devmand: skip unconfigured script invocations
. if a up/down script isn't specified, devmand would try to execute a command line with (null) in it, causing messy messages on startup . skip script at a higher level when missing, and add asserts for expected strings at the lower level Change-Id: Ia0d772076f3781caa5879ea4e64b53fa6c6e8478
This commit is contained in:
parent
a4d4ce4adb
commit
683d394d66
|
@ -89,6 +89,9 @@ int run_upscript(struct devmand_driver_instance *inst)
|
||||||
cmdl[0] = 0;
|
cmdl[0] = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
assert(inst->drv->upscript);
|
||||||
|
assert(inst->label);
|
||||||
|
|
||||||
snprintf(cmdl, 1024, "%s up %s %d %d",
|
snprintf(cmdl, 1024, "%s up %s %d %d",
|
||||||
inst->drv->upscript, inst->label, inst->major, inst->dev_id);
|
inst->drv->upscript, inst->label, inst->major, inst->dev_id);
|
||||||
dbg("Running Upscript: \"%s\"", cmdl);
|
dbg("Running Upscript: \"%s\"", cmdl);
|
||||||
|
@ -108,6 +111,9 @@ int run_cleanscript(struct devmand_usb_driver *drv)
|
||||||
cmdl[0] = 0;
|
cmdl[0] = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
assert(drv->upscript);
|
||||||
|
assert(drv->devprefix);
|
||||||
|
|
||||||
snprintf(cmdl, 1024, "%s clean %s ",
|
snprintf(cmdl, 1024, "%s clean %s ",
|
||||||
drv->upscript, drv->devprefix);
|
drv->upscript, drv->devprefix);
|
||||||
dbg("Running Upscript: \"%s\"", cmdl);
|
dbg("Running Upscript: \"%s\"", cmdl);
|
||||||
|
@ -130,6 +136,9 @@ int run_downscript(struct devmand_driver_instance *inst)
|
||||||
cmdl[0] = 0;
|
cmdl[0] = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
assert(inst->drv->downscript);
|
||||||
|
assert(inst->label);
|
||||||
|
|
||||||
snprintf(cmdl, 1024, "%s down %s %d",
|
snprintf(cmdl, 1024, "%s down %s %d",
|
||||||
inst->drv->downscript, inst->label, inst->major);
|
inst->drv->downscript, inst->label, inst->major);
|
||||||
|
|
||||||
|
@ -154,6 +163,8 @@ int stop_driver(struct devmand_driver_instance *inst)
|
||||||
cmdl[0] = 0;
|
cmdl[0] = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
assert(inst->label);
|
||||||
|
|
||||||
snprintf(cmdl, 1024, "%s down %s %d",
|
snprintf(cmdl, 1024, "%s down %s %d",
|
||||||
SERVICE_BINARY, inst->label, inst->dev_id);
|
SERVICE_BINARY, inst->label, inst->dev_id);
|
||||||
dbg("executing service: \"%s\"", cmdl);
|
dbg("executing service: \"%s\"", cmdl);
|
||||||
|
@ -186,6 +197,9 @@ int start_driver(struct devmand_driver_instance *inst)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(inst->drv->binary);
|
||||||
|
assert(inst->label);
|
||||||
|
|
||||||
snprintf(cmdl, 1024, "%s up %s -major %d -devid %d -label %s",
|
snprintf(cmdl, 1024, "%s up %s -major %d -devid %d -label %s",
|
||||||
SERVICE_BINARY, inst->drv->binary, inst->major, inst->dev_id,
|
SERVICE_BINARY, inst->drv->binary, inst->major, inst->dev_id,
|
||||||
inst->label);
|
inst->label);
|
||||||
|
@ -389,7 +403,9 @@ static void cleanup() {
|
||||||
/* quit all running drivers */
|
/* quit all running drivers */
|
||||||
LIST_FOREACH(inst, &instances, list) {
|
LIST_FOREACH(inst, &instances, list) {
|
||||||
dbg("stopping driver %s", inst->label);
|
dbg("stopping driver %s", inst->label);
|
||||||
run_downscript (inst);
|
if(inst->drv->downscript) {
|
||||||
|
run_downscript (inst);
|
||||||
|
}
|
||||||
stop_driver(inst);
|
stop_driver(inst);
|
||||||
}
|
}
|
||||||
unlink("/var/run/devmand.pid");
|
unlink("/var/run/devmand.pid");
|
||||||
|
@ -485,7 +501,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
parse_config();
|
parse_config();
|
||||||
LIST_FOREACH(driver, &drivers, list) {
|
LIST_FOREACH(driver, &drivers, list) {
|
||||||
run_cleanscript(driver);
|
if (driver->upscript) {
|
||||||
|
run_cleanscript(driver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_int);
|
signal(SIGINT, sig_int);
|
||||||
|
|
Loading…
Reference in a new issue