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. |
| 14 // TODO(mostynb@opera.com): remove this after 2014. |
| 15 #ifndef BTRFS_SUPER_MAGIC |
| 16 #define BTRFS_SUPER_MAGIC 0x9123683E |
| 17 #endif |
| 18 #ifndef HUGETLBFS_MAGIC |
| 19 #define HUGETLBFS_MAGIC 0x958458f6 |
| 20 #endif |
| 21 #ifndef TMPFS_MAGIC |
| 22 #define TMPFS_MAGIC 0x01021994 |
| 23 #endif |
| 24 |
13 namespace file_util { | 25 namespace file_util { |
14 | 26 |
15 bool GetFileSystemType(const base::FilePath& path, FileSystemType* type) { | 27 bool GetFileSystemType(const base::FilePath& path, FileSystemType* type) { |
16 struct statfs statfs_buf; | 28 struct statfs statfs_buf; |
17 if (statfs(path.value().c_str(), &statfs_buf) < 0) { | 29 if (statfs(path.value().c_str(), &statfs_buf) < 0) { |
18 if (errno == ENOENT) | 30 if (errno == ENOENT) |
19 return false; | 31 return false; |
20 *type = FILE_SYSTEM_UNKNOWN; | 32 *type = FILE_SYSTEM_UNKNOWN; |
21 return true; | 33 return true; |
22 } | 34 } |
(...skipping 30 matching lines...) Expand all Loading... |
53 case CGROUP_SUPER_MAGIC: | 65 case CGROUP_SUPER_MAGIC: |
54 *type = FILE_SYSTEM_CGROUP; | 66 *type = FILE_SYSTEM_CGROUP; |
55 break; | 67 break; |
56 default: | 68 default: |
57 *type = FILE_SYSTEM_OTHER; | 69 *type = FILE_SYSTEM_OTHER; |
58 } | 70 } |
59 return true; | 71 return true; |
60 } | 72 } |
61 | 73 |
62 } // namespace file_util | 74 } // namespace file_util |
OLD | NEW |