nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.16k stars 65 forks source link

Accessing /emulated/storage/0 from Nix-on-Droid #238

Open unclechu opened 1 year ago

unclechu commented 1 year ago

I would like to have some free access to a shared directory that Nix-on-Droid and other applications can see. So that I could transfer files back and forth.

Device: OnePlus 9
Android version: 13

The device storage path is /storage/emulated/0 as I can see from Ghost Commander. I gave the storage access permission to Nix-on-Droid in its application settings. The problem is that I can’t ls or read anything, all attempts end with “Permission denied”. But I can create/copy files and directories, and remove files. So this works:

touch /storage/emulated/0/foo
rm /storage/emulated/0/foo
cp ~/some-dir -r /storage/emulated/0

So I can send files from Nix-on-Droid but not the other way around. Do you have any ideas how to get files into Nix-on-Droid environment from the outside world?

t184256 commented 1 year ago

Does it manifest the same problem in a recovery session? (long tap the app icon)?

Is your storage available at any different paths?

Is some directory higher up in the chain missing an execute bit in the permission mask?

unclechu commented 1 year ago

@t184256

Does it manifest the same problem in a recovery session? (long tap the app icon)?

I don’t think I have this feature. Tried to find other ways to run it with no success.

Is your storage available at any different paths?

In df output I can see also /data which has the same size parameters. It seems /data/data is the directory where all application directories are but I can’t see its contents. Not from Nix-on-Droid, not from Ghost Commander.

Is some directory higher up in the chain missing an execute bit in the permission mask?

Probably, I don’t know how to check. I get “Permission denied” for anything above /data/data/com.termux.nix. ls /data/data gets me “Permission denied”.

$ ls -lahZ /data/data/com.termux.nix
total 65K
drwx------ 8 nix-on-droid nix-on-droid ? 3.4K Oct 21 2021 .
drwxrwx--x 387 1000 1000 ? 52K Dec 11 13:16 ..
drwxrwx--x 2 nix-on-droid nix-on-droid ? 3.4K Oct 21 2021 app_textures
drwx------ 3 nix-on-droid nix-on-droid ? 3.4K Oct 21 2021 app_webview
drwxrws--x 3 nix-on-droid 20256 ? 3.4K Oct 21 2021 cache
drwxrws--x 2 nix-on-droid 20256 ? 3.4K Oct 19 2021 code_cache
drwx------ 5 nix-on-droid nix-on-droid ? 3.4K Dec 10 22:34 files
drwxrwx--x 2 nix-on-droid nix-on-droid ? 3.4K Dec 11 12:56 shared_prefs
t184256 commented 1 year ago

I don’t think I have this feature. Tried to find other ways to run it with no success.

You should have it. Built-in Android terminal (hidden behind developer settings) or ADB shell would help.

Probably, I don’t know how to check. I get “Permission denied” for anything above /data/data/com.termux.nix. ls /data/data gets me “Permission denied”.

Yeah, rooting device and ls -lZ'ing would've been helpful, I'm not sure what's happening here.

You've mentioned that you can copy some-dir into /storage/emulated/0 - can you chmod +rx and/or ls it afterwards?

unclechu commented 1 year ago

@t184256

You've mentioned that you can copy some-dir into /storage/emulated/0 - can you chmod +rx and/or ls it afterwards?

It’s interesting, chmod ugo+rwx on that copied directory succeeds but any attempt to ls it fails with “Permission denied”.

unclechu commented 1 year ago

Yeah, rooting device and ls -lZ'ing would've been helpful

I didn’t root my device.

c0decafe commented 1 year ago

Got the same issue with the latest app + nix update:

ls: cannot open directory '/storage/emulated/0': Permission denied

It worked fine before that.

Does it manifest the same problem in a recovery session? (long tap the app icon)?

interestingly no, works fine from the failsafe session.

Any pointers on where to look?

dlip commented 1 year ago

Same here unfortunately

dlip commented 1 year ago

I actually managed to get it working by going into the app permissions, turning file access off, then on again!

unclechu commented 7 months ago

@dlip The trick didn’t work for me. But now I got a new device and just going to the settings of the app and turning on “files access” permissions did give me the access to /storage/emulated/0. Works just fine. Android version is the same (13).