2017년 8월 7일 월요일

Confused by the many locations of the virtual /sdcard/


Some devices (like my Nexus 4) don't have an external slot for an SD Card. Instead, there's a root folder called /sdcard/ that is treated the same way. But I also find other paths that all point to the same files -- there must be some kind redirects going on (I think this is called symlinks in Linux).
All these paths contain the same files:
/sdcard/
/storage/sdcard0/
/storage/emulated/0/
/storage/emulated/legacy/
Which path is the "actual" one? What about the other paths? What are they used for, why do they exist?

--
Recommended lecture: Why did /sdcard/ turn into /sdcard/0/ with 4.2?.
In short: It has to do with the multi-user functionality introduced with Jelly Bean:

⦁ /storage/emulated/0/: to my knowledge, this refers to the "emulated MMC" ("owner part"). Usually this is the internal one. The "0" stands for the user here, "0" is the first user aka device-owner. If you create additional users, this number will increment for each.

⦁ /storage/emulated/legacy/ as before, but pointing to the part of the currently working user (for the owner, this would be a symlink to /storage/emulated/0/). So this path should bring every user to his "part".

⦁ /sdcard/: According to a comment by Shywim, this is a symlink to...

  ⦁ /mnt/sdcard (Android < 4.0)
  ⦁ /storage/sdcard0 (Android 4.0+)

⦁ /storage/sdcard0/: As there's no legacy pendant here (see comments below), the "0" in this case rather identifies the device (card) itself. One could, eventually, connect a card reader with another SDCard via OTG, which then would become /storage/sdcard1 (no proof for that, just a guess -- but I'd say a good one)
Though one might get to the conclusion there should be a /storage/sdcard/legacy as well, there isn't (see comments) -- which completely makes sense with my assumption of the numbers here are not related to the user, but rather to possible multiple cards: "0" would always be the one in the card-slot of the device, so no need for a "legacy symlink" here.

--
Yea a bit confusing but these are alternate paths for the memory layout
/mnt/sdcard0/ (Internal Virtual SD Card)
and Izzy your correct if more devices are connected, but the naming could be different depending on device.
ex. /mnt/sdcard1/ (Physical SD Card in SD slot)
but other devices such as a Usb flash drive connect with an adapter could be called
/mnt/media_rw/usbdisk (android kitkat 4.4 and above?) or /mnt/usbdisk (jellybean 4.1 - 4.2)

--

댓글 없음:

댓글 쓰기