From: Tobias Klauser <tklauser@nuerscht.ch>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] Print usage of udevcontrol when no or invalid command is given
Date: Sun, 02 Jul 2006 16:59:43 +0000 [thread overview]
Message-ID: <20060702165943.GA4178@neon.tklauser.home> (raw)
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 <sys/un.h>
#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=<level> 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=<N> 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=<level> 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=<N> 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&kid\x120709&bid&3057&dat\x121642
_______________________________________________
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
next reply other threads:[~2006-07-02 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-02 16:59 Tobias Klauser [this message]
2006-07-02 23:06 ` [PATCH] Print usage of udevcontrol when no or invalid command Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060702165943.GA4178@neon.tklauser.home \
--to=tklauser@nuerscht.ch \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox