Chromium Code Reviews| Index: chrome/browser/chromeos/gdata/gdata_file_system.cc |
| diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc |
| index a88c8636ae018a893ed7e24350f84d32fd8d3eff..c00eaf7bd82d331e9a9bd52c6172a662da97db58 100644 |
| --- a/chrome/browser/chromeos/gdata/gdata_file_system.cc |
| +++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| #include <errno.h> |
| +#include <sys/stat.h> |
| #include <utility> |
| @@ -207,6 +208,22 @@ base::PlatformFileError CreateCacheDirectories( |
| return error; |
| } |
| +// Changes the permissions of |file_path| to |permissions|. |
| +// Returns the platform error code of the operation. |
| +base::PlatformFileError ChangeFilePermissions(const FilePath& file_path, |
| + mode_t permissions) { |
| + base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| + |
| + if (chmod(file_path.value().c_str(), permissions) != 0) { |
| + error = SystemToPlatformError(errno); |
| + PLOG(ERROR) << "Error changing permissions of " << file_path.value(); |
|
kuan
2012/04/13 02:12:13
if u want more informative log, u can append strer
Ben Chan
2012/04/13 03:05:21
PLOG() actually does that but is preferred because
kuan
2012/04/13 03:30:59
i didn't know that, gd to know, thanks :)
|
| + } else { |
| + DVLOG(1) << "Changed permissions of " << file_path.value(); |
| + } |
| + |
| + return error; |
| +} |
| + |
| // Modifies cache state of file on IO thread pool, which involves: |
| // - moving or copying file (per |file_operation_type|) from |source_path| to |
| // |dest_path| if they're different |
| @@ -3252,7 +3269,14 @@ void GDataFileSystem::InitializeCacheIfNecessary() { |
| void GDataFileSystem::InitializeCacheOnIOThreadPool() { |
| base::PlatformFileError error = CreateCacheDirectories(cache_paths_); |
| + if (error != base::PLATFORM_FILE_OK) |
| + return; |
| + // Change permissions of cache persistent directory to u+rwx,og+x in order to |
| + // allow archive files in that directory to be mounted by cros-disks. |
| + error = ChangeFilePermissions( |
| + gdata_cache_path_.Append(kGDataCachePersistentDir), |
|
kuan
2012/04/13 02:12:13
u can use cache_paths_[GDataRootDirectory::CACHE_T
Ben Chan
2012/04/13 03:05:21
Done.
|
| + S_IRWXU | S_IXGRP | S_IXOTH); |
| if (error != base::PLATFORM_FILE_OK) |
| return; |