termux-setup-storage
only grants android.permission.WRITE_EXTERNAL_STORAGE that lets the app access internal SD card i.e. /sdcard
.
Android's init creates rootfs /
with permissions 0:0
(uid:gid) and 0755
(mode). So the root directory should be accessible to any non-root user.
However SELinux plays its role restricting unauthorized access to rootfs. You can view such policy denials by:
dmesg | grep 'avc: denied'
* Most probably SELinux will deny this command too if run from non-root app
To view all SEPolicy rules, sesearch
tool from setools-android can be used.
To set SELinux permissive:
echo 0 >/sys/fs/selinux/enforce
# or
setenforce 0
Or add an exception to SELinux policy:
supolicy --live 'allow untrusted_app rootfs dir { read open }'
* supolicy
tool is provided by rooting solutions e.g. Magisk, SuperSu
This policy allows reading rootfs but still you may get errors because reading attributes of files/directories under rootfs isn't permitted by policy.
Also both solutions need root privileges and are nonpersistent i.e. need to be set after reboot.
So if you are running a non-rooted production build of Android (with enforcing SELinux), you won't be able to read rootfs /
.
/
, not "root of Android storage" which is usually/storage/emulated/0
. Which one do you mean? – iBug Aug 25 '18 at 17:42termux-setup-storage
has no effect on/
. Moreover, I'm able tols /
as non-root user, so your situation might very well depend on your phone's configuration of/
's permissions, even moreso when Andy lets you see the directory's contents. – Grimoire Aug 26 '18 at 13:56