1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/file_util.h"
7 #include "base/files/file_path.h"
14 bool GetFileSystemType(const base::FilePath
& path
, FileSystemType
* type
) {
15 struct statfs statfs_buf
;
16 if (statfs(path
.value().c_str(), &statfs_buf
) < 0) {
19 *type
= FILE_SYSTEM_UNKNOWN
;
23 // While you would think the possible values of f_type would be available
24 // in a header somewhere, it appears that is not the case. These values
25 // are copied from the statfs man page.
26 switch (statfs_buf
.f_type
) {
28 *type
= FILE_SYSTEM_0
;
30 case 0xEF53: // ext2, ext3.
32 case 0x5346544E: // NFTS
33 case 0x52654973: // reiser
34 case 0x58465342: // XFS
35 case 0x9123683E: // btrfs
36 case 0x3153464A: // JFS
37 *type
= FILE_SYSTEM_ORDINARY
;
40 *type
= FILE_SYSTEM_NFS
;
42 case 0xFF534D42: // CIFS
44 *type
= FILE_SYSTEM_SMB
;
46 case 0x73757245: // Coda
47 *type
= FILE_SYSTEM_CODA
;
49 case 0x858458f6: // ramfs
50 case 0x01021994: // tmpfs
51 *type
= FILE_SYSTEM_MEMORY
;
53 case 0x27e0eb: // CGROUP
54 *type
= FILE_SYSTEM_CGROUP
;
57 *type
= FILE_SYSTEM_OTHER
;