diff options
Diffstat (limited to 'vold/cmd_dispatch.c')
-rw-r--r-- | vold/cmd_dispatch.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vold/cmd_dispatch.c b/vold/cmd_dispatch.c index 1f48cfc..ab65fd9 100644 --- a/vold/cmd_dispatch.c +++ b/vold/cmd_dispatch.c @@ -33,13 +33,15 @@ static int do_send_ums_status(char *cmd); static int do_set_ums_enable(char *cmd); static int do_mount_volume(char *cmd); static int do_eject_media(char *cmd); +static int do_format_media(char *cmd); static struct cmd_dispatch dispatch_table[] = { { VOLD_CMD_ENABLE_UMS, do_set_ums_enable }, { VOLD_CMD_DISABLE_UMS, do_set_ums_enable }, { VOLD_CMD_SEND_UMS_STATUS, do_send_ums_status }, - { VOLD_CMD_MOUNT_VOLUME, do_mount_volume }, + { VOLD_CMD_MOUNT_VOLUME, do_mount_volume }, { VOLD_CMD_EJECT_MEDIA, do_eject_media }, + { VOLD_CMD_FORMAT_MEDIA, do_format_media }, { NULL, NULL } }; @@ -49,9 +51,10 @@ int process_framework_command(int socket) char buffer[101]; if ((rc = read(socket, buffer, sizeof(buffer) -1)) < 0) { - LOGE("Unable to read framework command (%s)\n", strerror(errno)); + LOGE("Unable to read framework command (%s)", strerror(errno)); return -errno; - } + } else if (!rc) + return -ECONNRESET; int start = 0; int i; @@ -71,7 +74,7 @@ static void dispatch_cmd(char *cmd) { struct cmd_dispatch *c; - LOG_VOL("dispatch_cmd(%s):\n", cmd); + LOG_VOL("dispatch_cmd(%s):", cmd); for (c = dispatch_table; c->cmd != NULL; c++) { if (!strncmp(c->cmd, cmd, strlen(c->cmd))) { @@ -80,7 +83,7 @@ static void dispatch_cmd(char *cmd) } } - LOGE("No cmd handlers defined for '%s'\n", cmd); + LOGE("No cmd handlers defined for '%s'", cmd); } static int do_send_ums_status(char *cmd) @@ -101,6 +104,11 @@ static int do_mount_volume(char *cmd) return volmgr_start_volume_by_mountpoint(&cmd[strlen("mount_volume:")]); } +static int do_format_media(char *cmd) +{ + return volmgr_format_volume(&cmd[strlen("format_media:")]); +} + static int do_eject_media(char *cmd) { return volmgr_stop_volume_by_mountpoint(&cmd[strlen("eject_media:")]); |