summaryrefslogtreecommitdiffstats
path: root/utils/pb-event.c
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2011-10-29 21:49:51 -0700
committerGeoff Levand <geoff@infradead.org>2011-10-29 22:00:27 -0700
commita88618fc1d5828287ce71bb643f8117e51754c88 (patch)
tree3ff4280055944a52979ebe3416431b6182a2f617 /utils/pb-event.c
parent38646182c4edae5df911f78aa75324550dac0596 (diff)
downloadtalos-petitboot-a88618fc1d5828287ce71bb643f8117e51754c88.tar.gz
talos-petitboot-a88618fc1d5828287ce71bb643f8117e51754c88.zip
pb-event: Add help message
Diffstat (limited to 'utils/pb-event.c')
-rw-r--r--utils/pb-event.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/utils/pb-event.c b/utils/pb-event.c
index 5ef8115..a119e21 100644
--- a/utils/pb-event.c
+++ b/utils/pb-event.c
@@ -40,7 +40,31 @@ static inline int __attribute__ ((format (printf, 1, 2))) DBG(
__attribute__((unused)) const char *fmt, ...) {return 0; }
#endif
-int main(void)
+static void print_version(void)
+{
+ printf("pb-event (" PACKAGE_NAME ") " PACKAGE_VERSION "\n");
+}
+
+static void print_usage(void)
+{
+ print_version();
+ printf(
+"Usage: pb-event [-h, --help] [-V, --version]\n"
+"\n"
+" Reads a single petitboot user event on stdin and forwards it to the\n"
+" petitboot discover server pb-discover. User events must have the\n"
+" following format:\n"
+"\n"
+" (add|remove)@device-id\\0[name=value\\0][image=value\\0][args=value\\0]\n"
+"\n"
+"Examples:\n"
+"\n"
+" echo -ne 'add@/net/eth0\\0name=netboot\\0image=tftp://192.168.1.10/vmlinux\\0args=root=/dev/nfs nfsroot=192.168.1.10:/target\\0' | pb-event\n"
+" echo -ne 'remove@/net/eth0\\0' | pb-event\n"
+"\n");
+}
+
+int main(int argc, __attribute__((unused)) char *argv[])
{
int result;
struct sockaddr_un addr;
@@ -48,7 +72,12 @@ int main(void)
ssize_t len;
int s;
int i;
-
+
+ if (argc > 1) {
+ print_usage();
+ return EXIT_FAILURE;
+ }
+
s = socket(PF_UNIX, SOCK_DGRAM, 0);
if (s < 0) {
@@ -62,7 +91,7 @@ int main(void)
if (!feof(stdin)) {
fprintf(stderr, "pb-event: msg too big (%u byte max)\n",
- sizeof(buf));
+ (unsigned int)sizeof(buf));
result = EXIT_FAILURE;
/* continue on and try to write msg */
}
@@ -90,6 +119,6 @@ int main(void)
return EXIT_FAILURE;
}
- DBG("pb-event: wrote %u bytes\n", len);
+ DBG("pb-event: wrote %u bytes\n", (unsigned int)len);
return result;
}
OpenPOWER on IntegriCloud