I am creating an application for Android which enables users to create encrypted LUKS partitions and then mount them to given directories on external memory.
For the partition to be usable I create an ext2 file system using the Busybox mkfs.ext2 command. The problem occurs once a user tries to create a file/directory at the root of the partition. For some reason it is impossible to create a file through Java as the “File.mkdirs()” method fails. However, it is possible to create this file through the command-line. And this error occurs only when at the root of the partition (i.e if I create a folder through the command line I am then able to create files within that folder through Java). Also, I am able to create a file if I create a vfat file system instead of ext2.
Any help would be greatly appreciated.
Harry
EDIT
Fixed. I was mounting the file system as root
My final solution to this problem was to create a vfat file system rather than ext2 as vfat doesn’t have permissions etc… This worked for me as I did not need the extra security of permissions. However, if you need an ext2 file system which you need to mount as root but want it to be useable by other users I recomment looking into the mount ownmask option (man mount).