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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10072003: gdata: Change permissions of cache persistent directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698