Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: base/files/file_util_linux.cc

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Also fix unit tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/files/file_util.h" 5 #include "base/files/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 <stdint.h>
9 #include <sys/vfs.h> 10 #include <sys/vfs.h>
10 11
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 13
13 namespace base { 14 namespace base {
14 15
15 bool GetFileSystemType(const FilePath& path, FileSystemType* type) { 16 bool GetFileSystemType(const FilePath& path, FileSystemType* type) {
16 struct statfs statfs_buf; 17 struct statfs statfs_buf;
17 if (statfs(path.value().c_str(), &statfs_buf) < 0) { 18 if (statfs(path.value().c_str(), &statfs_buf) < 0) {
18 if (errno == ENOENT) 19 if (errno == ENOENT)
19 return false; 20 return false;
20 *type = FILE_SYSTEM_UNKNOWN; 21 *type = FILE_SYSTEM_UNKNOWN;
21 return true; 22 return true;
22 } 23 }
23 24
24 // Not all possible |statfs_buf.f_type| values are in linux/magic.h. 25 // Not all possible |statfs_buf.f_type| values are in linux/magic.h.
25 // Missing values are copied from the statfs man page. 26 // Missing values are copied from the statfs man page.
26 switch (statfs_buf.f_type) { 27 switch (static_cast<uintmax_t>(statfs_buf.f_type)) {
danakj 2016/05/23 02:59:54 Why is this needed?
Luis Héctor Chávez 2016/05/24 15:27:52 Added a comment.
27 case 0: 28 case 0:
28 *type = FILE_SYSTEM_0; 29 *type = FILE_SYSTEM_0;
29 break; 30 break;
30 case EXT2_SUPER_MAGIC: // Also ext3 and ext4 31 case EXT2_SUPER_MAGIC: // Also ext3 and ext4
31 case MSDOS_SUPER_MAGIC: 32 case MSDOS_SUPER_MAGIC:
32 case REISERFS_SUPER_MAGIC: 33 case REISERFS_SUPER_MAGIC:
33 case BTRFS_SUPER_MAGIC: 34 case BTRFS_SUPER_MAGIC:
34 case 0x5346544E: // NTFS 35 case 0x5346544E: // NTFS
35 case 0x58465342: // XFS 36 case 0x58465342: // XFS
36 case 0x3153464A: // JFS 37 case 0x3153464A: // JFS
(...skipping 17 matching lines...) Expand all
54 case CGROUP_SUPER_MAGIC: 55 case CGROUP_SUPER_MAGIC:
55 *type = FILE_SYSTEM_CGROUP; 56 *type = FILE_SYSTEM_CGROUP;
56 break; 57 break;
57 default: 58 default:
58 *type = FILE_SYSTEM_OTHER; 59 *type = FILE_SYSTEM_OTHER;
59 } 60 }
60 return true; 61 return true;
61 } 62 }
62 63
63 } // namespace base 64 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698