Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / base / files / file_util_linux.cc
blobb230fd96484c7d8e75f408edc912019d60ffb728
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/files/file_util.h"
7 #include <errno.h>
8 #include <linux/magic.h>
9 #include <sys/vfs.h>
11 #include "base/files/file_path.h"
13 namespace base {
15 bool GetFileSystemType(const FilePath& path, FileSystemType* type) {
16 struct statfs statfs_buf;
17 if (statfs(path.value().c_str(), &statfs_buf) < 0) {
18 if (errno == ENOENT)
19 return false;
20 *type = FILE_SYSTEM_UNKNOWN;
21 return true;
24 // Not all possible |statfs_buf.f_type| values are in linux/magic.h.
25 // Missing values are copied from the statfs man page.
26 switch (statfs_buf.f_type) {
27 case 0:
28 *type = FILE_SYSTEM_0;
29 break;
30 case EXT2_SUPER_MAGIC: // Also ext3 and ext4
31 case MSDOS_SUPER_MAGIC:
32 case REISERFS_SUPER_MAGIC:
33 case BTRFS_SUPER_MAGIC:
34 case 0x5346544E: // NTFS
35 case 0x58465342: // XFS
36 case 0x3153464A: // JFS
37 *type = FILE_SYSTEM_ORDINARY;
38 break;
39 case NFS_SUPER_MAGIC:
40 *type = FILE_SYSTEM_NFS;
41 break;
42 case SMB_SUPER_MAGIC:
43 case 0xFF534D42: // CIFS
44 *type = FILE_SYSTEM_SMB;
45 break;
46 case CODA_SUPER_MAGIC:
47 *type = FILE_SYSTEM_CODA;
48 break;
49 case HUGETLBFS_MAGIC:
50 case RAMFS_MAGIC:
51 case TMPFS_MAGIC:
52 *type = FILE_SYSTEM_MEMORY;
53 break;
54 case CGROUP_SUPER_MAGIC:
55 *type = FILE_SYSTEM_CGROUP;
56 break;
57 default:
58 *type = FILE_SYSTEM_OTHER;
60 return true;
63 } // namespace base