aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-14 21:23:06 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-14 21:23:06 +0000
commit67991cf824f8df27e74c92d754fb507681c69ce6 (patch)
treea0b652f3dc794d1050c1a8de3afb014a621238fa /util-linux
parent68be2ab914e1e20fe666bbd22a89a18714be2789 (diff)
downloadbusybox-w32-67991cf824f8df27e74c92d754fb507681c69ce6.tar.gz
busybox-w32-67991cf824f8df27e74c92d754fb507681c69ce6.tar.bz2
busybox-w32-67991cf824f8df27e74c92d754fb507681c69ce6.zip
This patch, put together by Manuel Novoa III, is a merge of work
done by Evin Robertson (bug#1105) and work from Manuel to make usage messages occupy less space and simplify how usage messages are displayed.
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/dmesg.c11
-rw-r--r--util-linux/fdflush.c2
-rw-r--r--util-linux/freeramdisk.c2
-rw-r--r--util-linux/fsck_minix.c5
-rw-r--r--util-linux/getopt.c2
-rw-r--r--util-linux/mkfs_minix.c7
-rw-r--r--util-linux/mkswap.c10
-rw-r--r--util-linux/mount.c2
-rw-r--r--util-linux/pivot_root.c2
-rw-r--r--util-linux/rdate.c6
-rw-r--r--util-linux/swaponoff.c2
-rw-r--r--util-linux/umount.c4
12 files changed, 20 insertions, 35 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index c21f84c9a..47f9f4474 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -53,21 +53,21 @@ int dmesg_main(int argc, char **argv)
53 case 'n': 53 case 'n':
54 cmd = 8; 54 cmd = 8;
55 if (optarg == NULL) 55 if (optarg == NULL)
56 usage(dmesg_usage); 56 show_usage();
57 level = atoi(optarg); 57 level = atoi(optarg);
58 break; 58 break;
59 case 's': 59 case 's':
60 if (optarg == NULL) 60 if (optarg == NULL)
61 usage(dmesg_usage); 61 show_usage();
62 bufsize = atoi(optarg); 62 bufsize = atoi(optarg);
63 break; 63 break;
64 default: 64 default:
65 usage(dmesg_usage); 65 show_usage();
66 } 66 }
67 } 67 }
68 68
69 if (optind < argc) { 69 if (optind < argc) {
70 goto end; 70 show_usage();
71 } 71 }
72 72
73 if (cmd == 8) { 73 if (cmd == 8) {
@@ -97,7 +97,4 @@ int dmesg_main(int argc, char **argv)
97 if (lastc != '\n') 97 if (lastc != '\n')
98 putchar('\n'); 98 putchar('\n');
99 return EXIT_SUCCESS; 99 return EXIT_SUCCESS;
100 end:
101 usage(dmesg_usage);
102 return EXIT_FAILURE;
103} 100}
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index fcf8ddd28..f10cceae0 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -35,7 +35,7 @@ extern int fdflush_main(int argc, char **argv)
35 int fd; 35 int fd;
36 36
37 if (argc <= 1 || **(++argv) == '-') 37 if (argc <= 1 || **(++argv) == '-')
38 usage(fdflush_usage); 38 show_usage();
39 39
40 if ((fd = open(*argv, 0)) < 0) 40 if ((fd = open(*argv, 0)) < 0)
41 perror_msg_and_die("%s", *argv); 41 perror_msg_and_die("%s", *argv);
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index 8f90f40b5..cf25fae6a 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -40,7 +40,7 @@ freeramdisk_main(int argc, char **argv)
40 int f; 40 int f;
41 41
42 if (argc != 2 || *argv[1] == '-') { 42 if (argc != 2 || *argv[1] == '-') {
43 usage(freeramdisk_usage); 43 show_usage();
44 } 44 }
45 45
46 if ((f = open(argv[1], O_RDWR)) == -1) { 46 if ((f = open(argv[1], O_RDWR)) == -1) {
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 9d7622006..2b4c65144 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -283,11 +283,6 @@ static void leave(int status)
283 exit(status); 283 exit(status);
284} 284}
285 285
286static void show_usage(void)
287{
288 usage(fsck_minix_usage);
289}
290
291static void die(const char *str) 286static void die(const char *str)
292{ 287{
293 error_msg("%s", str); 288 error_msg("%s", str);
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 625263184..eb28d5d07 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -372,7 +372,7 @@ int getopt_main(int argc, char *argv[])
372 quote=0; 372 quote=0;
373 break; 373 break;
374 default: 374 default:
375 usage(getopt_usage); 375 show_usage();
376 } 376 }
377 377
378 if (!optstr) { 378 if (!optstr) {
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 9b40faac6..6b4a3e2d1 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -255,13 +255,6 @@ static inline int bit(char * a,unsigned int i)
255#define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1)) 255#define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1))
256#define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1)) 256#define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1))
257 257
258static void show_usage() __attribute__ ((noreturn));
259
260static void show_usage()
261{
262 usage(mkfs_minix_usage);
263}
264
265/* 258/*
266 * Check to make certain that our new filesystem won't be created on 259 * Check to make certain that our new filesystem won't be created on
267 * an already mounted partition. Code adapted from mke2fs, Copyright 260 * an already mounted partition. Code adapted from mke2fs, Copyright
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 7d690ad99..48637e889 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -287,7 +287,7 @@ int mkswap_main(int argc, char **argv)
287 287
288 PAGES = strtol(argv[0], &tmp, 0) / blocks_per_page; 288 PAGES = strtol(argv[0], &tmp, 0) / blocks_per_page;
289 if (*tmp) 289 if (*tmp)
290 usage(mkswap_usage); 290 show_usage();
291 } else 291 } else
292 device_name = argv[0]; 292 device_name = argv[0];
293 } else { 293 } else {
@@ -302,13 +302,13 @@ int mkswap_main(int argc, char **argv)
302 version = atoi(argv[0] + 2); 302 version = atoi(argv[0] + 2);
303 break; 303 break;
304 default: 304 default:
305 usage(mkswap_usage); 305 show_usage();
306 } 306 }
307 } 307 }
308 } 308 }
309 if (!device_name) { 309 if (!device_name) {
310 error_msg("error: Nowhere to set up swap on?"); 310 error_msg("error: Nowhere to set up swap on?");
311 usage(mkswap_usage); 311 show_usage();
312 } 312 }
313 sz = get_size(device_name); 313 sz = get_size(device_name);
314 if (!PAGES) { 314 if (!PAGES) {
@@ -331,12 +331,12 @@ int mkswap_main(int argc, char **argv)
331 } 331 }
332 if (version != 0 && version != 1) { 332 if (version != 0 && version != 1) {
333 error_msg("error: unknown version %d", version); 333 error_msg("error: unknown version %d", version);
334 usage(mkswap_usage); 334 show_usage();
335 } 335 }
336 if (PAGES < 10) { 336 if (PAGES < 10) {
337 error_msg("error: swap area needs to be at least %ldkB", 337 error_msg("error: swap area needs to be at least %ldkB",
338 (long) (10 * pagesize / 1024)); 338 (long) (10 * pagesize / 1024));
339 usage(mkswap_usage); 339 show_usage();
340 } 340 }
341#if 0 341#if 0
342 maxpages = ((version == 0) ? V0_MAX_PAGES : V1_MAX_PAGES); 342 maxpages = ((version == 0) ? V0_MAX_PAGES : V1_MAX_PAGES);
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 79813ba18..2f5bba59d 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -505,5 +505,5 @@ singlemount:
505 goto singlemount; 505 goto singlemount;
506 506
507goodbye: 507goodbye:
508 usage(mount_usage); 508 show_usage();
509} 509}
diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c
index 92fe4aeab..e00710148 100644
--- a/util-linux/pivot_root.c
+++ b/util-linux/pivot_root.c
@@ -20,7 +20,7 @@ static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
20int pivot_root_main(int argc, char **argv) 20int pivot_root_main(int argc, char **argv)
21{ 21{
22 if (argc != 3) 22 if (argc != 3)
23 usage(pivot_root_usage); 23 show_usage();
24 24
25 if (pivot_root(argv[1],argv[2]) < 0) 25 if (pivot_root(argv[1],argv[2]) < 0)
26 perror_msg_and_die("pivot_root"); 26 perror_msg_and_die("pivot_root");
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index d350be877..38a7689e9 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -95,14 +95,14 @@ int rdate_main(int argc, char **argv)
95 /* Interpret command line args */ 95 /* Interpret command line args */
96 /* do special-case option parsing */ 96 /* do special-case option parsing */
97 if (argv[1] && (strcmp(argv[1], "--help") == 0)) 97 if (argv[1] && (strcmp(argv[1], "--help") == 0))
98 usage(rdate_usage); 98 show_usage();
99 99
100 /* do normal option parsing */ 100 /* do normal option parsing */
101 while ((opt = getopt(argc, argv, "Hsp")) > 0) { 101 while ((opt = getopt(argc, argv, "Hsp")) > 0) {
102 switch (opt) { 102 switch (opt) {
103 default: 103 default:
104 case 'H': 104 case 'H':
105 usage(rdate_usage); 105 show_usage();
106 break; 106 break;
107 case 's': 107 case 's':
108 setdate++; 108 setdate++;
@@ -117,7 +117,7 @@ int rdate_main(int argc, char **argv)
117 if (printdate==0 && setdate==0) setdate++; 117 if (printdate==0 && setdate==0) setdate++;
118 118
119 if (optind == argc) { 119 if (optind == argc) {
120 usage(rdate_usage); 120 show_usage();
121 } 121 }
122 122
123 if ((time= askremotedate(argv[optind])) == (time_t)-1) { 123 if ((time= askremotedate(argv[optind])) == (time_t)-1) {
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index 74f6ec36e..8dda0972a 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -107,5 +107,5 @@ extern int swap_on_off_main(int argc, char **argv)
107 return EXIT_SUCCESS; 107 return EXIT_SUCCESS;
108 108
109 usage_and_exit: 109 usage_and_exit:
110 usage((whichApp == SWAPON_APP) ? swapon_usage : swapoff_usage); 110 show_usage();
111} 111}
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 39842d232..c160ec284 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -235,7 +235,7 @@ static int umount_all(int useMtab)
235extern int umount_main(int argc, char **argv) 235extern int umount_main(int argc, char **argv)
236{ 236{
237 if (argc < 2) { 237 if (argc < 2) {
238 usage(umount_usage); 238 show_usage();
239 } 239 }
240#ifdef BB_FEATURE_CLEAN_UP 240#ifdef BB_FEATURE_CLEAN_UP
241 atexit(mtab_free); 241 atexit(mtab_free);
@@ -269,7 +269,7 @@ extern int umount_main(int argc, char **argv)
269 case 'v': 269 case 'v':
270 break; /* ignore -v */ 270 break; /* ignore -v */
271 default: 271 default:
272 usage(umount_usage); 272 show_usage();
273 } 273 }
274 } 274 }
275 275