I have an application (running in an IDE under my user account) that does the following:
- It creates an empty file with ~1GiB size.
- It calls
mkfson this file (btrfs currently, but may change in future). - It calls
udisksctl loop-setupandudisksctl mountto mount it.
So far so good, but now I have the problem that I cannot create any files inside. To do this I would need to run chmod, which I can only do as root.
I do not want to run my application as root, because this could have huge security impacts.
In my opinion there should be a way to get the required permissions (without beeing root), because I have full access to the underlying image file nevertheless.
Edit: I found a solution that works at least. I'm creating a filesystem image with the according permissions set. Then I zip it and deploy it with my application. It is not perfect, but at least it works. If someone has a better idea, I would be very thankful to hear it.
Edit2: I do not need to chown or chmod anything, I just need to create, read, write and delete files and directories. Choosing a different filesystem is not an option.
mtoolsallows you to manipulate vfat images.