aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-02-24 16:07:23 -0500
committerMike Lockwood <lockwood@android.com>2010-02-24 16:07:23 -0500
commitd969faa161310d0a3792766320daa3200b84bd74 (patch)
treeeb4fea26978d27904b74781f793a345c2bcc3ec7
parenta9db22f1228996d8f81e4f4903fa5c598a606fbd (diff)
downloadsystem_core-d969faa161310d0a3792766320daa3200b84bd74.tar.gz
system_core-d969faa161310d0a3792766320daa3200b84bd74.tar.bz2
system_core-d969faa161310d0a3792766320daa3200b84bd74.zip
adb: Attempt to unmount the SD card before rebooting.
Change-Id: Idd4d96b4704f4e1bd324e72bca87611a23e30801 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--adb/adb.c3
-rw-r--r--adb/services.c16
2 files changed, 17 insertions, 2 deletions
diff --git a/adb/adb.c b/adb/adb.c
index 7df3f7bc..a34dd719 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -895,9 +895,10 @@ int adb_main(int is_daemon)
** AID_GRAPHICS to access the frame buffer
** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump)
** AID_SDCARD_RW to allow writing to the SD card
+ ** AID_MOUNT to allow unmounting the SD card before rebooting
*/
gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
- AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW };
+ AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT };
setgroups(sizeof(groups)/sizeof(groups[0]), groups);
/* then switch user and group to "shell" */
diff --git a/adb/services.c b/adb/services.c
index b5df5542..487c7d37 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -176,9 +176,23 @@ void restart_usb_service(int fd, void *cookie)
void reboot_service(int fd, void *arg)
{
char buf[100];
- int ret;
+ int pid, ret;
sync();
+
+ /* Attempt to unmount the SD card first.
+ * No need to bother checking for errors.
+ */
+ pid = fork();
+ if (pid == 0) {
+ /* ask vdc to unmount it */
+ execl("/system/bin/vdc", "/system/bin/vdc", "volume", "unmount",
+ getenv("EXTERNAL_STORAGE"), "force", NULL);
+ } else if (pid > 0) {
+ /* wait until vdc succeeds or fails */
+ waitpid(pid, &ret, 0);
+ }
+
ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_RESTART2, (char *)arg);
if (ret < 0) {