diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/acpid.c | 2 | ||||
-rw-r--r-- | util-linux/blockdev.c | 12 | ||||
-rw-r--r-- | util-linux/dmesg.c | 4 | ||||
-rw-r--r-- | util-linux/eject.c | 2 | ||||
-rw-r--r-- | util-linux/fdformat.c | 2 | ||||
-rw-r--r-- | util-linux/fdisk.c | 2 | ||||
-rw-r--r-- | util-linux/flock.c | 2 | ||||
-rw-r--r-- | util-linux/fsck_minix.c | 2 | ||||
-rw-r--r-- | util-linux/getopt.c | 6 | ||||
-rw-r--r-- | util-linux/hwclock.c | 4 | ||||
-rw-r--r-- | util-linux/ipcs.c | 8 | ||||
-rw-r--r-- | util-linux/last.c | 2 | ||||
-rw-r--r-- | util-linux/losetup.c | 37 | ||||
-rw-r--r-- | util-linux/mdev.c | 270 | ||||
-rw-r--r-- | util-linux/mesg.c | 2 | ||||
-rw-r--r-- | util-linux/mkfs_ext2.c | 6 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 22 | ||||
-rw-r--r-- | util-linux/mkfs_reiser.c | 2 | ||||
-rw-r--r-- | util-linux/mkfs_vfat.c | 6 | ||||
-rw-r--r-- | util-linux/mkswap.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 40 | ||||
-rw-r--r-- | util-linux/nsenter.c | 2 | ||||
-rw-r--r-- | util-linux/rdate.c | 6 | ||||
-rw-r--r-- | util-linux/readprofile.c | 4 | ||||
-rw-r--r-- | util-linux/rtcwake.c | 2 | ||||
-rw-r--r-- | util-linux/setpriv.c | 8 | ||||
-rw-r--r-- | util-linux/switch_root.c | 6 | ||||
-rw-r--r-- | util-linux/uevent.c | 41 | ||||
-rw-r--r-- | util-linux/unshare.c | 2 |
29 files changed, 313 insertions, 193 deletions
diff --git a/util-linux/acpid.c b/util-linux/acpid.c index 7274b6866..95f8150e2 100644 --- a/util-linux/acpid.c +++ b/util-linux/acpid.c | |||
@@ -148,7 +148,7 @@ static void process_event(const char *event) | |||
148 | const char *args[] = { "run-parts", handler, NULL }; | 148 | const char *args[] = { "run-parts", handler, NULL }; |
149 | 149 | ||
150 | // log the event | 150 | // log the event |
151 | bb_error_msg("%s", event); | 151 | bb_simple_error_msg(event); |
152 | 152 | ||
153 | // spawn handler | 153 | // spawn handler |
154 | // N.B. run-parts would require scripts to have #!/bin/sh | 154 | // N.B. run-parts would require scripts to have #!/bin/sh |
diff --git a/util-linux/blockdev.c b/util-linux/blockdev.c index e9b5b8bf9..e60bbe609 100644 --- a/util-linux/blockdev.c +++ b/util-linux/blockdev.c | |||
@@ -29,7 +29,17 @@ | |||
29 | //usage: "\n --getsize64 Get device size in bytes" | 29 | //usage: "\n --getsize64 Get device size in bytes" |
30 | //usage: "\n --flushbufs Flush buffers" | 30 | //usage: "\n --flushbufs Flush buffers" |
31 | //usage: "\n --rereadpt Reread partition table" | 31 | //usage: "\n --rereadpt Reread partition table" |
32 | 32 | // util-linux 2.31 also has: | |
33 | // --getdiscardzeroes BLKDISCARDZEROES Get discard zeroes support status | ||
34 | // --getpbsz BLKPBSZGET Get physical block (sector) size | ||
35 | // --getiomin BLKIOMIN Get minimum I/O size | ||
36 | // --getioopt BLKIOOPT Get optimal I/O size | ||
37 | // --getalignoff BLKALIGNOFF Get alignment offset in bytes | ||
38 | // --getmaxsect BLKSECTGET Get max sectors per request | ||
39 | // --setra SECTORS BLKRASET Set readahead | ||
40 | // --getra BLKRAGET Get readahead | ||
41 | // --setfra SECTORS BLKFRASET Set filesystem readahead | ||
42 | // --getfra BLKFRAGET Get filesystem readahead | ||
33 | 43 | ||
34 | #include "libbb.h" | 44 | #include "libbb.h" |
35 | #include <linux/fs.h> | 45 | #include <linux/fs.h> |
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index b797c7b2a..a1f269142 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c | |||
@@ -74,7 +74,7 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv) | |||
74 | opts = getopt32(argv, "cs:+n:+r", &len, &level); | 74 | opts = getopt32(argv, "cs:+n:+r", &len, &level); |
75 | if (opts & OPT_n) { | 75 | if (opts & OPT_n) { |
76 | if (klogctl(8, NULL, (long) level)) | 76 | if (klogctl(8, NULL, (long) level)) |
77 | bb_perror_msg_and_die("klogctl"); | 77 | bb_simple_perror_msg_and_die("klogctl"); |
78 | return EXIT_SUCCESS; | 78 | return EXIT_SUCCESS; |
79 | } | 79 | } |
80 | 80 | ||
@@ -88,7 +88,7 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv) | |||
88 | buf = xmalloc(len); | 88 | buf = xmalloc(len); |
89 | len = klogctl(3 + (opts & OPT_c), buf, len); /* read ring buffer */ | 89 | len = klogctl(3 + (opts & OPT_c), buf, len); /* read ring buffer */ |
90 | if (len < 0) | 90 | if (len < 0) |
91 | bb_perror_msg_and_die("klogctl"); | 91 | bb_simple_perror_msg_and_die("klogctl"); |
92 | if (len == 0) | 92 | if (len == 0) |
93 | return EXIT_SUCCESS; | 93 | return EXIT_SUCCESS; |
94 | 94 | ||
diff --git a/util-linux/eject.c b/util-linux/eject.c index 749e2c986..3ccb4ae89 100644 --- a/util-linux/eject.c +++ b/util-linux/eject.c | |||
@@ -70,7 +70,7 @@ static void eject_scsi(const char *dev) | |||
70 | sg_io_hdr_t io_hdr; | 70 | sg_io_hdr_t io_hdr; |
71 | 71 | ||
72 | if ((ioctl(dev_fd, SG_GET_VERSION_NUM, &i) < 0) || (i < 30000)) | 72 | if ((ioctl(dev_fd, SG_GET_VERSION_NUM, &i) < 0) || (i < 30000)) |
73 | bb_error_msg_and_die("not a sg device or old sg driver"); | 73 | bb_simple_error_msg_and_die("not a sg device or old sg driver"); |
74 | 74 | ||
75 | memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); | 75 | memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); |
76 | io_hdr.interface_id = 'S'; | 76 | io_hdr.interface_id = 'S'; |
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c index ff3bc4870..e1c8561d6 100644 --- a/util-linux/fdformat.c +++ b/util-linux/fdformat.c | |||
@@ -117,7 +117,7 @@ int fdformat_main(int argc UNUSED_PARAM, char **argv) | |||
117 | read_bytes = safe_read(fd, data, n); | 117 | read_bytes = safe_read(fd, data, n); |
118 | if (read_bytes != n) { | 118 | if (read_bytes != n) { |
119 | if (read_bytes < 0) { | 119 | if (read_bytes < 0) { |
120 | bb_perror_msg(bb_msg_read_error); | 120 | bb_simple_perror_msg(bb_msg_read_error); |
121 | } | 121 | } |
122 | bb_error_msg_and_die("problem reading cylinder %d, " | 122 | bb_error_msg_and_die("problem reading cylinder %d, " |
123 | "expected %d, read %d", cyl, n, read_bytes); | 123 | "expected %d, read %d", cyl, n, read_bytes); |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 58e93bb92..f28d4fdd2 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -511,7 +511,7 @@ static sector_t bb_BLKGETSIZE_sectors(int fd) | |||
511 | * we support can't record more than 32 bit | 511 | * we support can't record more than 32 bit |
512 | * sector counts or offsets | 512 | * sector counts or offsets |
513 | */ | 513 | */ |
514 | bb_error_msg("device has more than 2^32 sectors, can't use all of them"); | 514 | bb_simple_error_msg("device has more than 2^32 sectors, can't use all of them"); |
515 | v64 = (uint32_t)-1L; | 515 | v64 = (uint32_t)-1L; |
516 | } | 516 | } |
517 | return v64; | 517 | return v64; |
diff --git a/util-linux/flock.c b/util-linux/flock.c index 130627e93..12c16013c 100644 --- a/util-linux/flock.c +++ b/util-linux/flock.c | |||
@@ -73,7 +73,7 @@ int flock_main(int argc UNUSED_PARAM, char **argv) | |||
73 | ) { | 73 | ) { |
74 | argv++; | 74 | argv++; |
75 | if (argv[1]) | 75 | if (argv[1]) |
76 | bb_error_msg_and_die("-c takes only one argument"); | 76 | bb_simple_error_msg_and_die("-c takes only one argument"); |
77 | opt |= OPT_c; | 77 | opt |= OPT_c; |
78 | } | 78 | } |
79 | 79 | ||
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index f523da945..40b86d01b 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c | |||
@@ -321,7 +321,7 @@ static void die(const char *str) | |||
321 | { | 321 | { |
322 | if (termios_set) | 322 | if (termios_set) |
323 | tcsetattr_stdin_TCSANOW(&sv_termios); | 323 | tcsetattr_stdin_TCSANOW(&sv_termios); |
324 | bb_error_msg_and_die("%s", str); | 324 | bb_simple_error_msg_and_die(str); |
325 | } | 325 | } |
326 | 326 | ||
327 | static void push_filename(const char *name) | 327 | static void push_filename(const char *name) |
diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 1666d3d30..db7db6ff8 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c | |||
@@ -308,7 +308,7 @@ static struct option *add_long_options(struct option *long_options, char *option | |||
308 | } | 308 | } |
309 | tokptr[tlen] = '\0'; | 309 | tokptr[tlen] = '\0'; |
310 | if (tlen == 0) | 310 | if (tlen == 0) |
311 | bb_error_msg_and_die("empty long option specified"); | 311 | bb_simple_error_msg_and_die("empty long option specified"); |
312 | } | 312 | } |
313 | long_options = xrealloc_vector(long_options, 4, long_nr); | 313 | long_options = xrealloc_vector(long_options, 4, long_nr); |
314 | long_options[long_nr].has_arg = arg_opt; | 314 | long_options[long_nr].has_arg = arg_opt; |
@@ -380,7 +380,7 @@ int getopt_main(int argc, char **argv) | |||
380 | puts(" --"); | 380 | puts(" --"); |
381 | return 0; | 381 | return 0; |
382 | } | 382 | } |
383 | bb_error_msg_and_die("missing optstring argument"); | 383 | bb_simple_error_msg_and_die("missing optstring argument"); |
384 | } | 384 | } |
385 | 385 | ||
386 | if (argv[1][0] != '-' || compatible) { | 386 | if (argv[1][0] != '-' || compatible) { |
@@ -416,7 +416,7 @@ int getopt_main(int argc, char **argv) | |||
416 | if (!optstr) { | 416 | if (!optstr) { |
417 | optstr = argv[++n]; | 417 | optstr = argv[++n]; |
418 | if (!optstr) | 418 | if (!optstr) |
419 | bb_error_msg_and_die("missing optstring argument"); | 419 | bb_simple_error_msg_and_die("missing optstring argument"); |
420 | } | 420 | } |
421 | 421 | ||
422 | argv[n] = name ? name : argv[0]; | 422 | argv[n] = name ? name : argv[0]; |
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 29f51021e..dc97d8fb4 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c | |||
@@ -132,7 +132,7 @@ static void to_sys_clock(const char **pp_rtcname, int utc) | |||
132 | tv.tv_sec = read_rtc(pp_rtcname, NULL, utc); | 132 | tv.tv_sec = read_rtc(pp_rtcname, NULL, utc); |
133 | tv.tv_usec = 0; | 133 | tv.tv_usec = 0; |
134 | if (settimeofday(&tv, &tz)) | 134 | if (settimeofday(&tv, &tz)) |
135 | bb_perror_msg_and_die("settimeofday"); | 135 | bb_simple_perror_msg_and_die("settimeofday"); |
136 | } | 136 | } |
137 | 137 | ||
138 | static void from_sys_clock(const char **pp_rtcname, int utc) | 138 | static void from_sys_clock(const char **pp_rtcname, int utc) |
@@ -284,7 +284,7 @@ static void set_system_clock_timezone(int utc) | |||
284 | if (!utc) | 284 | if (!utc) |
285 | tv.tv_sec += tz.tz_minuteswest * 60; | 285 | tv.tv_sec += tz.tz_minuteswest * 60; |
286 | if (settimeofday(&tv, &tz)) | 286 | if (settimeofday(&tv, &tz)) |
287 | bb_perror_msg_and_die("settimeofday"); | 287 | bb_simple_perror_msg_and_die("settimeofday"); |
288 | } | 288 | } |
289 | 289 | ||
290 | //usage:#define hwclock_trivial_usage | 290 | //usage:#define hwclock_trivial_usage |
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c index 4863a5c29..df86cfb9d 100644 --- a/util-linux/ipcs.c +++ b/util-linux/ipcs.c | |||
@@ -467,7 +467,7 @@ static void print_shm(int shmid) | |||
467 | struct ipc_perm *ipcp = &shmds.shm_perm; | 467 | struct ipc_perm *ipcp = &shmds.shm_perm; |
468 | 468 | ||
469 | if (shmctl(shmid, IPC_STAT, &shmds) == -1) { | 469 | if (shmctl(shmid, IPC_STAT, &shmds) == -1) { |
470 | bb_perror_msg("shmctl"); | 470 | bb_simple_perror_msg("shmctl"); |
471 | return; | 471 | return; |
472 | } | 472 | } |
473 | 473 | ||
@@ -493,7 +493,7 @@ static void print_msg(int msqid) | |||
493 | struct ipc_perm *ipcp = &buf.msg_perm; | 493 | struct ipc_perm *ipcp = &buf.msg_perm; |
494 | 494 | ||
495 | if (msgctl(msqid, IPC_STAT, &buf) == -1) { | 495 | if (msgctl(msqid, IPC_STAT, &buf) == -1) { |
496 | bb_perror_msg("msgctl"); | 496 | bb_simple_perror_msg("msgctl"); |
497 | return; | 497 | return; |
498 | } | 498 | } |
499 | 499 | ||
@@ -527,7 +527,7 @@ static void print_sem(int semid) | |||
527 | 527 | ||
528 | arg.buf = &semds; | 528 | arg.buf = &semds; |
529 | if (semctl(semid, 0, IPC_STAT, arg)) { | 529 | if (semctl(semid, 0, IPC_STAT, arg)) { |
530 | bb_perror_msg("semctl"); | 530 | bb_simple_perror_msg("semctl"); |
531 | return; | 531 | return; |
532 | } | 532 | } |
533 | 533 | ||
@@ -555,7 +555,7 @@ static void print_sem(int semid) | |||
555 | zcnt = semctl(semid, i, GETZCNT, arg); | 555 | zcnt = semctl(semid, i, GETZCNT, arg); |
556 | pid = semctl(semid, i, GETPID, arg); | 556 | pid = semctl(semid, i, GETPID, arg); |
557 | if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) { | 557 | if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) { |
558 | bb_perror_msg_and_die("semctl"); | 558 | bb_simple_perror_msg_and_die("semctl"); |
559 | } | 559 | } |
560 | printf("%-10u %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid); | 560 | printf("%-10u %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid); |
561 | } | 561 | } |
diff --git a/util-linux/last.c b/util-linux/last.c index 689aa7a34..24ce7a8d8 100644 --- a/util-linux/last.c +++ b/util-linux/last.c | |||
@@ -100,7 +100,7 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
100 | pos = lseek(file, pos - sizeof(ut), SEEK_SET); | 100 | pos = lseek(file, pos - sizeof(ut), SEEK_SET); |
101 | while ((n = full_read(file, &ut, sizeof(ut))) > 0) { | 101 | while ((n = full_read(file, &ut, sizeof(ut))) > 0) { |
102 | if (n != sizeof(ut)) { | 102 | if (n != sizeof(ut)) { |
103 | bb_perror_msg_and_die("short read"); | 103 | bb_simple_perror_msg_and_die("short read"); |
104 | } | 104 | } |
105 | n = index_in_strings(_ut_lin, ut.ut_line); | 105 | n = index_in_strings(_ut_lin, ut.ut_line); |
106 | if (n == _TILDE) { /* '~' */ | 106 | if (n == _TILDE) { /* '~' */ |
diff --git a/util-linux/losetup.c b/util-linux/losetup.c index 2248f2cba..cc6c2b1d5 100644 --- a/util-linux/losetup.c +++ b/util-linux/losetup.c | |||
@@ -20,13 +20,14 @@ | |||
20 | //kbuild:lib-$(CONFIG_LOSETUP) += losetup.o | 20 | //kbuild:lib-$(CONFIG_LOSETUP) += losetup.o |
21 | 21 | ||
22 | //usage:#define losetup_trivial_usage | 22 | //usage:#define losetup_trivial_usage |
23 | //usage: "[-r] [-o OFS] {-f|LOOPDEV} FILE: associate loop devices\n" | 23 | //usage: "[-rP] [-o OFS] {-f|LOOPDEV} FILE: associate loop devices\n" |
24 | //usage: " losetup -c LOOPDEV: reread file size\n" | 24 | //usage: " losetup -c LOOPDEV: reread file size\n" |
25 | //usage: " losetup -d LOOPDEV: disassociate\n" | 25 | //usage: " losetup -d LOOPDEV: disassociate\n" |
26 | //usage: " losetup -a: show status\n" | 26 | //usage: " losetup -a: show status\n" |
27 | //usage: " losetup -f: show next free loop device" | 27 | //usage: " losetup -f: show next free loop device" |
28 | //usage:#define losetup_full_usage "\n\n" | 28 | //usage:#define losetup_full_usage "\n\n" |
29 | //usage: " -o OFS Start OFS bytes into FILE" | 29 | //usage: " -o OFS Start OFS bytes into FILE" |
30 | //usage: "\n -P Scan for partitions" | ||
30 | //usage: "\n -r Read-only" | 31 | //usage: "\n -r Read-only" |
31 | //usage: "\n -f Show/use next free loop device" | 32 | //usage: "\n -f Show/use next free loop device" |
32 | //usage: | 33 | //usage: |
@@ -35,8 +36,9 @@ | |||
35 | //usage: "(if any), or disassociate it (with -d). The display shows the offset\n" | 36 | //usage: "(if any), or disassociate it (with -d). The display shows the offset\n" |
36 | //usage: "and filename of the file the loop device is currently bound to.\n\n" | 37 | //usage: "and filename of the file the loop device is currently bound to.\n\n" |
37 | //usage: "Two arguments (losetup /dev/loop1 file.img) create a new association,\n" | 38 | //usage: "Two arguments (losetup /dev/loop1 file.img) create a new association,\n" |
38 | //usage: "with an optional offset (-o 12345). Encryption is not yet supported.\n" | 39 | //usage: "with optional partition scanning (creates /dev/loop1p1, /dev/loop1p2\n" |
39 | //usage: "losetup -f will show the first loop free loop device\n\n" | 40 | //usage: "etc. with -P) and with an optional offset (-o 12345). Encryption is\n" |
41 | //usage: "not yet supported. losetup -f will show the first free loop device\n\n" | ||
40 | 42 | ||
41 | #include "libbb.h" | 43 | #include "libbb.h" |
42 | 44 | ||
@@ -53,13 +55,14 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
53 | enum { | 55 | enum { |
54 | OPT_c = (1 << 0), | 56 | OPT_c = (1 << 0), |
55 | OPT_d = (1 << 1), | 57 | OPT_d = (1 << 1), |
56 | OPT_o = (1 << 2), | 58 | OPT_P = (1 << 2), |
57 | OPT_f = (1 << 3), | 59 | OPT_o = (1 << 3), |
58 | OPT_a = (1 << 4), | 60 | OPT_f = (1 << 4), |
59 | OPT_r = (1 << 5), | 61 | OPT_a = (1 << 5), |
62 | OPT_r = (1 << 6), | ||
60 | }; | 63 | }; |
61 | 64 | ||
62 | opt = getopt32(argv, "^" "cdo:far" "\0" "?2:d--ofar:a--ofr", &opt_o); | 65 | opt = getopt32(argv, "^" "cdPo:far" "\0" "?2:d--Pofar:a--Pofr", &opt_o); |
63 | argv += optind; | 66 | argv += optind; |
64 | 67 | ||
65 | /* LOOPDEV */ | 68 | /* LOOPDEV */ |
@@ -111,11 +114,17 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
111 | /* contains -f */ | 114 | /* contains -f */ |
112 | if (opt & OPT_f) { | 115 | if (opt & OPT_f) { |
113 | char *s; | 116 | char *s; |
114 | int n = 0; | 117 | int n; |
115 | 118 | ||
119 | n = get_free_loop(); | ||
120 | if (n == -1) | ||
121 | bb_simple_error_msg_and_die("no free loop devices"); | ||
122 | if (n < 0) /* n == -2: no /dev/loop-control, use legacy method */ | ||
123 | n = 0; | ||
124 | /* or: n >= 0: the number of next free loopdev, just verify it */ | ||
116 | do { | 125 | do { |
117 | if (n > MAX_LOOP_NUM) | 126 | if (n > MAX_LOOP_NUM) |
118 | bb_error_msg_and_die("no free loop devices"); | 127 | bb_simple_error_msg_and_die("no free loop devices"); |
119 | sprintf(dev, LOOP_FORMAT, n++); | 128 | sprintf(dev, LOOP_FORMAT, n++); |
120 | s = query_loop(dev); | 129 | s = query_loop(dev); |
121 | free(s); | 130 | free(s); |
@@ -127,7 +136,7 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
127 | } | 136 | } |
128 | } | 137 | } |
129 | 138 | ||
130 | /* [-r] [-o OFS] {-f|LOOPDEV} FILE */ | 139 | /* [-rP] [-o OFS] {-f|LOOPDEV} FILE */ |
131 | if (argv[0] && ((opt & OPT_f) || argv[1])) { | 140 | if (argv[0] && ((opt & OPT_f) || argv[1])) { |
132 | unsigned long long offset = 0; | 141 | unsigned long long offset = 0; |
133 | char *d = dev; | 142 | char *d = dev; |
@@ -138,7 +147,11 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
138 | d = *argv++; | 147 | d = *argv++; |
139 | 148 | ||
140 | if (argv[0]) { | 149 | if (argv[0]) { |
141 | if (set_loop(&d, argv[0], offset, (opt & OPT_r) ? BB_LO_FLAGS_READ_ONLY : 0) < 0) | 150 | unsigned flags = (opt & OPT_r) ? BB_LO_FLAGS_READ_ONLY : 0; |
151 | if (opt & OPT_P) { | ||
152 | flags |= BB_LO_FLAGS_PARTSCAN; | ||
153 | } | ||
154 | if (set_loop(&d, argv[0], offset, flags) < 0) | ||
142 | bb_simple_perror_msg_and_die(argv[0]); | 155 | bb_simple_perror_msg_and_die(argv[0]); |
143 | return EXIT_SUCCESS; | 156 | return EXIT_SUCCESS; |
144 | } | 157 | } |
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 63b55536a..207a112c1 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -64,15 +64,30 @@ | |||
64 | //config: These devices will request userspace look up the files in | 64 | //config: These devices will request userspace look up the files in |
65 | //config: /lib/firmware/ and if it exists, send it to the kernel for | 65 | //config: /lib/firmware/ and if it exists, send it to the kernel for |
66 | //config: loading into the hardware. | 66 | //config: loading into the hardware. |
67 | //config: | ||
68 | //config:config FEATURE_MDEV_DAEMON | ||
69 | //config: bool "Support daemon mode" | ||
70 | //config: default y | ||
71 | //config: depends on MDEV | ||
72 | //config: help | ||
73 | //config: Adds the -d option to run mdev in daemon mode handling hotplug | ||
74 | //config: events from the kernel like udev. If the system generates many | ||
75 | //config: hotplug events this mode of operation will consume less | ||
76 | //config: resources than registering mdev as hotplug helper or using the | ||
77 | //config: uevent applet. | ||
67 | 78 | ||
68 | //applet:IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP)) | 79 | //applet:IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP)) |
69 | 80 | ||
70 | //kbuild:lib-$(CONFIG_MDEV) += mdev.o | 81 | //kbuild:lib-$(CONFIG_MDEV) += mdev.o |
71 | 82 | ||
72 | //usage:#define mdev_trivial_usage | 83 | //usage:#define mdev_trivial_usage |
73 | //usage: "[-s]" | 84 | //usage: "[-s]" IF_FEATURE_MDEV_DAEMON(" | [-df]") |
74 | //usage:#define mdev_full_usage "\n\n" | 85 | //usage:#define mdev_full_usage "\n\n" |
75 | //usage: "mdev -s is to be run during boot to scan /sys and populate /dev.\n" | 86 | //usage: "mdev -s is to be run during boot to scan /sys and populate /dev.\n" |
87 | //usage: IF_FEATURE_MDEV_DAEMON( | ||
88 | //usage: "mdev -d[f]: daemon, listen on netlink.\n" | ||
89 | //usage: " -f: stay in foreground.\n" | ||
90 | //usage: ) | ||
76 | //usage: "\n" | 91 | //usage: "\n" |
77 | //usage: "Bare mdev is a kernel hotplug helper. To activate it:\n" | 92 | //usage: "Bare mdev is a kernel hotplug helper. To activate it:\n" |
78 | //usage: " echo /sbin/mdev >/proc/sys/kernel/hotplug\n" | 93 | //usage: " echo /sbin/mdev >/proc/sys/kernel/hotplug\n" |
@@ -98,6 +113,7 @@ | |||
98 | #include "libbb.h" | 113 | #include "libbb.h" |
99 | #include "common_bufsiz.h" | 114 | #include "common_bufsiz.h" |
100 | #include "xregex.h" | 115 | #include "xregex.h" |
116 | #include <linux/netlink.h> | ||
101 | 117 | ||
102 | /* "mdev -s" scans /sys/class/xxx, looking for directories which have dev | 118 | /* "mdev -s" scans /sys/class/xxx, looking for directories which have dev |
103 | * file (it is of the form "M:m\n"). Example: /sys/class/tty/tty0/dev | 119 | * file (it is of the form "M:m\n"). Example: /sys/class/tty/tty0/dev |
@@ -234,21 +250,30 @@ | |||
234 | 250 | ||
235 | #if DEBUG_LVL >= 1 | 251 | #if DEBUG_LVL >= 1 |
236 | # define dbg1(...) do { if (G.verbose) bb_error_msg(__VA_ARGS__); } while(0) | 252 | # define dbg1(...) do { if (G.verbose) bb_error_msg(__VA_ARGS__); } while(0) |
253 | # define dbg1s(msg) do { if (G.verbose) bb_simple_error_msg(msg); } while(0) | ||
237 | #else | 254 | #else |
238 | # define dbg1(...) ((void)0) | 255 | # define dbg1(...) ((void)0) |
256 | # define dbg1s(msg) ((void)0) | ||
239 | #endif | 257 | #endif |
240 | #if DEBUG_LVL >= 2 | 258 | #if DEBUG_LVL >= 2 |
241 | # define dbg2(...) do { if (G.verbose >= 2) bb_error_msg(__VA_ARGS__); } while(0) | 259 | # define dbg2(...) do { if (G.verbose >= 2) bb_error_msg(__VA_ARGS__); } while(0) |
260 | # define dbg2s(msg) do { if (G.verbose >= 2) bb_simple_error_msg(msg); } while(0) | ||
242 | #else | 261 | #else |
243 | # define dbg2(...) ((void)0) | 262 | # define dbg2(...) ((void)0) |
263 | # define dbg2s(msg) ((void)0) | ||
244 | #endif | 264 | #endif |
245 | #if DEBUG_LVL >= 3 | 265 | #if DEBUG_LVL >= 3 |
246 | # define dbg3(...) do { if (G.verbose >= 3) bb_error_msg(__VA_ARGS__); } while(0) | 266 | # define dbg3(...) do { if (G.verbose >= 3) bb_error_msg(__VA_ARGS__); } while(0) |
267 | # define dbg3s(msg) do { if (G.verbose >= 3) bb_simple_error_msg(msg); } while(0) | ||
247 | #else | 268 | #else |
248 | # define dbg3(...) ((void)0) | 269 | # define dbg3(...) ((void)0) |
270 | # define dbg3s(msg) ((void)0) | ||
249 | #endif | 271 | #endif |
250 | 272 | ||
251 | 273 | ||
274 | #ifndef SO_RCVBUFFORCE | ||
275 | #define SO_RCVBUFFORCE 33 | ||
276 | #endif | ||
252 | static const char keywords[] ALIGN1 = "add\0remove\0"; // "change\0" | 277 | static const char keywords[] ALIGN1 = "add\0remove\0"; // "change\0" |
253 | enum { OP_add, OP_remove }; | 278 | enum { OP_add, OP_remove }; |
254 | 279 | ||
@@ -1002,7 +1027,7 @@ wait_for_seqfile(unsigned expected_seq) | |||
1002 | /* seed file: write out seq ASAP */ | 1027 | /* seed file: write out seq ASAP */ |
1003 | xwrite_str(seq_fd, utoa(expected_seq)); | 1028 | xwrite_str(seq_fd, utoa(expected_seq)); |
1004 | xlseek(seq_fd, 0, SEEK_SET); | 1029 | xlseek(seq_fd, 0, SEEK_SET); |
1005 | dbg2("first seq written"); | 1030 | dbg2s("first seq written"); |
1006 | break; | 1031 | break; |
1007 | } | 1032 | } |
1008 | seqbufnum = atoll(seqbuf); | 1033 | seqbufnum = atoll(seqbuf); |
@@ -1047,17 +1072,141 @@ static void signal_mdevs(unsigned my_pid) | |||
1047 | } | 1072 | } |
1048 | } | 1073 | } |
1049 | 1074 | ||
1075 | static void process_action(char *temp, unsigned my_pid) | ||
1076 | { | ||
1077 | char *fw; | ||
1078 | char *seq; | ||
1079 | char *action; | ||
1080 | char *env_devname; | ||
1081 | char *env_devpath; | ||
1082 | unsigned seqnum = seqnum; /* for compiler */ | ||
1083 | int seq_fd; | ||
1084 | smalluint op; | ||
1085 | |||
1086 | /* Hotplug: | ||
1087 | * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev | ||
1088 | * ACTION can be "add", "remove", "change" | ||
1089 | * DEVPATH is like "/block/sda" or "/class/input/mice" | ||
1090 | */ | ||
1091 | env_devname = getenv("DEVNAME"); /* can be NULL */ | ||
1092 | G.subsystem = getenv("SUBSYSTEM"); | ||
1093 | action = getenv("ACTION"); | ||
1094 | env_devpath = getenv("DEVPATH"); | ||
1095 | if (!action || !env_devpath /*|| !G.subsystem*/) | ||
1096 | bb_show_usage(); | ||
1097 | fw = getenv("FIRMWARE"); | ||
1098 | seq = getenv("SEQNUM"); | ||
1099 | op = index_in_strings(keywords, action); | ||
1100 | |||
1101 | if (my_pid) | ||
1102 | open_mdev_log(seq, my_pid); | ||
1103 | |||
1104 | seq_fd = -1; | ||
1105 | if (my_pid && seq) { | ||
1106 | seqnum = atoll(seq); | ||
1107 | seq_fd = wait_for_seqfile(seqnum); | ||
1108 | } | ||
1109 | |||
1110 | dbg1("%s " | ||
1111 | "ACTION:%s SEQNUM:%s SUBSYSTEM:%s DEVNAME:%s DEVPATH:%s" | ||
1112 | "%s%s", | ||
1113 | curtime(), | ||
1114 | action, seq, G.subsystem, env_devname, env_devpath, | ||
1115 | fw ? " FW:" : "", fw ? fw : "" | ||
1116 | ); | ||
1117 | |||
1118 | snprintf(temp, PATH_MAX, "/sys%s", env_devpath); | ||
1119 | if (op == OP_remove) { | ||
1120 | /* Ignoring "remove firmware". It was reported | ||
1121 | * to happen and to cause erroneous deletion | ||
1122 | * of device nodes. */ | ||
1123 | if (!fw) | ||
1124 | make_device(env_devname, temp, op); | ||
1125 | } | ||
1126 | else { | ||
1127 | make_device(env_devname, temp, op); | ||
1128 | if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) { | ||
1129 | if (op == OP_add && fw) | ||
1130 | load_firmware(fw, temp); | ||
1131 | } | ||
1132 | } | ||
1133 | |||
1134 | if (seq_fd >= 0) { | ||
1135 | xwrite_str(seq_fd, utoa(seqnum + 1)); | ||
1136 | signal_mdevs(my_pid); | ||
1137 | } | ||
1138 | } | ||
1139 | |||
1140 | static void initial_scan(char *temp) | ||
1141 | { | ||
1142 | struct stat st; | ||
1143 | |||
1144 | xstat("/", &st); | ||
1145 | G.root_major = major(st.st_dev); | ||
1146 | G.root_minor = minor(st.st_dev); | ||
1147 | |||
1148 | putenv((char*)"ACTION=add"); | ||
1149 | |||
1150 | /* Create all devices from /sys/dev hierarchy */ | ||
1151 | recursive_action("/sys/dev", | ||
1152 | ACTION_RECURSE | ACTION_FOLLOWLINKS, | ||
1153 | fileAction, dirAction, temp, 0); | ||
1154 | } | ||
1155 | |||
1156 | #if ENABLE_FEATURE_MDEV_DAEMON | ||
1157 | |||
1158 | /* uevent applet uses 16k buffer, and mmaps it before every read */ | ||
1159 | # define BUFFER_SIZE (2 * 1024) | ||
1160 | # define RCVBUF (2 * 1024 * 1024) | ||
1161 | # define MAX_ENV 32 | ||
1162 | |||
1163 | static void daemon_loop(char *temp, int fd) | ||
1164 | { | ||
1165 | for (;;) { | ||
1166 | char netbuf[BUFFER_SIZE]; | ||
1167 | char *env[MAX_ENV]; | ||
1168 | char *s, *end; | ||
1169 | ssize_t len; | ||
1170 | int idx; | ||
1171 | |||
1172 | len = safe_read(fd, netbuf, sizeof(netbuf) - 1); | ||
1173 | if (len < 0) { | ||
1174 | bb_simple_perror_msg_and_die("read"); | ||
1175 | } | ||
1176 | end = netbuf + len; | ||
1177 | *end = '\0'; | ||
1178 | |||
1179 | idx = 0; | ||
1180 | s = netbuf; | ||
1181 | while (s < end && idx < MAX_ENV) { | ||
1182 | if (endofname(s)[0] == '=') { | ||
1183 | env[idx++] = s; | ||
1184 | putenv(s); | ||
1185 | } | ||
1186 | s += strlen(s) + 1; | ||
1187 | } | ||
1188 | |||
1189 | process_action(temp, 0); | ||
1190 | |||
1191 | while (idx) | ||
1192 | bb_unsetenv(env[--idx]); | ||
1193 | } | ||
1194 | } | ||
1195 | #endif | ||
1196 | |||
1050 | int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1197 | int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
1051 | int mdev_main(int argc UNUSED_PARAM, char **argv) | 1198 | int mdev_main(int argc UNUSED_PARAM, char **argv) |
1052 | { | 1199 | { |
1200 | enum { | ||
1201 | MDEV_OPT_SCAN = 1 << 0, | ||
1202 | MDEV_OPT_DAEMON = 1 << 1, | ||
1203 | MDEV_OPT_FOREGROUND = 1 << 2, | ||
1204 | }; | ||
1205 | int opt; | ||
1053 | RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE); | 1206 | RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE); |
1054 | 1207 | ||
1055 | INIT_G(); | 1208 | INIT_G(); |
1056 | 1209 | ||
1057 | #if ENABLE_FEATURE_MDEV_CONF | ||
1058 | G.filename = "/etc/mdev.conf"; | ||
1059 | #endif | ||
1060 | |||
1061 | /* We can be called as hotplug helper */ | 1210 | /* We can be called as hotplug helper */ |
1062 | /* Kernel cannot provide suitable stdio fds for us, do it ourself */ | 1211 | /* Kernel cannot provide suitable stdio fds for us, do it ourself */ |
1063 | bb_sanitize_stdio(); | 1212 | bb_sanitize_stdio(); |
@@ -1067,90 +1216,55 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
1067 | 1216 | ||
1068 | xchdir("/dev"); | 1217 | xchdir("/dev"); |
1069 | 1218 | ||
1070 | if (argv[1] && strcmp(argv[1], "-s") == 0) { | 1219 | opt = getopt32(argv, "s" IF_FEATURE_MDEV_DAEMON("df")); |
1071 | /* | ||
1072 | * Scan: mdev -s | ||
1073 | */ | ||
1074 | struct stat st; | ||
1075 | 1220 | ||
1076 | #if ENABLE_FEATURE_MDEV_CONF | 1221 | #if ENABLE_FEATURE_MDEV_CONF |
1222 | G.filename = "/etc/mdev.conf"; | ||
1223 | if (opt & (MDEV_OPT_SCAN|MDEV_OPT_DAEMON)) { | ||
1077 | /* Same as xrealloc_vector(NULL, 4, 0): */ | 1224 | /* Same as xrealloc_vector(NULL, 4, 0): */ |
1078 | G.rule_vec = xzalloc((1 << 4) * sizeof(*G.rule_vec)); | 1225 | G.rule_vec = xzalloc((1 << 4) * sizeof(*G.rule_vec)); |
1226 | } | ||
1079 | #endif | 1227 | #endif |
1080 | xstat("/", &st); | ||
1081 | G.root_major = major(st.st_dev); | ||
1082 | G.root_minor = minor(st.st_dev); | ||
1083 | 1228 | ||
1084 | putenv((char*)"ACTION=add"); | 1229 | #if ENABLE_FEATURE_MDEV_DAEMON |
1230 | if (opt & MDEV_OPT_DAEMON) { | ||
1231 | /* | ||
1232 | * Daemon mode listening on uevent netlink socket. | ||
1233 | */ | ||
1234 | int fd; | ||
1235 | |||
1236 | /* Subscribe for UEVENT kernel messages */ | ||
1237 | /* Without a sufficiently big RCVBUF, a ton of simultaneous events | ||
1238 | * can trigger ENOBUFS on read, which is unrecoverable. | ||
1239 | * Reproducer: | ||
1240 | * mdev -d | ||
1241 | * find /sys -name uevent -exec sh -c 'echo add >"{}"' ';' | ||
1242 | */ | ||
1243 | fd = create_and_bind_to_netlink(NETLINK_KOBJECT_UEVENT, 1 << 0, RCVBUF); | ||
1085 | 1244 | ||
1086 | /* Create all devices from /sys/dev hierarchy */ | 1245 | /* |
1087 | recursive_action("/sys/dev", | 1246 | * Make inital scan after the uevent socket is alive and |
1088 | ACTION_RECURSE | ACTION_FOLLOWLINKS, | 1247 | * _before_ we fork away. |
1089 | fileAction, dirAction, temp, 0); | ||
1090 | } else { | ||
1091 | char *fw; | ||
1092 | char *seq; | ||
1093 | char *action; | ||
1094 | char *env_devname; | ||
1095 | char *env_devpath; | ||
1096 | unsigned my_pid; | ||
1097 | unsigned seqnum = seqnum; /* for compiler */ | ||
1098 | int seq_fd; | ||
1099 | smalluint op; | ||
1100 | |||
1101 | /* Hotplug: | ||
1102 | * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev | ||
1103 | * ACTION can be "add", "remove", "change" | ||
1104 | * DEVPATH is like "/block/sda" or "/class/input/mice" | ||
1105 | */ | 1248 | */ |
1106 | env_devname = getenv("DEVNAME"); /* can be NULL */ | 1249 | initial_scan(temp); |
1107 | G.subsystem = getenv("SUBSYSTEM"); | ||
1108 | action = getenv("ACTION"); | ||
1109 | env_devpath = getenv("DEVPATH"); | ||
1110 | if (!action || !env_devpath /*|| !G.subsystem*/) | ||
1111 | bb_show_usage(); | ||
1112 | fw = getenv("FIRMWARE"); | ||
1113 | seq = getenv("SEQNUM"); | ||
1114 | op = index_in_strings(keywords, action); | ||
1115 | |||
1116 | my_pid = getpid(); | ||
1117 | open_mdev_log(seq, my_pid); | ||
1118 | 1250 | ||
1119 | seq_fd = -1; | 1251 | if (!(opt & MDEV_OPT_FOREGROUND)) |
1120 | if (seq) { | 1252 | bb_daemonize_or_rexec(0, argv); |
1121 | seqnum = atoll(seq); | ||
1122 | seq_fd = wait_for_seqfile(seqnum); | ||
1123 | } | ||
1124 | 1253 | ||
1125 | dbg1("%s " | 1254 | open_mdev_log(NULL, getpid()); |
1126 | "ACTION:%s SUBSYSTEM:%s DEVNAME:%s DEVPATH:%s" | 1255 | |
1127 | "%s%s", | 1256 | daemon_loop(temp, fd); |
1128 | curtime(), | 1257 | } |
1129 | action, G.subsystem, env_devname, env_devpath, | 1258 | #endif |
1130 | fw ? " FW:" : "", fw ? fw : "" | 1259 | if (opt & MDEV_OPT_SCAN) { |
1131 | ); | 1260 | /* |
1132 | 1261 | * Scan: mdev -s | |
1133 | snprintf(temp, PATH_MAX, "/sys%s", env_devpath); | 1262 | */ |
1134 | if (op == OP_remove) { | 1263 | initial_scan(temp); |
1135 | /* Ignoring "remove firmware". It was reported | 1264 | } else { |
1136 | * to happen and to cause erroneous deletion | 1265 | process_action(temp, getpid()); |
1137 | * of device nodes. */ | ||
1138 | if (!fw) | ||
1139 | make_device(env_devname, temp, op); | ||
1140 | } | ||
1141 | else { | ||
1142 | make_device(env_devname, temp, op); | ||
1143 | if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) { | ||
1144 | if (op == OP_add && fw) | ||
1145 | load_firmware(fw, temp); | ||
1146 | } | ||
1147 | } | ||
1148 | 1266 | ||
1149 | dbg1("%s exiting", curtime()); | 1267 | dbg1("%s exiting", curtime()); |
1150 | if (seq_fd >= 0) { | ||
1151 | xwrite_str(seq_fd, utoa(seqnum + 1)); | ||
1152 | signal_mdevs(my_pid); | ||
1153 | } | ||
1154 | } | 1268 | } |
1155 | 1269 | ||
1156 | if (ENABLE_FEATURE_CLEAN_UP) | 1270 | if (ENABLE_FEATURE_CLEAN_UP) |
diff --git a/util-linux/mesg.c b/util-linux/mesg.c index c7b696853..8c032555b 100644 --- a/util-linux/mesg.c +++ b/util-linux/mesg.c | |||
@@ -65,7 +65,7 @@ int mesg_main(int argc UNUSED_PARAM, char **argv) | |||
65 | */ | 65 | */ |
66 | 66 | ||
67 | if (!isatty(STDIN_FILENO)) | 67 | if (!isatty(STDIN_FILENO)) |
68 | bb_error_msg_and_die("not a tty"); | 68 | bb_simple_error_msg_and_die("not a tty"); |
69 | 69 | ||
70 | xfstat(STDIN_FILENO, &sb, "stdin"); | 70 | xfstat(STDIN_FILENO, &sb, "stdin"); |
71 | if (c == 0) { | 71 | if (c == 0) { |
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 845ba0a24..d568f4be5 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c | |||
@@ -266,7 +266,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) | |||
266 | // N.B. what if we format a file? find_mount_point will return false negative since | 266 | // N.B. what if we format a file? find_mount_point will return false negative since |
267 | // it is loop block device which is mounted! | 267 | // it is loop block device which is mounted! |
268 | if (find_mount_point(argv[0], 0)) | 268 | if (find_mount_point(argv[0], 0)) |
269 | bb_error_msg_and_die("can't format mounted filesystem"); | 269 | bb_simple_error_msg_and_die("can't format mounted filesystem"); |
270 | 270 | ||
271 | // get size in kbytes | 271 | // get size in kbytes |
272 | kilobytes = get_volume_size_in_bytes(fd, argv[1], 1024, /*extend:*/ !(option_mask32 & OPT_n)) / 1024; | 272 | kilobytes = get_volume_size_in_bytes(fd, argv[1], 1024, /*extend:*/ !(option_mask32 & OPT_n)) / 1024; |
@@ -326,11 +326,11 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) | |||
326 | kilobytes >>= (blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); | 326 | kilobytes >>= (blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); |
327 | nblocks = kilobytes; | 327 | nblocks = kilobytes; |
328 | if (nblocks != kilobytes) | 328 | if (nblocks != kilobytes) |
329 | bb_error_msg_and_die("block count doesn't fit in 32 bits"); | 329 | bb_simple_error_msg_and_die("block count doesn't fit in 32 bits"); |
330 | #define kilobytes kilobytes_unused_after_this | 330 | #define kilobytes kilobytes_unused_after_this |
331 | // Experimentally, standard mke2fs won't work on images smaller than 60k | 331 | // Experimentally, standard mke2fs won't work on images smaller than 60k |
332 | if (nblocks < 60) | 332 | if (nblocks < 60) |
333 | bb_error_msg_and_die("need >= 60 blocks"); | 333 | bb_simple_error_msg_and_die("need >= 60 blocks"); |
334 | 334 | ||
335 | // How many reserved blocks? | 335 | // How many reserved blocks? |
336 | if (reserved_percent > 50) | 336 | if (reserved_percent > 50) |
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index e191acbd0..8f791cf66 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -262,7 +262,7 @@ static int get_free_block(void) | |||
262 | int blk; | 262 | int blk; |
263 | 263 | ||
264 | if (G.used_good_blocks + 1 >= MAX_GOOD_BLOCKS) | 264 | if (G.used_good_blocks + 1 >= MAX_GOOD_BLOCKS) |
265 | bb_error_msg_and_die("too many bad blocks"); | 265 | bb_simple_error_msg_and_die("too many bad blocks"); |
266 | if (G.used_good_blocks) | 266 | if (G.used_good_blocks) |
267 | blk = G.good_blocks_table[G.used_good_blocks - 1] + 1; | 267 | blk = G.good_blocks_table[G.used_good_blocks - 1] + 1; |
268 | else | 268 | else |
@@ -270,7 +270,7 @@ static int get_free_block(void) | |||
270 | while (blk < SB_ZONES && zone_in_use(blk)) | 270 | while (blk < SB_ZONES && zone_in_use(blk)) |
271 | blk++; | 271 | blk++; |
272 | if (blk >= SB_ZONES) | 272 | if (blk >= SB_ZONES) |
273 | bb_error_msg_and_die("not enough good blocks"); | 273 | bb_simple_error_msg_and_die("not enough good blocks"); |
274 | G.good_blocks_table[G.used_good_blocks] = blk; | 274 | G.good_blocks_table[G.used_good_blocks] = blk; |
275 | G.used_good_blocks++; | 275 | G.used_good_blocks++; |
276 | return blk; | 276 | return blk; |
@@ -342,7 +342,7 @@ static void make_bad_inode(void) | |||
342 | goto end_bad; | 342 | goto end_bad; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | bb_error_msg_and_die("too many bad blocks"); | 345 | bb_simple_error_msg_and_die("too many bad blocks"); |
346 | end_bad: | 346 | end_bad: |
347 | if (ind) | 347 | if (ind) |
348 | write_block(ind, (char *) ind_block); | 348 | write_block(ind, (char *) ind_block); |
@@ -398,7 +398,7 @@ static void make_bad_inode2(void) | |||
398 | } | 398 | } |
399 | } | 399 | } |
400 | /* Could make triple indirect block here */ | 400 | /* Could make triple indirect block here */ |
401 | bb_error_msg_and_die("too many bad blocks"); | 401 | bb_simple_error_msg_and_die("too many bad blocks"); |
402 | end_bad: | 402 | end_bad: |
403 | if (ind) | 403 | if (ind) |
404 | write_block(ind, (char *) ind_block); | 404 | write_block(ind, (char *) ind_block); |
@@ -514,7 +514,7 @@ static void check_blocks(void) | |||
514 | if (got == try) | 514 | if (got == try) |
515 | continue; | 515 | continue; |
516 | if (G.currently_testing < SB_FIRSTZONE) | 516 | if (G.currently_testing < SB_FIRSTZONE) |
517 | bb_error_msg_and_die("bad blocks before data-area: cannot make fs"); | 517 | bb_simple_error_msg_and_die("bad blocks before data-area: cannot make fs"); |
518 | mark_zone(G.currently_testing); | 518 | mark_zone(G.currently_testing); |
519 | G.badblocks++; | 519 | G.badblocks++; |
520 | G.currently_testing++; | 520 | G.currently_testing++; |
@@ -588,7 +588,7 @@ static void setup_tables(void) | |||
588 | SB_ZMAPS = sb_zmaps; | 588 | SB_ZMAPS = sb_zmaps; |
589 | /* new SB_ZMAPS, need to recalc NORM_FIRSTZONE */ | 589 | /* new SB_ZMAPS, need to recalc NORM_FIRSTZONE */ |
590 | } while (--i); | 590 | } while (--i); |
591 | bb_error_msg_and_die("incompatible size/inode count, try different -i N"); | 591 | bb_simple_error_msg_and_die("incompatible size/inode count, try different -i N"); |
592 | got_it: | 592 | got_it: |
593 | 593 | ||
594 | SB_FIRSTZONE = norm_firstzone; | 594 | SB_FIRSTZONE = norm_firstzone; |
@@ -623,10 +623,10 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) | |||
623 | G.magic = MINIX1_SUPER_MAGIC2; | 623 | G.magic = MINIX1_SUPER_MAGIC2; |
624 | 624 | ||
625 | if (INODE_SIZE1 * MINIX1_INODES_PER_BLOCK != BLOCK_SIZE) | 625 | if (INODE_SIZE1 * MINIX1_INODES_PER_BLOCK != BLOCK_SIZE) |
626 | bb_error_msg_and_die("bad inode size"); | 626 | bb_simple_error_msg_and_die("bad inode size"); |
627 | #if ENABLE_FEATURE_MINIX2 | 627 | #if ENABLE_FEATURE_MINIX2 |
628 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 628 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
629 | bb_error_msg_and_die("bad inode size"); | 629 | bb_simple_error_msg_and_die("bad inode size"); |
630 | #endif | 630 | #endif |
631 | 631 | ||
632 | opt = getopt32(argv, "ci:l:n:+v", &str_i, &listfile, &G.namelen); | 632 | opt = getopt32(argv, "ci:l:n:+v", &str_i, &listfile, &G.namelen); |
@@ -644,7 +644,7 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) | |||
644 | #if ENABLE_FEATURE_MINIX2 | 644 | #if ENABLE_FEATURE_MINIX2 |
645 | version2 = 1; | 645 | version2 = 1; |
646 | #else | 646 | #else |
647 | bb_error_msg_and_die("not compiled with minix v2 support"); | 647 | bb_simple_error_msg_and_die("not compiled with minix v2 support"); |
648 | #endif | 648 | #endif |
649 | } | 649 | } |
650 | 650 | ||
@@ -654,14 +654,14 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) | |||
654 | 654 | ||
655 | /* Check if it is mounted */ | 655 | /* Check if it is mounted */ |
656 | if (find_mount_point(G.device_name, 0)) | 656 | if (find_mount_point(G.device_name, 0)) |
657 | bb_error_msg_and_die("can't format mounted filesystem"); | 657 | bb_simple_error_msg_and_die("can't format mounted filesystem"); |
658 | 658 | ||
659 | xmove_fd(xopen(G.device_name, O_RDWR), dev_fd); | 659 | xmove_fd(xopen(G.device_name, O_RDWR), dev_fd); |
660 | 660 | ||
661 | G.total_blocks = get_volume_size_in_bytes(dev_fd, argv[1], 1024, /*extend:*/ 1) / 1024; | 661 | G.total_blocks = get_volume_size_in_bytes(dev_fd, argv[1], 1024, /*extend:*/ 1) / 1024; |
662 | 662 | ||
663 | if (G.total_blocks < 10) | 663 | if (G.total_blocks < 10) |
664 | bb_error_msg_and_die("must have at least 10 blocks"); | 664 | bb_simple_error_msg_and_die("must have at least 10 blocks"); |
665 | 665 | ||
666 | if (version2) { | 666 | if (version2) { |
667 | G.magic = MINIX2_SUPER_MAGIC2; | 667 | G.magic = MINIX2_SUPER_MAGIC2; |
diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c index b4c8dda6f..d2eaf5f94 100644 --- a/util-linux/mkfs_reiser.c +++ b/util-linux/mkfs_reiser.c | |||
@@ -178,7 +178,7 @@ int mkfs_reiser_main(int argc UNUSED_PARAM, char **argv) | |||
178 | // N.B. what if we format a file? find_mount_point will return false negative since | 178 | // N.B. what if we format a file? find_mount_point will return false negative since |
179 | // it is loop block device which is mounted! | 179 | // it is loop block device which is mounted! |
180 | if (find_mount_point(argv[0], 0)) | 180 | if (find_mount_point(argv[0], 0)) |
181 | bb_error_msg_and_die("can't format mounted filesystem"); | 181 | bb_simple_error_msg_and_die("can't format mounted filesystem"); |
182 | 182 | ||
183 | // open the device, get size in blocks | 183 | // open the device, get size in blocks |
184 | blocks = get_volume_size_in_bytes(fd, argv[1], blocksize, /*extend:*/ 1) / blocksize; | 184 | blocks = get_volume_size_in_bytes(fd, argv[1], blocksize, /*extend:*/ 1) / blocksize; |
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index b760fb2aa..16c1fac00 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c | |||
@@ -278,7 +278,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv) | |||
278 | if (!S_ISBLK(st.st_mode)) { | 278 | if (!S_ISBLK(st.st_mode)) { |
279 | if (!S_ISREG(st.st_mode)) { | 279 | if (!S_ISREG(st.st_mode)) { |
280 | if (!argv[1]) | 280 | if (!argv[1]) |
281 | bb_error_msg_and_die("image size must be specified"); | 281 | bb_simple_error_msg_and_die("image size must be specified"); |
282 | } | 282 | } |
283 | // not a block device, skip bad sectors check | 283 | // not a block device, skip bad sectors check |
284 | opts &= ~OPT_c; | 284 | opts &= ~OPT_c; |
@@ -399,7 +399,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv) | |||
399 | // "mkdosfs -v -F 32 image5k 5" is the minimum: | 399 | // "mkdosfs -v -F 32 image5k 5" is the minimum: |
400 | // 2 sectors for FATs and 2 data sectors | 400 | // 2 sectors for FATs and 2 data sectors |
401 | if ((off_t)(volume_size_sect - reserved_sect) < 4) | 401 | if ((off_t)(volume_size_sect - reserved_sect) < 4) |
402 | bb_error_msg_and_die("the image is too small for FAT32"); | 402 | bb_simple_error_msg_and_die("the image is too small for FAT32"); |
403 | sect_per_fat = 1; | 403 | sect_per_fat = 1; |
404 | while (1) { | 404 | while (1) { |
405 | while (1) { | 405 | while (1) { |
@@ -439,7 +439,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv) | |||
439 | } | 439 | } |
440 | next: | 440 | next: |
441 | if (sect_per_clust == 128) | 441 | if (sect_per_clust == 128) |
442 | bb_error_msg_and_die("can't make FAT32 with >128 sectors/cluster"); | 442 | bb_simple_error_msg_and_die("can't make FAT32 with >128 sectors/cluster"); |
443 | sect_per_clust *= 2; | 443 | sect_per_clust *= 2; |
444 | sect_per_fat = (sect_per_fat / 2) | 1; | 444 | sect_per_fat = (sect_per_fat / 2) | 1; |
445 | } | 445 | } |
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 38413606d..9e51a1dcc 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
@@ -75,7 +75,7 @@ static void mkswap_selinux_setcontext(int fd, const char *path) | |||
75 | } | 75 | } |
76 | return; | 76 | return; |
77 | error: | 77 | error: |
78 | bb_perror_msg_and_die("SELinux relabeling failed"); | 78 | bb_simple_perror_msg_and_die("SELinux relabeling failed"); |
79 | } | 79 | } |
80 | #else | 80 | #else |
81 | # define mkswap_selinux_setcontext(fd, path) ((void)0) | 81 | # define mkswap_selinux_setcontext(fd, path) ((void)0) |
diff --git a/util-linux/mount.c b/util-linux/mount.c index e6bad7c2c..84c85c057 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -483,7 +483,7 @@ static void FAST_FUNC update_mtab_entry_on_move(const struct mntent *mp) | |||
483 | 483 | ||
484 | mountTable = setmntent(bb_path_mtab_file, "r"); | 484 | mountTable = setmntent(bb_path_mtab_file, "r"); |
485 | if (!mountTable) { | 485 | if (!mountTable) { |
486 | bb_perror_msg(bb_path_mtab_file); | 486 | bb_simple_perror_msg(bb_path_mtab_file); |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | 489 | ||
@@ -511,7 +511,7 @@ static void FAST_FUNC update_mtab_entry_on_move(const struct mntent *mp) | |||
511 | } | 511 | } |
512 | endmntent(mountTable); | 512 | endmntent(mountTable); |
513 | } else if (errno != EROFS) | 513 | } else if (errno != EROFS) |
514 | bb_perror_msg(bb_path_mtab_file); | 514 | bb_simple_perror_msg(bb_path_mtab_file); |
515 | 515 | ||
516 | if (ENABLE_FEATURE_CLEAN_UP) { | 516 | if (ENABLE_FEATURE_CLEAN_UP) { |
517 | for (i = 0; i < count; i++) { | 517 | for (i = 0; i < count; i++) { |
@@ -739,7 +739,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero | |||
739 | // Abort entirely if permission denied. | 739 | // Abort entirely if permission denied. |
740 | 740 | ||
741 | if (rc && errno == EPERM) | 741 | if (rc && errno == EPERM) |
742 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); | 742 | bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
743 | 743 | ||
744 | // If the mount was successful, and we're maintaining an old-style | 744 | // If the mount was successful, and we're maintaining an old-style |
745 | // mtab file by hand, add the new entry to it now. | 745 | // mtab file by hand, add the new entry to it now. |
@@ -751,7 +751,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero | |||
751 | int i; | 751 | int i; |
752 | 752 | ||
753 | if (!mountTable) { | 753 | if (!mountTable) { |
754 | bb_perror_msg(bb_path_mtab_file); | 754 | bb_simple_perror_msg(bb_path_mtab_file); |
755 | goto ret; | 755 | goto ret; |
756 | } | 756 | } |
757 | 757 | ||
@@ -1288,18 +1288,18 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1288 | s = strchr(hostname, ','); | 1288 | s = strchr(hostname, ','); |
1289 | if (s) { | 1289 | if (s) { |
1290 | *s = '\0'; | 1290 | *s = '\0'; |
1291 | bb_error_msg("warning: multiple hostnames not supported"); | 1291 | bb_simple_error_msg("warning: multiple hostnames not supported"); |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | server_addr.sin_family = AF_INET; | 1294 | server_addr.sin_family = AF_INET; |
1295 | if (!inet_aton(hostname, &server_addr.sin_addr)) { | 1295 | if (!inet_aton(hostname, &server_addr.sin_addr)) { |
1296 | hp = gethostbyname(hostname); | 1296 | hp = gethostbyname(hostname); |
1297 | if (hp == NULL) { | 1297 | if (hp == NULL) { |
1298 | bb_herror_msg("%s", hostname); | 1298 | bb_simple_herror_msg(hostname); |
1299 | goto fail; | 1299 | goto fail; |
1300 | } | 1300 | } |
1301 | if (hp->h_length != (int)sizeof(struct in_addr)) { | 1301 | if (hp->h_length != (int)sizeof(struct in_addr)) { |
1302 | bb_error_msg_and_die("only IPv4 is supported"); | 1302 | bb_simple_error_msg_and_die("only IPv4 is supported"); |
1303 | } | 1303 | } |
1304 | memcpy(&server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr)); | 1304 | memcpy(&server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr)); |
1305 | } | 1305 | } |
@@ -1389,7 +1389,7 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1389 | else if (is_prefixed_with(opteq, "udp")) | 1389 | else if (is_prefixed_with(opteq, "udp")) |
1390 | tcp = 0; | 1390 | tcp = 0; |
1391 | else | 1391 | else |
1392 | bb_error_msg("warning: unrecognized proto= option"); | 1392 | bb_simple_error_msg("warning: unrecognized proto= option"); |
1393 | continue; | 1393 | continue; |
1394 | case 20: // "addr" - ignore | 1394 | case 20: // "addr" - ignore |
1395 | continue; | 1395 | continue; |
@@ -1522,7 +1522,7 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1522 | if (nfs_mount_version >= 3) | 1522 | if (nfs_mount_version >= 3) |
1523 | nolock = !val; | 1523 | nolock = !val; |
1524 | else | 1524 | else |
1525 | bb_error_msg("warning: option nolock is not supported"); | 1525 | bb_simple_error_msg("warning: option nolock is not supported"); |
1526 | break; | 1526 | break; |
1527 | case 11: //rdirplus | 1527 | case 11: //rdirplus |
1528 | nordirplus = !val; | 1528 | nordirplus = !val; |
@@ -1590,11 +1590,11 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1590 | } else { | 1590 | } else { |
1591 | hp = gethostbyname(mounthost); | 1591 | hp = gethostbyname(mounthost); |
1592 | if (hp == NULL) { | 1592 | if (hp == NULL) { |
1593 | bb_herror_msg("%s", mounthost); | 1593 | bb_simple_herror_msg(mounthost); |
1594 | goto fail; | 1594 | goto fail; |
1595 | } | 1595 | } |
1596 | if (hp->h_length != (int)sizeof(struct in_addr)) { | 1596 | if (hp->h_length != (int)sizeof(struct in_addr)) { |
1597 | bb_error_msg_and_die("only IPv4 is supported"); | 1597 | bb_simple_error_msg_and_die("only IPv4 is supported"); |
1598 | } | 1598 | } |
1599 | mount_server_addr.sin_family = AF_INET; | 1599 | mount_server_addr.sin_family = AF_INET; |
1600 | memcpy(&mount_server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr)); | 1600 | memcpy(&mount_server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr)); |
@@ -1767,18 +1767,18 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1767 | /* Create nfs socket for kernel */ | 1767 | /* Create nfs socket for kernel */ |
1768 | if (tcp) { | 1768 | if (tcp) { |
1769 | if (nfs_mount_version < 3) { | 1769 | if (nfs_mount_version < 3) { |
1770 | bb_error_msg("NFS over TCP is not supported"); | 1770 | bb_simple_error_msg("NFS over TCP is not supported"); |
1771 | goto fail; | 1771 | goto fail; |
1772 | } | 1772 | } |
1773 | fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | 1773 | fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); |
1774 | } else | 1774 | } else |
1775 | fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); | 1775 | fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
1776 | if (fsock < 0) { | 1776 | if (fsock < 0) { |
1777 | bb_perror_msg("nfs socket"); | 1777 | bb_simple_perror_msg("nfs socket"); |
1778 | goto fail; | 1778 | goto fail; |
1779 | } | 1779 | } |
1780 | if (bindresvport(fsock, 0) < 0) { | 1780 | if (bindresvport(fsock, 0) < 0) { |
1781 | bb_perror_msg("nfs bindresvport"); | 1781 | bb_simple_perror_msg("nfs bindresvport"); |
1782 | goto fail; | 1782 | goto fail; |
1783 | } | 1783 | } |
1784 | if (port == 0) { | 1784 | if (port == 0) { |
@@ -2047,9 +2047,9 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
2047 | ); | 2047 | ); |
2048 | if (loopfd < 0) { | 2048 | if (loopfd < 0) { |
2049 | if (errno == EPERM || errno == EACCES) | 2049 | if (errno == EPERM || errno == EACCES) |
2050 | bb_error_msg(bb_msg_perm_denied_are_you_root); | 2050 | bb_simple_error_msg(bb_msg_perm_denied_are_you_root); |
2051 | else | 2051 | else |
2052 | bb_perror_msg("can't setup loop device"); | 2052 | bb_simple_perror_msg("can't setup loop device"); |
2053 | return errno; | 2053 | return errno; |
2054 | } | 2054 | } |
2055 | 2055 | ||
@@ -2255,7 +2255,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2255 | // argument when we get it. | 2255 | // argument when we get it. |
2256 | if (argv[1]) { | 2256 | if (argv[1]) { |
2257 | if (nonroot) | 2257 | if (nonroot) |
2258 | bb_error_msg_and_die(bb_msg_you_must_be_root); | 2258 | bb_simple_error_msg_and_die(bb_msg_you_must_be_root); |
2259 | mtpair->mnt_fsname = argv[0]; | 2259 | mtpair->mnt_fsname = argv[0]; |
2260 | mtpair->mnt_dir = argv[1]; | 2260 | mtpair->mnt_dir = argv[1]; |
2261 | mtpair->mnt_type = fstype; | 2261 | mtpair->mnt_type = fstype; |
@@ -2272,7 +2272,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2272 | 2272 | ||
2273 | cmdopt_flags = parse_mount_options(cmdopts, NULL); | 2273 | cmdopt_flags = parse_mount_options(cmdopts, NULL); |
2274 | if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags | 2274 | if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags |
2275 | bb_error_msg_and_die(bb_msg_you_must_be_root); | 2275 | bb_simple_error_msg_and_die(bb_msg_you_must_be_root); |
2276 | 2276 | ||
2277 | // If we have a shared subtree flag, don't worry about fstab or mtab. | 2277 | // If we have a shared subtree flag, don't worry about fstab or mtab. |
2278 | if (ENABLE_FEATURE_MOUNT_FLAGS | 2278 | if (ENABLE_FEATURE_MOUNT_FLAGS |
@@ -2337,7 +2337,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2337 | // No, mount -a won't mount anything, | 2337 | // No, mount -a won't mount anything, |
2338 | // even user mounts, for mere humans | 2338 | // even user mounts, for mere humans |
2339 | if (nonroot) | 2339 | if (nonroot) |
2340 | bb_error_msg_and_die(bb_msg_you_must_be_root); | 2340 | bb_simple_error_msg_and_die(bb_msg_you_must_be_root); |
2341 | 2341 | ||
2342 | // Does type match? (NULL matches always) | 2342 | // Does type match? (NULL matches always) |
2343 | if (!fstype_matches(mtcur->mnt_type, fstype)) | 2343 | if (!fstype_matches(mtcur->mnt_type, fstype)) |
@@ -2417,7 +2417,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2417 | // fstab must have "users" or "user" | 2417 | // fstab must have "users" or "user" |
2418 | l = parse_mount_options(mtcur->mnt_opts, NULL); | 2418 | l = parse_mount_options(mtcur->mnt_opts, NULL); |
2419 | if (!(l & MOUNT_USERS)) | 2419 | if (!(l & MOUNT_USERS)) |
2420 | bb_error_msg_and_die(bb_msg_you_must_be_root); | 2420 | bb_simple_error_msg_and_die(bb_msg_you_must_be_root); |
2421 | } | 2421 | } |
2422 | 2422 | ||
2423 | //util-linux-2.12 does not do this check. | 2423 | //util-linux-2.12 does not do this check. |
diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c index 4eeaa9f3e..304f2d748 100644 --- a/util-linux/nsenter.c +++ b/util-linux/nsenter.c | |||
@@ -257,7 +257,7 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv) | |||
257 | 257 | ||
258 | if (opts & OPT_setgid) { | 258 | if (opts & OPT_setgid) { |
259 | if (setgroups(0, NULL) < 0 && setgroups_failed) | 259 | if (setgroups(0, NULL) < 0 && setgroups_failed) |
260 | bb_perror_msg_and_die("setgroups"); | 260 | bb_simple_perror_msg_and_die("setgroups"); |
261 | xsetgid(gid); | 261 | xsetgid(gid); |
262 | } | 262 | } |
263 | if (opts & OPT_setuid) | 263 | if (opts & OPT_setuid) |
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index 70f829e7f..41aade5ea 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c | |||
@@ -33,7 +33,7 @@ enum { RFC_868_BIAS = 2208988800UL }; | |||
33 | 33 | ||
34 | static void socket_timeout(int sig UNUSED_PARAM) | 34 | static void socket_timeout(int sig UNUSED_PARAM) |
35 | { | 35 | { |
36 | bb_error_msg_and_die("timeout connecting to time server"); | 36 | bb_simple_error_msg_and_die("timeout connecting to time server"); |
37 | } | 37 | } |
38 | 38 | ||
39 | static time_t askremotedate(const char *host) | 39 | static time_t askremotedate(const char *host) |
@@ -94,10 +94,10 @@ int rdate_main(int argc UNUSED_PARAM, char **argv) | |||
94 | 94 | ||
95 | if (!(flags & 2)) { /* no -p (-s may be present) */ | 95 | if (!(flags & 2)) { /* no -p (-s may be present) */ |
96 | if (time(NULL) == remote_time) | 96 | if (time(NULL) == remote_time) |
97 | bb_error_msg("current time matches remote time"); | 97 | bb_simple_error_msg("current time matches remote time"); |
98 | else | 98 | else |
99 | if (stime(&remote_time) < 0) | 99 | if (stime(&remote_time) < 0) |
100 | bb_perror_msg_and_die("can't set time of day"); | 100 | bb_simple_perror_msg_and_die("can't set time of day"); |
101 | } | 101 | } |
102 | 102 | ||
103 | if (flags != 1) /* not lone -s */ | 103 | if (flags != 1) /* not lone -s */ |
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c index cab2c4319..c4ea374be 100644 --- a/util-linux/readprofile.c +++ b/util-linux/readprofile.c | |||
@@ -142,7 +142,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv) | |||
142 | small++; | 142 | small++; |
143 | } | 143 | } |
144 | if (big > small) { | 144 | if (big > small) { |
145 | bb_error_msg("assuming reversed byte order, " | 145 | bb_simple_error_msg("assuming reversed byte order, " |
146 | "use -n to force native byte order"); | 146 | "use -n to force native byte order"); |
147 | BUILD_BUG_ON(sizeof(*p) > 8); | 147 | BUILD_BUG_ON(sizeof(*p) > 8); |
148 | for (p = buf; p < buf+len; p++) { | 148 | for (p = buf; p < buf+len; p++) { |
@@ -204,7 +204,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv) | |||
204 | } | 204 | } |
205 | 205 | ||
206 | if (indx >= len) | 206 | if (indx >= len) |
207 | bb_error_msg_and_die("profile address out of range. " | 207 | bb_simple_error_msg_and_die("profile address out of range. " |
208 | "Wrong map file?"); | 208 | "Wrong map file?"); |
209 | 209 | ||
210 | this = 0; | 210 | this = 0; |
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c index 29c440b82..cad0f9d64 100644 --- a/util-linux/rtcwake.c +++ b/util-linux/rtcwake.c | |||
@@ -230,7 +230,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
230 | do { | 230 | do { |
231 | ssize_t ret = safe_read(fd, &data, sizeof(data)); | 231 | ssize_t ret = safe_read(fd, &data, sizeof(data)); |
232 | if (ret < 0) { | 232 | if (ret < 0) { |
233 | bb_perror_msg("rtc read"); | 233 | bb_simple_perror_msg("rtc read"); |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | } while (!(data & RTC_AF)); | 236 | } while (!(data & RTC_AF)); |
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c index b69b8cbb6..e5cf96957 100644 --- a/util-linux/setpriv.c +++ b/util-linux/setpriv.c | |||
@@ -164,7 +164,7 @@ static void set_inh_caps(char *capstring) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | if (capset(&caps.header, caps.data) != 0) | 166 | if (capset(&caps.header, caps.data) != 0) |
167 | bb_perror_msg_and_die("capset"); | 167 | bb_simple_perror_msg_and_die("capset"); |
168 | } | 168 | } |
169 | 169 | ||
170 | static void set_ambient_caps(char *string) | 170 | static void set_ambient_caps(char *string) |
@@ -178,10 +178,10 @@ static void set_ambient_caps(char *string) | |||
178 | idx = parse_cap(cap); | 178 | idx = parse_cap(cap); |
179 | if (cap[0] == '+') { | 179 | if (cap[0] == '+') { |
180 | if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, idx, 0, 0) < 0) | 180 | if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, idx, 0, 0) < 0) |
181 | bb_perror_msg("cap_ambient_raise"); | 181 | bb_simple_perror_msg("cap_ambient_raise"); |
182 | } else { | 182 | } else { |
183 | if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, idx, 0, 0) < 0) | 183 | if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, idx, 0, 0) < 0) |
184 | bb_perror_msg("cap_ambient_lower"); | 184 | bb_simple_perror_msg("cap_ambient_lower"); |
185 | } | 185 | } |
186 | cap = strtok(NULL, ","); | 186 | cap = strtok(NULL, ","); |
187 | } | 187 | } |
@@ -236,7 +236,7 @@ static int dump(void) | |||
236 | unsigned idx = CAP_TO_INDEX(i); | 236 | unsigned idx = CAP_TO_INDEX(i); |
237 | if (idx >= caps.u32s) { | 237 | if (idx >= caps.u32s) { |
238 | printf("\nindex: %u u32s: %u capability: %u\n", idx, caps.u32s, i); | 238 | printf("\nindex: %u u32s: %u capability: %u\n", idx, caps.u32s, i); |
239 | bb_error_msg_and_die("unsupported capability"); | 239 | bb_simple_error_msg_and_die("unsupported capability"); |
240 | } | 240 | } |
241 | if (caps.data[idx].inheritable & CAP_TO_MASK(i)) { | 241 | if (caps.data[idx].inheritable & CAP_TO_MASK(i)) { |
242 | printf_cap(fmt, i); | 242 | printf_cap(fmt, i); |
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index ae9d412d1..a483893ed 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c | |||
@@ -117,7 +117,7 @@ static void drop_capset(int cap_idx) | |||
117 | getcaps(&caps); | 117 | getcaps(&caps); |
118 | caps.data[CAP_TO_INDEX(cap_idx)].inheritable &= ~CAP_TO_MASK(cap_idx); | 118 | caps.data[CAP_TO_INDEX(cap_idx)].inheritable &= ~CAP_TO_MASK(cap_idx); |
119 | if (capset(&caps.header, caps.data) != 0) | 119 | if (capset(&caps.header, caps.data) != 0) |
120 | bb_perror_msg_and_die("capset"); | 120 | bb_simple_perror_msg_and_die("capset"); |
121 | } | 121 | } |
122 | 122 | ||
123 | static void drop_bounding_set(int cap_idx) | 123 | static void drop_bounding_set(int cap_idx) |
@@ -253,7 +253,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv) | |||
253 | if ((unsigned)stfs.f_type != RAMFS_MAGIC | 253 | if ((unsigned)stfs.f_type != RAMFS_MAGIC |
254 | && (unsigned)stfs.f_type != TMPFS_MAGIC | 254 | && (unsigned)stfs.f_type != TMPFS_MAGIC |
255 | ) { | 255 | ) { |
256 | bb_error_msg_and_die("root filesystem is not ramfs/tmpfs"); | 256 | bb_simple_error_msg_and_die("root filesystem is not ramfs/tmpfs"); |
257 | } | 257 | } |
258 | 258 | ||
259 | if (!dry_run) { | 259 | if (!dry_run) { |
@@ -263,7 +263,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv) | |||
263 | // Overmount / with newdir and chroot into it | 263 | // Overmount / with newdir and chroot into it |
264 | if (mount(".", "/", NULL, MS_MOVE, NULL)) { | 264 | if (mount(".", "/", NULL, MS_MOVE, NULL)) { |
265 | // For example, fails when newroot is not a mountpoint | 265 | // For example, fails when newroot is not a mountpoint |
266 | bb_perror_msg_and_die("error moving root"); | 266 | bb_simple_perror_msg_and_die("error moving root"); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | xchroot("."); | 269 | xchroot("."); |
diff --git a/util-linux/uevent.c b/util-linux/uevent.c index 761743f45..7a1d7d4a7 100644 --- a/util-linux/uevent.c +++ b/util-linux/uevent.c | |||
@@ -46,37 +46,19 @@ enum { RCVBUF = 2 * 1024 * 1024 }; | |||
46 | int uevent_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 46 | int uevent_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
47 | int uevent_main(int argc UNUSED_PARAM, char **argv) | 47 | int uevent_main(int argc UNUSED_PARAM, char **argv) |
48 | { | 48 | { |
49 | struct sockaddr_nl sa; | ||
50 | int fd; | 49 | int fd; |
51 | 50 | ||
52 | INIT_G(); | 51 | INIT_G(); |
53 | 52 | ||
54 | argv++; | 53 | argv++; |
55 | 54 | ||
56 | // Subscribe for UEVENT kernel messages | 55 | // Subscribe for UEVENT kernel messages. |
57 | sa.nl_family = AF_NETLINK; | ||
58 | sa.nl_pad = 0; | ||
59 | sa.nl_pid = getpid(); | ||
60 | sa.nl_groups = 1 << 0; | ||
61 | fd = xsocket(AF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); | ||
62 | xbind(fd, (struct sockaddr *) &sa, sizeof(sa)); | ||
63 | close_on_exec_on(fd); | ||
64 | |||
65 | // Without a sufficiently big RCVBUF, a ton of simultaneous events | 56 | // Without a sufficiently big RCVBUF, a ton of simultaneous events |
66 | // can trigger ENOBUFS on read, which is unrecoverable. | 57 | // can trigger ENOBUFS on read, which is unrecoverable. |
67 | // Reproducer: | 58 | // Reproducer: |
68 | // uevent mdev & | 59 | // uevent mdev & |
69 | // find /sys -name uevent -exec sh -c 'echo add >"{}"' ';' | 60 | // find /sys -name uevent -exec sh -c 'echo add >"{}"' ';' |
70 | // | 61 | fd = create_and_bind_to_netlink(NETLINK_KOBJECT_UEVENT, /*groups:*/ 1 << 0, RCVBUF); |
71 | // SO_RCVBUFFORCE (root only) can go above net.core.rmem_max sysctl | ||
72 | setsockopt_SOL_SOCKET_int(fd, SO_RCVBUF, RCVBUF); | ||
73 | setsockopt_SOL_SOCKET_int(fd, SO_RCVBUFFORCE, RCVBUF); | ||
74 | if (0) { | ||
75 | int z; | ||
76 | socklen_t zl = sizeof(z); | ||
77 | getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &z, &zl); | ||
78 | bb_error_msg("SO_RCVBUF:%d", z); | ||
79 | } | ||
80 | 62 | ||
81 | for (;;) { | 63 | for (;;) { |
82 | char *netbuf; | 64 | char *netbuf; |
@@ -93,12 +75,12 @@ int uevent_main(int argc UNUSED_PARAM, char **argv) | |||
93 | MAP_PRIVATE | MAP_ANON, | 75 | MAP_PRIVATE | MAP_ANON, |
94 | /* ignored: */ -1, 0); | 76 | /* ignored: */ -1, 0); |
95 | if (netbuf == MAP_FAILED) | 77 | if (netbuf == MAP_FAILED) |
96 | bb_perror_msg_and_die("mmap"); | 78 | bb_simple_perror_msg_and_die("mmap"); |
97 | 79 | ||
98 | // Here we block, possibly for a very long time | 80 | // Here we block, possibly for a very long time |
99 | len = safe_read(fd, netbuf, BUFFER_SIZE - 1); | 81 | len = safe_read(fd, netbuf, BUFFER_SIZE - 1); |
100 | if (len < 0) | 82 | if (len < 0) |
101 | bb_perror_msg_and_die("read"); | 83 | bb_simple_perror_msg_and_die("read"); |
102 | end = netbuf + len; | 84 | end = netbuf + len; |
103 | *end = '\0'; | 85 | *end = '\0'; |
104 | 86 | ||
@@ -118,14 +100,15 @@ int uevent_main(int argc UNUSED_PARAM, char **argv) | |||
118 | } | 100 | } |
119 | env[idx] = NULL; | 101 | env[idx] = NULL; |
120 | 102 | ||
121 | idx = 0; | 103 | if (argv[0]) { |
122 | while (env[idx]) | 104 | idx = 0; |
123 | putenv(env[idx++]); | 105 | while (env[idx]) |
124 | if (argv[0]) | 106 | putenv(env[idx++]); |
125 | spawn_and_wait(argv); | 107 | spawn_and_wait(argv); |
126 | idx = 0; | 108 | idx = 0; |
127 | while (env[idx]) | 109 | while (env[idx]) |
128 | bb_unsetenv(env[idx++]); | 110 | bb_unsetenv(env[idx++]); |
111 | } | ||
129 | munmap(netbuf, BUFFER_SIZE); | 112 | munmap(netbuf, BUFFER_SIZE); |
130 | } | 113 | } |
131 | 114 | ||
diff --git a/util-linux/unshare.c b/util-linux/unshare.c index 61fc71197..a943e7b03 100644 --- a/util-linux/unshare.c +++ b/util-linux/unshare.c | |||
@@ -239,7 +239,7 @@ int unshare_main(int argc UNUSED_PARAM, char **argv) | |||
239 | if (setgrp_str) { | 239 | if (setgrp_str) { |
240 | if (strcmp(setgrp_str, "allow") == 0) { | 240 | if (strcmp(setgrp_str, "allow") == 0) { |
241 | if (opts & OPT_map_root) { | 241 | if (opts & OPT_map_root) { |
242 | bb_error_msg_and_die( | 242 | bb_simple_error_msg_and_die( |
243 | "--setgroups=allow and --map-root-user " | 243 | "--setgroups=allow and --map-root-user " |
244 | "are mutually exclusive" | 244 | "are mutually exclusive" |
245 | ); | 245 | ); |