diff -U 3 -r nut-2.6.0.orig/drivers/upsdrvctl.c nut-2.6.0/drivers/upsdrvctl.c --- nut-2.6.0.orig/drivers/upsdrvctl.c 2011-02-08 12:35:02 +0200 +++ nut-2.6.0/drivers/upsdrvctl.c 2011-02-08 12:40:38 +0200 @@ -283,16 +283,33 @@ } } +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"); @@ -470,6 +487,10 @@ "starts and you need to copy and paste that line and append the debug flags to that\n" "line (less the 'exec:' prefix).\n"); + + if (!strcmp(argv[0], "list")) + command = &list_driver; + if (!strcmp(argv[0], "start")) command = &start_driver;