From 81cc8b631f4dba01ba4ae75ac9d622b58dea64bd Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Fri, 4 Mar 2011 17:57:25 -0500 Subject: [PATCH] bug 637487 - Unable to install extensions when Fennec moved to SD Card r=dougt a=blocking-fennec --- xpcom/io/nsLocalFileUnix.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 88be319d1820..45112b5a0c95 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -119,6 +119,7 @@ static nsresult MacErrorMapper(OSErr inErr); #ifdef ANDROID #include "AndroidBridge.h" #include "nsIMIMEService.h" +#include #endif #include "nsNativeCharsetUtils.h" @@ -1103,9 +1104,20 @@ nsLocalFile::SetPermissions(PRUint32 aPermissions) * 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