Chromium Code Reviews| Index: components/drive/chromeos/file_cache.cc |
| diff --git a/components/drive/chromeos/file_cache.cc b/components/drive/chromeos/file_cache.cc |
| index 1e6c145d8124d6ff25c04a5f50d414ace9e35c8b..bb6865f73e6de15b9eb084eea9e56ce93ed1cd78 100644 |
| --- a/components/drive/chromeos/file_cache.cc |
| +++ b/components/drive/chromeos/file_cache.cc |
| @@ -52,9 +52,20 @@ base::FilePath GetPathForId(const base::FilePath& cache_directory, |
| base::FilePath::FromUTF8Unsafe(util::EscapeCacheFileName(id))); |
| } |
| +// Returns if the filesystem backing |path| supports file attributes. |
| +// This will return false if the filesystem is for example tmpfs, which is used |
| +// for ephemeral mode. |
| +bool IsFileAttributesSupported(const base::FilePath& path) { |
| + getxattr(path.value().c_str(), "user.foo", nullptr, 0); |
|
hashimoto
2016/10/14 04:16:49
Please check that getxattr actually fails.
oka
2016/10/14 04:36:06
Done.
|
| + return errno != ENOTSUP; |
| +} |
| + |
| // Sets extended file attribute as |name| |value| pair. |
| bool SetExtendedFileAttributes(const base::FilePath& path, |
| const std::string& name, const std::string& value) { |
| + if (!IsFileAttributesSupported(path)) { |
|
hashimoto
2016/10/14 04:16:49
Isn't it better to check this at the beginning of
oka
2016/10/14 04:36:05
Done.
|
| + return true; |
| + } |
| return setxattr(path.value().c_str(), name.c_str(), value.c_str(), |
| value.size() + 1, 0) == 0; |
| } |
| @@ -94,6 +105,9 @@ FileAttributes GetFileAttributes(const base::FilePath& path) { |
| // Marks the cache file to be removable by cryptohome. |
| bool SetRemovable(const base::FilePath& path) { |
| + if (!IsFileAttributesSupported(path)) { |
|
hashimoto
2016/10/14 04:16:48
It'd be nice to have a brief comment to justify th
oka
2016/10/14 04:36:05
Done.
|
| + return true; |
| + } |
| FileAttributes flags = GetFileAttributes(path); |
| if (flags < 0) return false; |
| if ((flags & FS_NODUMP_FL) == FS_NODUMP_FL) return true; |
| @@ -103,6 +117,9 @@ bool SetRemovable(const base::FilePath& path) { |
| // Marks the cache file to be unremovable by cryptohome. |
| bool UnsetRemovable(const base::FilePath& path) { |
| + if (!IsFileAttributesSupported(path)) { |
|
hashimoto
2016/10/14 04:16:48
ditto.
oka
2016/10/14 04:36:06
Done.
|
| + return true; |
| + } |
| FileAttributes flags = GetFileAttributes(path); |
| if (flags < 0) return false; |
| if ((flags & FS_NODUMP_FL) == 0) return true; |