summaryrefslogtreecommitdiffstats
path: root/vold
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-07-16 10:44:15 -0700
committerSan Mehat <san@google.com>2009-07-16 11:41:33 -0700
commit1f27821568065715d3235c0e690c42d0d7a413bc (patch)
treee7137504d6072dcc2375d166c8d7bd464947c905 /vold
parentd8221d9869f9fe1031219e8f6cbcef0771d767fa (diff)
downloadcore-1f27821568065715d3235c0e690c42d0d7a413bc.tar.gz
core-1f27821568065715d3235c0e690c42d0d7a413bc.tar.bz2
core-1f27821568065715d3235c0e690c42d0d7a413bc.zip
vold: If we're bootstrapping, don't automatically mount the SD card. Also fixes some
error display bugs (our printf doesnt support %m) Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'vold')
-rw-r--r--vold/blkdev.c2
-rw-r--r--vold/mmc.c21
-rw-r--r--vold/switch.c9
-rw-r--r--vold/uevent.c12
-rw-r--r--vold/vold.c4
-rw-r--r--vold/vold.h1
-rw-r--r--vold/volmgr.c9
7 files changed, 40 insertions, 18 deletions
diff --git a/vold/blkdev.c b/vold/blkdev.c
index 316750760..1482a1ac0 100644
--- a/vold/blkdev.c
+++ b/vold/blkdev.c
@@ -73,7 +73,7 @@ int blkdev_refresh(blkdev_t *blk)
}
if (ioctl(fd, BLKGETSIZE, &blk->nr_sec)) {
- LOGE("Unable to get device size (%m)");
+ LOGE("Unable to get device size (%s)", strerror(errno));
return -errno;
}
close(fd);
diff --git a/vold/mmc.c b/vold/mmc.c
index 0f08964b3..cbddb9223 100644
--- a/vold/mmc.c
+++ b/vold/mmc.c
@@ -43,7 +43,8 @@ int mmc_bootstrap()
struct dirent *de;
if (!(d = opendir(SYSFS_CLASS_MMC_PATH))) {
- LOG_ERROR("Unable to open '%s' (%m)", SYSFS_CLASS_MMC_PATH);
+ LOG_ERROR("Unable to open '%s' (%s)", SYSFS_CLASS_MMC_PATH,
+ strerror(errno));
return -errno;
}
@@ -54,8 +55,10 @@ int mmc_bootstrap()
continue;
sprintf(tmp, "%s/%s", SYSFS_CLASS_MMC_PATH, de->d_name);
- if (mmc_bootstrap_controller(tmp))
- LOG_ERROR("Error bootstrapping controller '%s' (%m)", tmp);
+ if (mmc_bootstrap_controller(tmp)) {
+ LOG_ERROR("Error bootstrapping controller '%s' (%s)", tmp,
+ strerror(errno));
+ }
}
closedir(d);
@@ -72,7 +75,7 @@ static int mmc_bootstrap_controller(char *sysfs_path)
LOG_VOL("bootstrap_controller(%s):", sysfs_path);
#endif
if (!(d = opendir(sysfs_path))) {
- LOG_ERROR("Unable to open '%s' (%m)", sysfs_path);
+ LOG_ERROR("Unable to open '%s' (%s)", sysfs_path, strerror(errno));
return -errno;
}
@@ -92,7 +95,7 @@ static int mmc_bootstrap_controller(char *sysfs_path)
sprintf(tmp, "%s/%s", sysfs_path, de->d_name);
if (mmc_bootstrap_card(tmp) < 0)
- LOG_ERROR("Error bootstrapping card '%s' (%m)", tmp);
+ LOG_ERROR("Error bootstrapping card '%s' (%s)", tmp, strerror(errno));
} // while
closedir(d);
@@ -123,7 +126,7 @@ static int mmc_bootstrap_card(char *sysfs_path)
}
if (chdir(sysfs_path) < 0) {
- LOGE("Unable to chdir to %s (%m)", sysfs_path);
+ LOGE("Unable to chdir to %s (%s)", sysfs_path, strerror(errno));
return -errno;
}
@@ -162,7 +165,7 @@ static int mmc_bootstrap_card(char *sysfs_path)
uevent_params[3] = (char *) NULL;
if (simulate_uevent("mmc", devpath, "add", uevent_params) < 0) {
- LOGE("Error simulating uevent (%m)");
+ LOGE("Error simulating uevent (%s)", strerror(errno));
return -errno;
}
@@ -264,7 +267,7 @@ static int mmc_bootstrap_mmcblk_partition(char *devpath)
sprintf(filename, "/sys%s/uevent", devpath);
if (!(fp = fopen(filename, "r"))) {
- LOGE("Unable to open '%s' (%m)", filename);
+ LOGE("Unable to open '%s' (%s)", filename, strerror(errno));
return -errno;
}
@@ -286,7 +289,7 @@ static int mmc_bootstrap_mmcblk_partition(char *devpath)
uevent_params[4] = '\0';
if (simulate_uevent("block", devpath, "add", uevent_params) < 0) {
- LOGE("Error simulating uevent (%m)");
+ LOGE("Error simulating uevent (%s)", strerror(errno));
return -errno;
}
return 0;
diff --git a/vold/switch.c b/vold/switch.c
index ba9ddb390..d8dab4327 100644
--- a/vold/switch.c
+++ b/vold/switch.c
@@ -35,7 +35,8 @@ int switch_bootstrap()
struct dirent *de;
if (!(d = opendir(SYSFS_CLASS_SWITCH_PATH))) {
- LOG_ERROR("Unable to open '%s' (%m)", SYSFS_CLASS_SWITCH_PATH);
+ LOG_ERROR("Unable to open '%s' (%s)", SYSFS_CLASS_SWITCH_PATH,
+ strerror(errno));
return -errno;
}
@@ -46,8 +47,10 @@ int switch_bootstrap()
continue;
sprintf(tmp, "%s/%s", SYSFS_CLASS_SWITCH_PATH, de->d_name);
- if (mmc_bootstrap_switch(tmp))
- LOG_ERROR("Error bootstrapping switch '%s' (%m)", tmp);
+ if (mmc_bootstrap_switch(tmp)) {
+ LOG_ERROR("Error bootstrapping switch '%s' (%s)", tmp,
+ strerror(errno));
+ }
}
closedir(d);
diff --git a/vold/uevent.c b/vold/uevent.c
index 66e70c59a..dffe81707 100644
--- a/vold/uevent.c
+++ b/vold/uevent.c
@@ -333,7 +333,7 @@ static int handle_block_event(struct uevent *event)
min,
media,
get_uevent_param(event, "DEVTYPE")))) {
- LOGE("Unable to allocate new blkdev (%m)");
+ LOGE("Unable to allocate new blkdev (%s)", strerror(errno));
return -1;
}
@@ -354,8 +354,12 @@ static int handle_block_event(struct uevent *event)
if (blkdev_get_num_pending_partitions(blkdev->disk) == 0) {
if ((rc = volmgr_consider_disk(blkdev->disk)) < 0) {
- LOGE("Volmgr failed to handle device (%d)", rc);
- return rc;
+ if (rc == -EBUSY) {
+ LOGI("Volmgr not ready to handle device");
+ } else {
+ LOGE("Volmgr failed to handle device (%d)", rc);
+ return rc;
+ }
}
}
} else if (event->action == action_remove) {
@@ -414,7 +418,7 @@ static int handle_mmc_event(struct uevent *event)
get_uevent_param(event, "MMC_NAME"),
serial,
media_mmc))) {
- LOGE("Unable to allocate new media (%m)");
+ LOGE("Unable to allocate new media (%s)", strerror(errno));
return -1;
}
LOGI("New MMC card '%s' (serial %u) added @ %s", media->name,
diff --git a/vold/vold.c b/vold/vold.c
index 7d50a2fe6..11b99a9bf 100644
--- a/vold/vold.c
+++ b/vold/vold.c
@@ -53,6 +53,8 @@ static int ver_minor = 0;
static pthread_mutex_t write_mutex = PTHREAD_MUTEX_INITIALIZER;
static int fw_sock = -1;
+int bootstrap = 0;
+
int main(int argc, char **argv)
{
int door_sock = -1;
@@ -108,6 +110,7 @@ int main(int argc, char **argv)
* Bootstrap
*/
+ bootstrap = 1;
// Volume Manager
volmgr_bootstrap();
@@ -120,6 +123,7 @@ int main(int argc, char **argv)
// Switch
switch_bootstrap();
+ bootstrap = 0;
/*
* Main loop
*/
diff --git a/vold/vold.h b/vold/vold.h
index 4ff690a3b..abc27a185 100644
--- a/vold/vold.h
+++ b/vold/vold.h
@@ -97,4 +97,5 @@ boolean ums_hostconnected_get(void);
int send_msg(char *msg);
int send_msg_with_data(char *msg, char *data);
+extern int bootstrap;
#endif
diff --git a/vold/volmgr.c b/vold/volmgr.c
index b7c5ddc9e..3c34a9c52 100644
--- a/vold/volmgr.c
+++ b/vold/volmgr.c
@@ -583,7 +583,7 @@ static int _volmgr_consider_disk_and_vol(volume_t *vol, blkdev_t *dev)
LOG_VOL("_volmgr_start(%s, %d:%d) rc = %d",
vol->mount_point, part->major, part->minor, rc);
#endif
- if (!rc)
+ if (!rc || rc == -EBUSY)
break;
}
@@ -1065,6 +1065,13 @@ static int volmgr_start_fs(struct volmgr_fstable_entry *fs, volume_t *vol, blkde
vol->dev = dev;
+ if (bootstrap) {
+ LOGI("Aborting start of %s (bootstrap = %d)\n", vol->mount_point,
+ bootstrap);
+ vol->state = volstate_unmounted;
+ return -EBUSY;
+ }
+
vol->worker_args.start_args.fs = fs;
vol->worker_args.start_args.dev = dev;