OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <linux/magic.h> | 8 #include <linux/magic.h> |
9 #include <sys/vfs.h> | 9 #include <sys/vfs.h> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 | 12 |
13 // Make sure some of the newer macros from magic.h are defined. | 13 // Make sure some of the newer macros from magic.h are defined. |
14 // TODO(mostynb@opera.com): remove this after 2014. | 14 // TODO(mostynb@opera.com): remove this after 2014. |
15 #ifndef BTRFS_SUPER_MAGIC | 15 #ifndef BTRFS_SUPER_MAGIC |
16 #define BTRFS_SUPER_MAGIC 0x9123683E | 16 #define BTRFS_SUPER_MAGIC 0x9123683E |
17 #endif | 17 #endif |
18 #ifndef HUGETLBFS_MAGIC | 18 #ifndef HUGETLBFS_MAGIC |
19 #define HUGETLBFS_MAGIC 0x958458f6 | 19 #define HUGETLBFS_MAGIC 0x958458f6 |
20 #endif | 20 #endif |
| 21 #ifndef RAMFS_MAGIC |
| 22 #define RAMFS_MAGIC 0x858458f6 |
| 23 #endif |
21 #ifndef TMPFS_MAGIC | 24 #ifndef TMPFS_MAGIC |
22 #define TMPFS_MAGIC 0x01021994 | 25 #define TMPFS_MAGIC 0x01021994 |
23 #endif | 26 #endif |
24 | 27 |
25 namespace file_util { | 28 namespace file_util { |
26 | 29 |
27 bool GetFileSystemType(const base::FilePath& path, FileSystemType* type) { | 30 bool GetFileSystemType(const base::FilePath& path, FileSystemType* type) { |
28 struct statfs statfs_buf; | 31 struct statfs statfs_buf; |
29 if (statfs(path.value().c_str(), &statfs_buf) < 0) { | 32 if (statfs(path.value().c_str(), &statfs_buf) < 0) { |
30 if (errno == ENOENT) | 33 if (errno == ENOENT) |
(...skipping 20 matching lines...) Expand all Loading... |
51 case NFS_SUPER_MAGIC: | 54 case NFS_SUPER_MAGIC: |
52 *type = FILE_SYSTEM_NFS; | 55 *type = FILE_SYSTEM_NFS; |
53 break; | 56 break; |
54 case SMB_SUPER_MAGIC: | 57 case SMB_SUPER_MAGIC: |
55 case 0xFF534D42: // CIFS | 58 case 0xFF534D42: // CIFS |
56 *type = FILE_SYSTEM_SMB; | 59 *type = FILE_SYSTEM_SMB; |
57 break; | 60 break; |
58 case CODA_SUPER_MAGIC: | 61 case CODA_SUPER_MAGIC: |
59 *type = FILE_SYSTEM_CODA; | 62 *type = FILE_SYSTEM_CODA; |
60 break; | 63 break; |
61 case HUGETLBFS_MAGIC: // AKA ramfs | 64 case HUGETLBFS_MAGIC: |
| 65 case RAMFS_MAGIC: |
62 case TMPFS_MAGIC: | 66 case TMPFS_MAGIC: |
63 *type = FILE_SYSTEM_MEMORY; | 67 *type = FILE_SYSTEM_MEMORY; |
64 break; | 68 break; |
65 case CGROUP_SUPER_MAGIC: | 69 case CGROUP_SUPER_MAGIC: |
66 *type = FILE_SYSTEM_CGROUP; | 70 *type = FILE_SYSTEM_CGROUP; |
67 break; | 71 break; |
68 default: | 72 default: |
69 *type = FILE_SYSTEM_OTHER; | 73 *type = FILE_SYSTEM_OTHER; |
70 } | 74 } |
71 return true; | 75 return true; |
72 } | 76 } |
73 | 77 |
74 } // namespace file_util | 78 } // namespace file_util |
OLD | NEW |