From what I guess, internal storage is available by every user. If emulated storage is a storage location, made for a specific user, are files created in /storage/emulated/0
supposed to appear in /storage/sdcard0
? I assume no, because files that are user created should show up in emulated only, otherwise files created by the user would be available for all other users to see.
Answer
I've checked on one of my devices, and as the comment chain already suspected, you don't need to worry about everyone having access to everybody elses data. First:
/storage/sdcard0 -> /storage/emulated/legacy
Which means, it's just a symlink which always points to the data of the current user:
/storage/emulated/legacy -> /mnt/shell/emulated/0
(the first user – in my case the only one). Second, where you usually look for it:
/sdcard -> /storage/emulated/legacy
Same game again. So for the emulated SD card (aka the "internal SD card), the Android system takes care to map it accordingly for the current user. Not sure about the external SD card (if that e.g. could be used to share data between multiple users). This is usually found in /storage/sdcard1
:
$ mount | grep sdcard
/dev/block/vold/179:65 /mnt/media_rw/sdcard1 vfat […]
/dev/fuse /storage/sdcard1 fuse […]
$ ls /mnt/media_rw/sdcard1
/mnt/media_rw/sdcard1: Permission denied
$ su -c "ls /mnt/media_rw/sdcard1"
[data from external SD card]
So you can see the external SD card can only be accessed directly with root powers, why "ordinary users" have to go via a FUSE mount overlayed on that. So the system again might take care that each user can only access his/her own data in that place. I'm not familiar enough with the internals to say for sure (or even to say what exactly is done there).
Now for your explicit question, whether files created in /storage/emulated/0
supposed to appear in /storage/sdcard0
: Assuming you're speaking about /mnt/shell/emulated/0
(I couldn't find /storage/emulated/0
on my device), empirically they of course do, as both are the very same location: /storage/sdcard0 -> /storage/emulated/legacy -> /mnt/shell/emulated/0
– which means that /storage/sdcard0
shows what's contained in /mnt/shell/emulated/0
. But your concern is unwarranted: due to the "middle-man" (/storage/emulated/legacy
), /storage/sdcard0
always points to the storage of the "logged-in user" – so if e.g. the second user looks there, (s)he will see what's in /mnt/shell/emulated/1
(or which ever his/her emulated storage area is).
So as a PS, let me sum up things from the comments, as a short FAQ:
- I wonder what would happen if a different user tries to access and save data in a different user's emulated storage?
He receives an error message that it's either not there or not accessible. - Why are these symlinks needed?
Multiple reasons, many of them historical (one word: "compatibility"). - What are those symlinks and how do they work, in laymens terms?
They are basically "signposts", saying "please look there". Other than you initially assumed, they don't contain any data themselves – they are really only signposts or "pointers". The data itself resides at the "targeted location", and only there. For more details, please see the Wikipedia article on symbolic links.
Also see:
No comments:
Post a Comment