0
  1. /sdcard -> /storage/sdcard0
  2. /storage/sdcard0 -> /storage/emulated/legacy
  3. /storage/emulated/legacy -> /storage/emulated/0

Based on the above, if all the locations point to the same virtual storage, what's the point in having separate storage locations for each different user?

If /storage/emulated/0,1,2,3,etc. all point to /storage/sdcard0, and saving files in any storage location make it appear in all other locations, how is it possible to have user designated storage if all information is the same for all users?

Or is it not supposed to be designed this way...that every user's storage should be the exact same, but if that were the case, then why does having multiple folders with different numbers for multiple users exist? Am I missing something here? Am I missing some key piece of information? Why allocate folders for a specific user if they all point to the same location and contain the same exact information?

xavier_fakerat
  • 10,065
  • 6
  • 41
  • 101
Narcotixs
  • 213
  • 3
  • 4
  • 14
  • 1
    See my comments on your similar question: When files are created in Android 4.2 and above, are files ever stored in one location? – and *do read* the Wikipedia article on symbolic links I told you instead of re-asking the same again. As I already wrote, you're looking at it from the wrong end, symbolic links work the other way around: it's not /storage/emulated/* pointing to /storage/sdcard0, but just the opposite – so sdcard always points to the current user's storage. – Izzy Apr 29 '17 at 10:23
  • 1
    @Izzy On my 5.1.1, /storage/sdcard0 points to /storage/emulated/legacy. All hail the Symlink Hell! – Grimoire Apr 29 '17 at 13:53
  • 1
    @DeathMaskSalesman Yes, same as in Narcotixs post. Now, where does /storage/emulated/legacy point to? #3 above. So what is accessed finally, and where are data written to and read from when accessing /sdcard? The storage area of the logged-in user (in the example above that's the device owner, as the 0 in emulated/0 indicates, because the device owner is logged in – if you follow the chain of Narcotixs' questions, OP never tried with a "secondary user"). – Izzy Apr 29 '17 at 13:58
  • @Izzy So, what you're saying is that /storage/emulated/legacy points to /mnt/shell/emulated/X, with X being the currently logged in user, is it? – Grimoire Apr 29 '17 at 14:05
  • 1
    @Izzy Yes, from the output of mount, I can now see that /dev/fuse is mounted on /mnt/shell/emulated. Pretty hacky way to handle things, especially if you consider that the internal storage visible to a non-rooted user is just a subset of the /data partition (i.e. /data/media). – Grimoire Apr 29 '17 at 14:10
  • @DeathMaskSalesman You got it, yes! That's what I'm saying all the time :) Just with minor device/ROM-specific differences (as what in our case is /mnt/shell/emulated/X in the OP's case is /storage/emulated/X). But results are the same, the corresponding ROMs just chose a different mount-point (to achieve better confusion – after all, isn't it a "mounted con FUSE"?) – Izzy Apr 29 '17 at 14:11
  • @Izzy That's the layer of psychotic hell the developers usually hide from the power users, heh. Why don't you write a huge answer with all of the above? – Grimoire Apr 29 '17 at 14:14
  • @DeathMaskSalesman because I already did that on Narcotixs' original question? Of course I could add my "Latin joke" ("mounting with FUSE (Latin: ’con FUSE’) leads to conFUSion") #D – Izzy Apr 29 '17 at 14:17
  • @Izzy Not just Latin, but modern Italian as well! – Grimoire Apr 29 '17 at 14:17
  • 1
    @Izzy , I finally understand now, it all makes sense. Symlinks just redirect content and data to the current user's designated storage location.They don't actually hold any data at all, there merely reflect what is in that location. So if that's the case, then for example, let's say I'm "user3" and my designated storage is "/storage/emulated/3". All the symlinks would only point that location, because that is the current user that is logged in. Thus, multi-user actually works. – Narcotixs Apr 29 '17 at 18:30
  • I wonder what would happen if a different user tries to access and save data in a different user's emulated storage (e.g., user3 attempts to access user1's emulated storage folder). Would user3 be able to gain either read or write access in the first place? @Izzy , any thoughts? – Narcotixs Apr 29 '17 at 18:39
  • \o/ Yes, exactly so :) And no, the mechanism should take care for that. If you take a closer look, all those targets belong to "root". I don't know how exactly that works, but accessing another user's content should not be possible (except when being root). – Izzy Apr 29 '17 at 18:42
  • Interesting...Well, I've exhausted you two, @Izzy and Death Mask Salesman, and I'm sorry for the confusion. Thanks for helping me understand symlinks and emulated storage. All hail the symlink hell! – Narcotixs Apr 29 '17 at 18:54
  • @Narcotixs let me close this one here as duplicate. I will update my answer with some additional details I found (the answer why you cannot access another users storage obviously is because it's not mounted – at least not in "your context", and you cannot access what is "not there" ;) – Izzy Apr 29 '17 at 19:00
  • @Izzy so when a different user logs in, all other users emulated storage is unmounted? So if you are user3, all you would see is /storage/emulated/3 for example? – Narcotixs Apr 29 '17 at 19:08
  • Something like that, yes. A bit more technical, though. Please see my updated answer for more details. – Izzy Apr 29 '17 at 19:23

0 Answers0