[git commit] traceroute: fix help text
Denys Vlasenko
vda.linux at googlemail.com
Mon Aug 24 16:56:46 UTC 2015
commit: http://git.busybox.net/busybox/commit/?id=2eabe3fc7631d490ab04fc5338ed60d920fd1bea
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/inotifyd.c | 24 +++++++++++++----
networking/traceroute.c | 66 ++++++++++++++++++++++++----------------------
2 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 7a1a6a2..97f67ab 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -28,7 +28,7 @@
*/
//usage:#define inotifyd_trivial_usage
-//usage: "PROG FILE1[:MASK]..."
+//usage: "[OPTS] PROG FILE1[:MASK]..."
//usage:#define inotifyd_full_usage "\n\n"
//usage: "Run PROG on filesystem changes."
//usage: "\nWhen a filesystem event matching MASK occurs on FILEn,"
@@ -52,12 +52,17 @@
//usage: "\n n Subfile is created"
//usage: "\n d Subfile is deleted"
//usage: "\n"
+//usage: "\nOptions:"
+//usage: "\n -x STATUS Exit if PROG returns STATUS"
+//usage: "\n"
//usage: "\ninotifyd waits for PROG to exit."
//usage: "\nWhen x event happens for all FILEs, inotifyd exits."
#include "libbb.h"
#include <sys/inotify.h>
+#define OPT_x (1 << 0)
+
static const char mask_names[] ALIGN1 =
"a" // 0x00000001 File was accessed
"c" // 0x00000002 File was modified
@@ -84,17 +89,22 @@ enum {
int inotifyd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int inotifyd_main(int argc, char **argv)
{
- int n;
- unsigned mask;
+ int n, exp_st, st;
+ unsigned mask, opts;
struct pollfd pfd;
char **watches; // names of files being watched
const char *args[5];
+ char *opt_x_str;
+
+ opts = getopt32(argv, "x:", &opt_x_str);
+ argc -= optind;
+ argv += optind;
+ exp_st = xstrtol_range(opt_x_str, 10, 0, 255);
// sanity check: agent and at least one watch must be given
- if (!argv[1] || !argv[2])
+ if (!argv[0] || !argv[1])
bb_show_usage();
- argv++;
// inotify_add_watch will number watched files
// starting from 1, thus watches[0] is unimportant,
// and 1st file name is watches[1].
@@ -190,7 +200,9 @@ int inotifyd_main(int argc, char **argv)
args[1] = events;
args[2] = watches[ie->wd];
args[3] = ie->len ? ie->name : NULL;
- spawn_and_wait((char **)args);
+ st = spawn_and_wait((char **)args);
+ if ((opts & OPT_x) && st == exp_st)
+ goto done;
}
// we are done if all files got final x event
if (ie->mask & 0x8000) {
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 12ba614..8557136 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -211,60 +211,62 @@
*/
//usage:#define traceroute_trivial_usage
-//usage: "[-"IF_TRACEROUTE6("46")"FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]\n"
-//usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]\n"
+//usage: "[-"IF_TRACEROUTE6("46")"FIlnrv] [-f 1ST_TTL] [-m MAXTTL] [-q PROBES] [-p PORT]\n"
+//usage: " [-t TOS] [-w WAIT_SEC]"
+//usage: IF_FEATURE_TRACEROUTE_SOURCE_ROUTE(" [-g GATEWAY]")" [-s SRC_IP] [-i IFACE]\n"
//usage: " [-z PAUSE_MSEC] HOST [BYTES]"
//usage:#define traceroute_full_usage "\n\n"
//usage: "Trace the route to HOST\n"
//usage: IF_TRACEROUTE6(
//usage: "\n -4,-6 Force IP or IPv6 name resolution"
//usage: )
-//usage: "\n -F Set the don't fragment bit"
+//usage: "\n -F Set don't fragment bit"
+//usage: IF_FEATURE_TRACEROUTE_USE_ICMP(
//usage: "\n -I Use ICMP ECHO instead of UDP datagrams"
-//usage: "\n -l Display the TTL value of the returned packet"
-//usage: "\n -d Set SO_DEBUG options to socket"
+//usage: )
+//usage: "\n -l Display TTL value of the returned packet"
+//Currently disabled (TRACEROUTE_SO_DEBUG==0)
+////usage: "\n -d Set SO_DEBUG options to socket"
//usage: "\n -n Print numeric addresses"
//usage: "\n -r Bypass routing tables, send directly to HOST"
+//usage: IF_FEATURE_TRACEROUTE_VERBOSE(
//usage: "\n -v Verbose"
-//usage: "\n -m Max time-to-live (max number of hops)"
-//usage: "\n -p Base UDP port number used in probes"
+//usage: )
+//usage: "\n -f N First number of hops (default 1)"
+//usage: "\n -m N Max number of hops"
+//usage: "\n -q N Number of probes per hop (default 3)"
+//usage: "\n -p N Base UDP port number used in probes"
//usage: "\n (default 33434)"
-//usage: "\n -q Number of probes per TTL (default 3)"
-//usage: "\n -s IP address to use as the source address"
-//usage: "\n -t Type-of-service in probe packets (default 0)"
-//usage: "\n -w Time in seconds to wait for a response (default 3)"
-//usage: "\n -g Loose source route gateway (8 max)"
+//usage: "\n -s IP Source address"
+//usage: "\n -i IFACE Source interface"
+//usage: "\n -t N Type-of-service in probe packets (default 0)"
+//usage: "\n -w SEC Time to wait for a response (default 3)"
+//usage: "\n -g IP Loose source route gateway (8 max)"
//usage:
//usage:#define traceroute6_trivial_usage
-//usage: "[-dnrv] [-m MAXTTL] [-p PORT] [-q PROBES]\n"
-//usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-i IFACE]\n"
+//usage: "[-nrv] [-m MAXTTL] [-q PROBES] [-p PORT]\n"
+//usage: " [-t TOS] [-w WAIT_SEC] [-s SRC_IP] [-i IFACE]\n"
//usage: " HOST [BYTES]"
//usage:#define traceroute6_full_usage "\n\n"
//usage: "Trace the route to HOST\n"
-//usage: "\n -d Set SO_DEBUG options to socket"
+//Currently disabled (TRACEROUTE_SO_DEBUG==0)
+////usage: "\n -d Set SO_DEBUG options to socket"
//usage: "\n -n Print numeric addresses"
//usage: "\n -r Bypass routing tables, send directly to HOST"
+//usage: IF_FEATURE_TRACEROUTE_VERBOSE(
//usage: "\n -v Verbose"
-//usage: "\n -m Max time-to-live (max number of hops)"
-//usage: "\n -p Base UDP port number used in probes"
-//usage: "\n (default is 33434)"
-//usage: "\n -q Number of probes per TTL (default 3)"
-//usage: "\n -s IP address to use as the source address"
-//usage: "\n -t Type-of-service in probe packets (default 0)"
-//usage: "\n -w Time in seconds to wait for a response (default 3)"
+//usage: )
+//usage: "\n -m N Max number of hops"
+//usage: "\n -q N Number of probes per hop (default 3)"
+//usage: "\n -p N Base UDP port number used in probes"
+//usage: "\n (default 33434)"
+//usage: "\n -s IP Source address"
+//usage: "\n -i IFACE Source interface"
+//usage: "\n -t N Type-of-service in probe packets (default 0)"
+//usage: "\n -w SEC Time wait for a response (default 3)"
#define TRACEROUTE_SO_DEBUG 0
-/* TODO: undefs were uncommented - ??! we have config system for that! */
-/* probably ok to remove altogether */
-//#undef CONFIG_FEATURE_TRACEROUTE_VERBOSE
-//#define CONFIG_FEATURE_TRACEROUTE_VERBOSE
-//#undef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
-//#define CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
-//#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
-//#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP
-
-
#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
More information about the busybox-cvs
mailing list