bug 637487 - Unable to install extensions when Fennec moved to SD Card r=dougt a=blocking-fennec
authorBrad Lassey <blassey@mozilla.com>
Fri, 04 Mar 2011 17:57:25 -0500
changeset 63325 378eec685e74ab810aff9bb3f910625256b774dc
parent 63324 e56ecd8b3a68c158025207c5fd081d043e28f5ce
child 63326 6b25a8d97e211308898a78b1e7e1ab9e75b3f4aa
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersdougt, blocking-fennec
bugs637487
milestone2.0b13pre
bug 637487 - Unable to install extensions when Fennec moved to SD Card r=dougt a=blocking-fennec
xpcom/io/nsLocalFileUnix.cpp
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -114,16 +114,17 @@ static nsresult MacErrorMapper(OSErr inE
 #include <hildon-uri.h>
 #include <hildon-mime.h>
 #include <libosso.h>
 #endif
 
 #ifdef ANDROID
 #include "AndroidBridge.h"
 #include "nsIMIMEService.h"
+#include <linux/magic.h>
 #endif
 
 #include "nsNativeCharsetUtils.h"
 #include "nsTraceRefcntImpl.h"
 
 #define ENSURE_STAT_CACHE()                     \
     PR_BEGIN_MACRO                              \
         if (!FillStatCache())                   \
@@ -1098,19 +1099,30 @@ NS_IMETHODIMP
 nsLocalFile::SetPermissions(PRUint32 aPermissions)
 {
     CHECK_mPath();
 
     /*
      * Race condition here: we should use fchmod instead, there's no way to 
      * guarantee the name still refers to the same file.
      */
-    if (chmod(mPath.get(), aPermissions) < 0)
-        return NSRESULT_FOR_ERRNO();
-    return NS_OK;
+    if (chmod(mPath.get(), aPermissions) >= 0)
+        return NS_OK;
+#if defined(ANDROID) && defined(STATFS)
+    // For the time being, this is restricted for use by Android, but we 
+    // will figure out what to do for all platforms in bug 638503
+    struct STATFS sfs;
+    if (STATFS(mPath.get(), &sfs) < 0)
+         return NSRESULT_FOR_ERRNO();
+
+    // if this is a FAT file system we can't set file permissions
+    if (sfs.f_type == MSDOS_SUPER_MAGIC )
+        return NS_OK;
+#endif
+    return NSRESULT_FOR_ERRNO();
 }
 
 NS_IMETHODIMP
 nsLocalFile::SetPermissionsOfLink(PRUint32 aPermissions)
 {
     // There isn't a consistent mechanism for doing this on UNIX platforms. We
     // might want to carefully implement this in the future though.
     return NS_ERROR_NOT_IMPLEMENTED;