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
1 changed files with 20 additions and 2 deletions
|
@ -89,6 +89,9 @@ int run_upscript(struct devmand_driver_instance *inst)
|
|||
cmdl[0] = 0;
|
||||
int ret;
|
||||
|
||||
assert(inst->drv->upscript);
|
||||
assert(inst->label);
|
||||
|
||||
snprintf(cmdl, 1024, "%s up %s %d %d",
|
||||
inst->drv->upscript, inst->label, inst->major, inst->dev_id);
|
||||
dbg("Running Upscript: \"%s\"", cmdl);
|
||||
|
@ -108,6 +111,9 @@ int run_cleanscript(struct devmand_usb_driver *drv)
|
|||
cmdl[0] = 0;
|
||||
int ret;
|
||||
|
||||
assert(drv->upscript);
|
||||
assert(drv->devprefix);
|
||||
|
||||
snprintf(cmdl, 1024, "%s clean %s ",
|
||||
drv->upscript, drv->devprefix);
|
||||
dbg("Running Upscript: \"%s\"", cmdl);
|
||||
|
@ -130,6 +136,9 @@ int run_downscript(struct devmand_driver_instance *inst)
|
|||
cmdl[0] = 0;
|
||||
int ret;
|
||||
|
||||
assert(inst->drv->downscript);
|
||||
assert(inst->label);
|
||||
|
||||
snprintf(cmdl, 1024, "%s down %s %d",
|
||||
inst->drv->downscript, inst->label, inst->major);
|
||||
|
||||
|
@ -154,6 +163,8 @@ int stop_driver(struct devmand_driver_instance *inst)
|
|||
cmdl[0] = 0;
|
||||
int ret;
|
||||
|
||||
assert(inst->label);
|
||||
|
||||
snprintf(cmdl, 1024, "%s down %s %d",
|
||||
SERVICE_BINARY, inst->label, inst->dev_id);
|
||||
dbg("executing service: \"%s\"", cmdl);
|
||||
|
@ -186,6 +197,9 @@ int start_driver(struct devmand_driver_instance *inst)
|
|||
return ENOMEM;
|
||||
}
|
||||
|
||||
assert(inst->drv->binary);
|
||||
assert(inst->label);
|
||||
|
||||
snprintf(cmdl, 1024, "%s up %s -major %d -devid %d -label %s",
|
||||
SERVICE_BINARY, inst->drv->binary, inst->major, inst->dev_id,
|
||||
inst->label);
|
||||
|
@ -389,7 +403,9 @@ static void cleanup() {
|
|||
/* quit all running drivers */
|
||||
LIST_FOREACH(inst, &instances, list) {
|
||||
dbg("stopping driver %s", inst->label);
|
||||
if(inst->drv->downscript) {
|
||||
run_downscript (inst);
|
||||
}
|
||||
stop_driver(inst);
|
||||
}
|
||||
unlink("/var/run/devmand.pid");
|
||||
|
@ -485,8 +501,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
parse_config();
|
||||
LIST_FOREACH(driver, &drivers, list) {
|
||||
if (driver->upscript) {
|
||||
run_cleanscript(driver);
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_int);
|
||||
|
||||
|
|
Loading…
Reference in a new issue