--- nut-2.0.5/drivers/upsdrvctl.c.alt-upsdrvctl-list 2007-07-27 13:20:47 +0400 +++ nut-2.0.5/drivers/upsdrvctl.c 2007-07-27 13:29:30 +0400 @@ -276,16 +276,33 @@ static void start_driver(const ups_t *up forkexec(dfn, argv, ups); } +static void list_driver(const ups_t *ups) +{ + char dfn[SMALLBUF]; + int ret; + struct stat fs; + + snprintf(dfn, sizeof(dfn), "%s/%s", driverpath, ups->driver); + ret = stat(dfn, &fs); + + if (ret < 0) + upslogx(LOG_ERR, "stat: %s: %m", dfn); + else + puts(dfn); +} + static void help(const char *progname) { printf("Starts and stops UPS drivers via ups.conf.\n\n"); - printf("usage: %s [OPTIONS] (start | stop | shutdown) []\n\n", progname); + printf("usage: %s [OPTIONS] (list | start | stop | shutdown) []\n\n", progname); printf(" -h display this help\n"); printf(" -r drivers will chroot to \n"); printf(" -t testing mode - prints actions without doing them\n"); printf(" -u drivers started will switch from root to \n"); printf(" -D raise debugging level\n"); + printf(" list list all UPS drivers in ups.conf\n"); + printf(" list only list driver for UPS \n"); printf(" start start all UPS drivers in ups.conf\n"); printf(" start only start driver for UPS \n"); printf(" stop stop all UPS drivers in ups.conf\n"); @@ -448,6 +465,9 @@ int main(int argc, char **argv) nut_debug_level = 2; } + if (!strcmp(argv[0], "list")) + command = &list_driver; + if (!strcmp(argv[0], "start")) command = &start_driver;