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