From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tobias Klauser Date: Sun, 02 Jul 2006 16:59:43 +0000 Subject: [PATCH] Print usage of udevcontrol when no or invalid command is given Message-Id: <20060702165943.GA4178@neon.tklauser.home> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org When not giving any command to udevcontrol it just prints "missing command". This patch changes udevcontrol to also print the usage in such cases (and additionaly in cases where invalid commands are given). The patch also cleans up the exit paths. --- udevcontrol.c | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-) diff --git a/udevcontrol.c b/udevcontrol.c index 8add09e..60d21d2 100644 --- a/udevcontrol.c +++ b/udevcontrol.c @@ -33,6 +33,9 @@ #include #include "udev.h" #include "udevd.h" +/* prototypes */ +void usage(void); + /* global variables */ static int sock = -1; static int udev_log = 0; @@ -51,6 +54,16 @@ void log_message (int priority, const ch } #endif +void usage(void) +{ + printf("Usage: udevcontrol COMMAND\n" + " log_priority= set the udev log level for the daemon\n" + " stop_exec_queue keep udevd from executing events, queue only\n" + " start_exec_queue execute events, flush queue\n" + " reload_rules reloads the rules files\n" + " max_childs= maximum number of childs running at the same time\n" + " --help print this help text\n\n"); +} int main(int argc, char *argv[], char *envp[]) { @@ -72,6 +85,7 @@ int main(int argc, char *argv[], char *e if (argc < 2) { fprintf(stderr, "missing command\n\n"); + usage(); goto exit; } @@ -100,23 +114,18 @@ int main(int argc, char *argv[], char *e *intval = atoi(val); info("send max_childs=%i", *intval); } else if (strcmp(arg, "help") = 0 || strcmp(arg, "--help") = 0 || strcmp(arg, "-h") = 0) { - printf("Usage: udevcontrol COMMAND\n" - " log_priority= set the udev log level for the daemon\n" - " stop_exec_queue keep udevd from executing events, queue only\n" - " start_exec_queue execute events, flush queue\n" - " reload_rules reloads the rules files\n" - " max_childs= maximum number of childs running at the same time\n" - " --help print this help text\n\n"); - exit(0); + usage(); + goto exit; } else { fprintf(stderr, "unknown option\n\n"); - exit(1); + usage(); + goto exit; } } if (getuid() != 0) { fprintf(stderr, "need to be root, exit\n\n"); - exit(1); + goto exit; } sock = socket(AF_LOCAL, SOCK_DGRAM, 0); -- 1.4.0 Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel