Migrate sdcard0 to shell-accessible location.
Also remove mount() from adb, since it can come online long before
data partition is ready. Set EXTERNAL_STORAGE environment variable
to point to owner for backwards compatibility.
Bug: 7005701
Change-Id: I63444f6636624eb7ad89f053daa289663424639e
diff --git a/adb/adb.c b/adb/adb.c
index a13a7c9..95d3921 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -990,26 +990,6 @@
}
#endif /* !ADB_HOST */
-#if !ADB_HOST
-/* Give ourselves access to external storage, which is otherwise protected. */
-static void mount_external_storage(void) {
- // Create private mount namespace for our process
- if (unshare(CLONE_NEWNS) == -1) {
- fatal_errno("Failed to unshare()");
- }
-
- // Mark rootfs as being a slave in our process so that changes
- // from parent namespace flow into our process.
- if (mount("rootfs", "/", NULL, (MS_SLAVE | MS_REC), NULL) == -1) {
- fatal_errno("Failed to mount() rootfs as MS_SLAVE");
- }
-
- if (mount(EXTERNAL_STORAGE_SYSTEM, EXTERNAL_STORAGE_APP, "none", MS_BIND, NULL) == -1) {
- fatal_errno("Failed to mount() from %s", EXTERNAL_STORAGE_SYSTEM);
- }
-}
-#endif /* !ADB_HOST */
-
int adb_main(int is_daemon, int server_port)
{
#if !ADB_HOST
@@ -1042,7 +1022,9 @@
}
#else
- mount_external_storage();
+ // Our external storage path may be different than apps, since
+ // we aren't able to bind mount after dropping root.
+ setenv("EXTERNAL_STORAGE", getenv("ADB_EXTERNAL_STORAGE"), 1);
/* don't listen on a port (default 5037) if running in secure mode */
/* don't run as root if we are running in secure mode */