I mounted a NFS share on my rooted Android device using busybox mount.

I can read and create files, but when I create a file in any app, the file's permissions are set to 0600 (because the umask inside the app is 077). This means that a file created by an app can only be accessed by that app.

How can I change this behavior, and have the new files created with more permissions? Is there a way to have apps start with a different umask?

Also, how come all the files created on the sdcard are 0775 (thus ignoring the app's umask) ? I want my NFS mount to behave like the SD Card

I have a rooted Android box with version 4.4.2.


A quick Google search reveals a new API in Java 7 that allows permissions bits to be twiddled for individual files. This doesn't help with changing the umask, but it should allow you to override it after file creation. Check out:


If you really do need to change the umask, it doesn't seem to be a function currently exposed directly by the BCL. You'll have to resort to native calls, or use a library to do it on your behalf. I hear that such libraries do already exist -- you'd be looking for one that gives access to POSIX operating system functionality.

As for why files on the sdcard ignore the umask, sdcards are typically formatted using the vfat filesystem, which is basically backwards-compatible to MS-DOS/Windows 95 and doesn't recognize the concept of users. As such, it has no way to restrict access to a file; if you can't restrict access for particular users, then you'd only be restricting access for anyone, and why would you ever want to do that? :-)

What vfat has are file attributes -- read-only, hidden and system. There's no effective way to map the majority of UNIX file mode combinations to these. The driver, thus, simply always reports files as having a particular mode, set when the filesystem is mounted. Android mounts sdcards so that that mode is returned as 0755 (-rwxr-xr-x).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.