diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-20 00:36:01 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-20 00:36:01 +0000 |
commit | 1d01d411a1d7e2ef29adf072855eb561e4c34cf7 (patch) | |
tree | 161073ff19231ddaf502b0be90500c7a9dcfd5ab /base | |
parent | 56c18fe00eb1b3bb958c9135a47f17350a82113e (diff) | |
download | chromium_src-1d01d411a1d7e2ef29adf072855eb561e4c34cf7.zip chromium_src-1d01d411a1d7e2ef29adf072855eb561e4c34cf7.tar.gz chromium_src-1d01d411a1d7e2ef29adf072855eb561e4c34cf7.tar.bz2 |
linux: add UMA stat for the file system where the prefs are stored
I'd like to see how common it is to use a network file system for
your home directory. This would help evaluate how important it is
to support these users.
See also:
http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/b43d2905f079fa1c
Review URL: http://codereview.chromium.org/3187011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56786 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 1 | ||||
-rw-r--r-- | base/file_util.h | 24 | ||||
-rw-r--r-- | base/file_util_linux.cc | 59 |
3 files changed, 82 insertions, 2 deletions
diff --git a/base/base.gypi b/base/base.gypi index d6e13b5..383f645 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -77,6 +77,7 @@ 'file_util.cc', 'file_util.h', 'file_util_deprecated.h', + 'file_util_linux.cc', 'file_util_mac.mm', 'file_util_posix.cc', 'file_util_win.cc', diff --git a/base/file_util.h b/base/file_util.h index 91b16d2..ce30b5e 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -612,9 +612,29 @@ inline bool MakeFileUnreadable(const FilePath& path) { // is passed in. If it is 0 then the whole file is paged in. The step size // which indicates the number of bytes to skip after every page touched is // also passed in. - bool PreReadImage(const wchar_t* file_path, size_t size_to_read, - size_t step_size); +bool PreReadImage(const wchar_t* file_path, size_t size_to_read, + size_t step_size); #endif // OS_WIN + +#if defined(OS_LINUX) +// Broad categories of file systems as returned by statfs() on Linux. +enum FileSystemType { + FILE_SYSTEM_UNKNOWN, // statfs failed. + FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. + FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 + FILE_SYSTEM_NFS, + FILE_SYSTEM_SMB, + FILE_SYSTEM_CODA, + FILE_SYSTEM_MEMORY, // in-memory file system + FILE_SYSTEM_OTHER, // any other value. + FILE_SYSTEM_TYPE_COUNT +}; + +// Attempts determine the FileSystemType for |path|. +// Returns false if |path| doesn't exist. +bool GetFileSystemType(const FilePath& path, FileSystemType* type); +#endif + } // namespace file_util // Deprecated functions have been moved to this separate header file, diff --git a/base/file_util_linux.cc b/base/file_util_linux.cc new file mode 100644 index 0000000..dd0c820 --- /dev/null +++ b/base/file_util_linux.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/file_util.h" + +#include "base/file_path.h" + +#include <errno.h> +#include <sys/vfs.h> + +namespace file_util { + +bool GetFileSystemType(const FilePath& path, FileSystemType* type) { + struct statfs statfs_buf; + if (statfs(path.value().c_str(), &statfs_buf) < 0) { + if (errno == ENOENT) + return false; + *type = FILE_SYSTEM_UNKNOWN; + return true; + } + + // While you would think the possible values of f_type would be available + // in a header somewhere, it appears that is not the case. These values + // are copied from the statfs man page. + switch (statfs_buf.f_type) { + case 0: + *type = FILE_SYSTEM_0; + break; + case 0xEF53: // ext2, ext3. + case 0x4D44: // dos + case 0x5346544E: // NFTS + case 0x52654973: // reiser + case 0x58465342: // XFS + case 0x9123683E: // btrfs + case 0x3153464A: // JFS + *type = FILE_SYSTEM_ORDINARY; + break; + case 0x6969: // NFS + *type = FILE_SYSTEM_NFS; + break; + case 0xFF534D42: // CIFS + case 0x517B: // SMB + *type = FILE_SYSTEM_SMB; + break; + case 0x73757245: // Coda + *type = FILE_SYSTEM_CODA; + break; + case 0x858458f6: // ramfs + case 0x01021994: // tmpfs + *type = FILE_SYSTEM_MEMORY; + break; + default: + *type = FILE_SYSTEM_OTHER; + } + return true; +} + +} // namespace |