Userland: How to access sdcard?

Created on 20 Jun 2018  路  16Comments  路  Source: CypherpunkArmory/UserLAnd

I'm trying to find a way to access sd card but I'm getting Permission Denied everywhere. Even with fake root. /data is inaccessible, there's no /sdcard and most of directories in /mnt return Permission Denied as well.

I gave UserLAnd permission to Storage on Android permissions level. Tried reinstalling multiple times. Didn't help.

enhancement question

Most helpful comment

Android's /sdcard appears to be mounted at /host-rootfs/sdcard/.

All 16 comments

also where are stored UserLAnd files in Android storage? Are they still located in some "public" location like sdcard or somewhere in system files, inaccessible by Android file browsers?

Android's /sdcard appears to be mounted at /host-rootfs/sdcard/.

Could you add some symlink somewhere? Because listing /host-rootfs itself gives Permission denied so it's a bit hard to guess what's inside and that you can jump over it to /host-rootfs/sdcard/

We can add a binding

We had this on gnuroot debian and will do it here too. The path for the sdcard is not always the same, so the binding will not always be /sdcard -> /host-rootfs/sdcard

A proot binding is conceptually similar to a symbolic link, but different.

@lapsio ,

Thank you for your report and request. I have organized this reply into two parts, the first being related to permissions and the second being related to UserLAnd file locations.

Part 1:
Even as root, some directories in Android will return a 'permission denied' error if you attempt to perform certain tasks within them. For example, I can confirm that in the "data" folder the ls command will return a permission denied error. This is actually intended behavior in Android. However, you may be able to perform the same command within certain sub-directories.

"ls /data/data/tech.ula" should not return an error. If you can confirm this works for you @lapsio , please reply to this thread.

In regards to sdcard permissions , Android implements a different method of accessing it. As @thedward stated, the directory /host-rootfs/sdcard is the correct method to access that location. Furthermore, I do not believe any subdirectories within /host-rootfs should be met with permissions errors if you are accessing it as root.

Part 2:
UserLAnd undergoes a somewhat complex installation procedure, and the short version (from my limited understanding - if this is incorrect please correct this statement) is that the majority of installation files for debian will be found in the /data folder and subfolders for Android.

Any downloaded files will be stored in the Android download manager default location (folder "Downloads" for Android 7.0).

Thank you for filing this issue,
-Adam

Yeah i know proot will give Permission Denied in lots of cases because it's fake root so it's not an issue. Issue is that there are _some_ files _somewhere_ which are accessible after going through "denied wall of obscurity". I think listing them in documentation or some README file in default user's home would be sufficient solution if they're not that much predictable. Well I just added ln -s /host-rootfs/sdcard / and it's fine but I wouldn't guess it without help. Here are my permissions after sudo su:

root@localhost:/home/lapsio# ls /data                                                  
ls: cannot open directory '/data': Permission denied                                   
root@localhost:/home/lapsio# ls /data/                                                 
ls: cannot open directory '/data/': Permission denied                                  
root@localhost:/home/lapsio# ls /data/data                                             
ls: cannot open directory '/data/data': Permission denied                              
root@localhost:/home/lapsio# ls /data/data/                                            
ls: cannot open directory '/data/data/': Permission denied                             
root@localhost:/home/lapsio# ls /data/data/tech.ula                                    
cache  code_cache  databases  files  shared_prefs                                      
root@localhost:/home/lapsio# ls /host-rootfs                                           
ls: cannot open directory '/host-rootfs': Permission denied                            
root@localhost:/home/lapsio# ls /host-rootfs/                                          
ls: cannot open directory '/host-rootfs/': Permission denied                           
root@localhost:/home/lapsio# ls /host-rootfs/sdcard                                    
ASUS                    Music               Downloads.... etc                                
root@localhost:/home/lapsio#

This is another thing that worries me a bit but I don't know if it's okay:

lapsio@localhost ~> ls /mnt/                                                           
ls: cannot access '/mnt/media_rw': Permission denied                                   
appfuse/  asec/  expand/  media_rw/  obb/  runtime/  sdcard@  secure/  user/           
lapsio@localhost ~> file /mnt/sdcard                                                   
/mnt/sdcard: broken symbolic link to /storage/self/primary                             
lapsio@localhost ~>

I mean broken symbolic links is not really something you expect on fresh system i guess... Besides, for now this version seems to have superior compatibility comparing to old one in terms of files permissions handling. I compiled and installed without any issues some programs that required manual install scripts modification under old GNURoot in order to not crash in the middle.

So i would like to add, I can definitely ls /host-rootfs and most of the other sub directories here except for /host-rootfs/data. And yes I can ls /host-rootfs/mnt. I assume at least for my device (S9+) that root directory is in /host-rootfs.

This should be fixed with release 0.2.3. #139
You can get to the sdcard via /sdcard from within the running session.
Please file separate issues for anything new.

/host-rootfs/sdcard

it's work tank's

Hello all,

I have two Android phones
One is running Android 6.0 and can access the SDCard from within UserLand Debian in root mode with ln -s /host-rootfs/sdcard /

The second one is running Android 8.1.0 and CANNOT access the SDCard from within UserLand Debian in root mode. The same command ln -s /host-rootfs/sdcard / return premission denied

I also tried under root permission (sudo su) to change the repertory rights with chmod -R 777 /host-rootfs and I got :
chmod : changing permissions of '/host-rootfs': Read-only file system
chmod : cannot read directory '/host-rootfs': Permission denied

While the same command work on Android 6.0

Please help as my Android phone 6.0 has issues and I would like to use my new phone.
Best regards,
Jean

Hi,

I also have this issue on a LG G7 running Android v9, not rooted, although I allow storage access to UserLand v2.6.3. In the previous version of UserLand I was able to access at least the _internal storage_ at mount point /sdcard (even I'd like to access the real SD card, too). How could I exchange data between Android and UserLand, else?

When I call "sudo mount" I get 11 mounts of "type sdcardfs" and "type vfat" listed which are all not working, examples:
/mnt/media_rw/F3B9-110D on /storage/F3B9-110D type sdcardfs
/mnt/media_rw/F3B9-110D on /mnt/runtime/write/F3B9-110D type sdcardfs
/data/media on /storage/emulated type sdcardfs
/dev/block/vold/public:179,1 on /mnt/media_rw/F3B9-110D type vfat
/dev/block/bootdevice/by-name/modem_b on /vendor/firmware_mnt type vfat
Even for sudo it does not work, and also "sudo ls -l /host-rootfs/" returns
/bin/ls: cannot open directory '/host-rootfs/': Permission denied

Please fix (or at least allow the previous access to the internal storage).

Thanks
Dirk

I read the information about scoped access at link https://github.com/CypherpunkArmory/UserLAnd/wiki/Importing-and-exporting-files-in-UserLAnd now. But what if I like to promote UserLAnd to be able to access all files and folders again? Think about a file explorer, how would such an app work in future?

Kind regards
Dirk

Could you add some symlink somewhere? Because listing /host-rootfs itself gives Permission denied so it's a bit hard to guess what's inside and that you can jump over it to /host-rootfs/sdcard/
/host-rootfs would show permission denied as it cant open root folders but /host-rootfs/sdcard/ will open.(It works for me)

Funci贸no, gracias, son los mejores!!!

Was this page helpful?
0 / 5 - 0 ratings