[Nexus 7 General] jmtw000:
I think Google really ****ed us good on this one. I did a little digging around in the source code documentation for 4.2 and I think I understand what's happening. I finally found the explaination of exactly how they're ****ing us (see below, last paragraph). Note to Google: <sarcasm>Thanks for making this info so easily available</sarcasm> Anyhow, it looks like they're using the Linux kernel shared subtree feature to create this mess. This is a good explaination of what it's all about:

http://www.mjmwired.net/kernel/Documentation/filesystems/sharedsubtree.txt (Check out section 2b which describes exactly the behavior we're seeing)

Init initially mounts / as "shared" then, they use the dalvik VM to set it as a "slave". From dalvik/vm/Init.cpp:

// Mark rootfs as being a slave so that changes from default

// namespace only flow into our children.

if (mount("rootfs", "/", NULL, (MS_SLAVE | MS_REC), NULL) == -1) {

SLOGE("Failed to mount() rootfs as MS_SLAVE: %s", strerror(errno));

return -1;

}

I may be wrong, as this whole thing is new to me, but I think what this means is that the only way to let other processes see mounts is if the dalvik vm (or init) mounts the volume, since it is what set / to slave and changes only propagate down from the parent. At this point, I'm thinking of maybe changing the init.rc script in the boot.img so that it does not set / to shared. But this will probably break stuff. Another possibility is to try to mount the cifs share at boot time in init.rc. These are both less than ideal options though. Anyone else have any ideas?

From docs/source.android.com/src/tech/storage/index.md:

...

## Multi-user external storage

Starting in Android 4.2, devices can support multiple users, and external

storage must meet the following constraints:

* Each user must have their own isolated primary external storage, and must not

have access to the primary external storage of other users.

* The `/sdcard` path must resolve to the correct user-specific primary external

storage based on the user a process is running as.

* Storage for large OBB files in the `Android/obb` directory may be shared

between multiple users as an optimization.

* Secondary external storage must not be writable by apps.

The default platform implementation of this feature leverages Linux kernel

namespaces to create isolated mount tables for each Zygote-forked process, and

then uses bind mounts to offer the correct user-specific primary external

storage into that private namespace.

At boot, the system mounts a single emulated external storage FUSE daemon at

`EMULATED_STORAGE_SOURCE`, which is hidden from apps. After the Zygote forks,

it bind mounts the appropriate user-specific subdirectory from under the FUSE

daemon to `EMULATED_STORAGE_TARGET` so that external storage paths resolve

correctly for the app. Because an app lacks accessible mount points for other

users’ storage, they can only access storage for the user it was started as.

This implementation also uses the shared subtree kernel feature to propagate

mount events from the default root namespace into app namespaces, which ensures

that features like ASEC containers and OBB mounting continue working correctly.

It does this by mounting the rootfs as shared, and then remounting it as slave

after each Zygote namespace is created.