aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-10-13 14:37:51 +0100
committerRon Yorston <rmy@pobox.com>2021-10-13 14:37:51 +0100
commit0ecf1aea459571b48dc68ddc2b7b9265740fa960 (patch)
tree491d6184a44b8b525a4ca35759d622aecd7f6344 /util-linux
parent4859ddcb20616718efbea12c6bf8b27c469b68de (diff)
parentaaf3d5ba74c5da97ff80b61f30cb8dd225d39096 (diff)
downloadbusybox-w32-0ecf1aea459571b48dc68ddc2b7b9265740fa960.tar.gz
busybox-w32-0ecf1aea459571b48dc68ddc2b7b9265740fa960.tar.bz2
busybox-w32-0ecf1aea459571b48dc68ddc2b7b9265740fa960.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/chrt.c2
-rw-r--r--util-linux/fbset.c2
-rw-r--r--util-linux/fdisk_sun.c2
-rw-r--r--util-linux/hexdump_xxd.c51
-rw-r--r--util-linux/mdev.c10
-rw-r--r--util-linux/mount.c21
6 files changed, 59 insertions, 29 deletions
diff --git a/util-linux/chrt.c b/util-linux/chrt.c
index a8701b55f..6799abb2d 100644
--- a/util-linux/chrt.c
+++ b/util-linux/chrt.c
@@ -93,7 +93,7 @@ int chrt_main(int argc UNUSED_PARAM, char **argv)
93 unsigned opt; 93 unsigned opt;
94 struct sched_param sp; 94 struct sched_param sp;
95 char *pid_str; 95 char *pid_str;
96 char *priority = priority; /* for compiler */ 96 char *priority = NULL;
97 const char *current_new; 97 const char *current_new;
98 int policy = SCHED_RR; 98 int policy = SCHED_RR;
99 int ret; 99 int ret;
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index cc5413b40..41cc29f37 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -267,7 +267,7 @@ static void ss(uint32_t *x, uint32_t flag, char *buf, const char *what)
267 * vsync high 267 * vsync high
268 * endmode 268 * endmode
269 */ 269 */
270static int read_mode_db(struct fb_var_screeninfo *base, const char *fn, 270static NOINLINE int read_mode_db(struct fb_var_screeninfo *base, const char *fn,
271 const char *mode) 271 const char *mode)
272{ 272{
273 char *token[2], *p, *s; 273 char *token[2], *p, *s;
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 66e434833..5b7760e8c 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -403,7 +403,7 @@ verify_sun_cmp(int *a, int *b)
403 return -1; 403 return -1;
404} 404}
405 405
406static void 406static NOINLINE void
407verify_sun(void) 407verify_sun(void)
408{ 408{
409 unsigned starts[8], lens[8], start, stop; 409 unsigned starts[8], lens[8], start, stop;
diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c
index fe78f6242..76dada983 100644
--- a/util-linux/hexdump_xxd.c
+++ b/util-linux/hexdump_xxd.c
@@ -69,7 +69,7 @@
69#define OPT_c (1 << 7) 69#define OPT_c (1 << 7)
70#define OPT_o (1 << 8) 70#define OPT_o (1 << 8)
71 71
72static void reverse(unsigned opt, unsigned cols, const char *filename) 72static void reverse(unsigned opt, const char *filename)
73{ 73{
74 FILE *fp; 74 FILE *fp;
75 char *buf; 75 char *buf;
@@ -77,9 +77,9 @@ static void reverse(unsigned opt, unsigned cols, const char *filename)
77 fp = filename ? xfopen_for_read(filename) : stdin; 77 fp = filename ? xfopen_for_read(filename) : stdin;
78 78
79 while ((buf = xmalloc_fgetline(fp)) != NULL) { 79 while ((buf = xmalloc_fgetline(fp)) != NULL) {
80 char *p = buf; 80 char *p;
81 unsigned cnt = cols;
82 81
82 p = buf;
83 if (!(opt & OPT_p)) { 83 if (!(opt & OPT_p)) {
84 /* skip address */ 84 /* skip address */
85 while (isxdigit(*p)) p++; 85 while (isxdigit(*p)) p++;
@@ -92,9 +92,9 @@ static void reverse(unsigned opt, unsigned cols, const char *filename)
92 } 92 }
93 93
94 /* Process hex bytes optionally separated by whitespace */ 94 /* Process hex bytes optionally separated by whitespace */
95 do { 95 for (;;) {
96 uint8_t val, c; 96 uint8_t val, c;
97 97 nibble1:
98 p = skip_whitespace(p); 98 p = skip_whitespace(p);
99 99
100 c = *p++; 100 c = *p++;
@@ -102,8 +102,19 @@ static void reverse(unsigned opt, unsigned cols, const char *filename)
102 val = c - '0'; 102 val = c - '0';
103 else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') 103 else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
104 val = (c|0x20) - ('a' - 10); 104 val = (c|0x20) - ('a' - 10);
105 else 105 else {
106 /* xxd V1.10 is inconsistent here.
107 * echo -e "31 !3 0a 0a" | xxd -r -p
108 * is "10<a0>" (no <cr>) - "!" is ignored,
109 * but
110 * echo -e "31 !!343434\n30 0a" | xxd -r -p
111 * is "10<cr>" - "!!" drops rest of the line.
112 * We will ignore all invalid chars:
113 */
114 if (c != '\0')
115 goto nibble1;
106 break; 116 break;
117 }
107 val <<= 4; 118 val <<= 4;
108 119
109 /* Works the same with xxd V1.10: 120 /* Works the same with xxd V1.10:
@@ -111,6 +122,7 @@ static void reverse(unsigned opt, unsigned cols, const char *filename)
111 * echo "31 0 9 32 0a" | xxd -r -p 122 * echo "31 0 9 32 0a" | xxd -r -p
112 * thus allow whitespace even within the byte: 123 * thus allow whitespace even within the byte:
113 */ 124 */
125 nibble2:
114 p = skip_whitespace(p); 126 p = skip_whitespace(p);
115 127
116 c = *p++; 128 c = *p++;
@@ -118,10 +130,23 @@ static void reverse(unsigned opt, unsigned cols, const char *filename)
118 val |= c - '0'; 130 val |= c - '0';
119 else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') 131 else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
120 val |= (c|0x20) - ('a' - 10); 132 val |= (c|0x20) - ('a' - 10);
121 else 133 else {
122 break; 134 if (c != '\0') {
135 /* "...3<not_hex_char>..." ignores both chars */
136 goto nibble1;
137 }
138 /* Nibbles can join even through newline:
139 * echo -e "31 3\n2 0a" | xxd -r -p
140 * is "12<cr>".
141 */
142 free(buf);
143 p = buf = xmalloc_fgetline(fp);
144 if (!buf)
145 break;
146 goto nibble2;
147 }
123 putchar(val); 148 putchar(val);
124 } while (!(opt & OPT_p) || --cnt != 0); 149 }
125 free(buf); 150 free(buf);
126 } 151 }
127 //fclose(fp); 152 //fclose(fp);
@@ -174,6 +199,10 @@ int xxd_main(int argc UNUSED_PARAM, char **argv)
174 //BUGGY for /proc/version (unseekable?) 199 //BUGGY for /proc/version (unseekable?)
175 } 200 }
176 201
202 if (opt & OPT_r) {
203 reverse(opt, argv[0]);
204 }
205
177 if (opt & OPT_o) { 206 if (opt & OPT_o) {
178 /* -o accepts negative numbers too */ 207 /* -o accepts negative numbers too */
179 dumper->xxd_displayoff = xstrtoll(opt_o, /*base:*/ 0); 208 dumper->xxd_displayoff = xstrtoll(opt_o, /*base:*/ 0);
@@ -194,10 +223,6 @@ int xxd_main(int argc UNUSED_PARAM, char **argv)
194 bb_dump_add(dumper, "\"%08.8_ax: \""); // "address: " 223 bb_dump_add(dumper, "\"%08.8_ax: \""); // "address: "
195 } 224 }
196 225
197 if (opt & OPT_r) {
198 reverse(opt, cols, argv[0]);
199 }
200
201 if (bytes < 1 || bytes >= cols) { 226 if (bytes < 1 || bytes >= cols) {
202 sprintf(buf, "%u/1 \"%%02x\"", cols); // cols * "XX" 227 sprintf(buf, "%u/1 \"%%02x\"", cols); // cols * "XX"
203 bb_dump_add(dumper, buf); 228 bb_dump_add(dumper, buf);
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index dbbcbc655..ebdc0c254 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -82,12 +82,12 @@
82//usage:#define mdev_trivial_usage 82//usage:#define mdev_trivial_usage
83//usage: "[-vS] " IF_FEATURE_MDEV_DAEMON("{ ") "[-s]" IF_FEATURE_MDEV_DAEMON(" | [-df] }") 83//usage: "[-vS] " IF_FEATURE_MDEV_DAEMON("{ ") "[-s]" IF_FEATURE_MDEV_DAEMON(" | [-df] }")
84//usage:#define mdev_full_usage "\n\n" 84//usage:#define mdev_full_usage "\n\n"
85//usage: " -v verbose\n" 85//usage: " -v Verbose\n"
86//usage: " -S log to syslog too\n" 86//usage: " -S Log to syslog too\n"
87//usage: " -s scan /sys and populate /dev\n" 87//usage: " -s Scan /sys and populate /dev\n"
88//usage: IF_FEATURE_MDEV_DAEMON( 88//usage: IF_FEATURE_MDEV_DAEMON(
89//usage: " -d daemon, listen on netlink\n" 89//usage: " -d Daemon, listen on netlink\n"
90//usage: " -f stay in foreground\n" 90//usage: " -f Run in foreground\n"
91//usage: ) 91//usage: )
92//usage: "\n" 92//usage: "\n"
93//usage: "Bare mdev is a kernel hotplug helper. To activate it:\n" 93//usage: "Bare mdev is a kernel hotplug helper. To activate it:\n"
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 44afdbcff..4e65b6b46 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -589,7 +589,7 @@ static void append_mount_options(char **oldopts, const char *newopts)
589 589
590// Use the mount_options list to parse options into flags. 590// Use the mount_options list to parse options into flags.
591// Also update list of unrecognized options if unrecognized != NULL 591// Also update list of unrecognized options if unrecognized != NULL
592static unsigned long parse_mount_options(char *options, char **unrecognized) 592static unsigned long parse_mount_options(char *options, char **unrecognized, uint32_t *opt)
593{ 593{
594 unsigned long flags = MS_SILENT; 594 unsigned long flags = MS_SILENT;
595 595
@@ -617,6 +617,11 @@ static unsigned long parse_mount_options(char *options, char **unrecognized)
617 flags &= fl; 617 flags &= fl;
618 else 618 else
619 flags |= fl; 619 flags |= fl;
620 /* If we see "-o rw" on command line, it's the same as -w:
621 * "do not try to fall back to RO mounts"
622 */
623 if (fl == ~MS_RDONLY && opt)
624 (*opt) |= OPT_w;
620 goto found; 625 goto found;
621 } 626 }
622 option_str += opt_len + 1; 627 option_str += opt_len + 1;
@@ -1973,7 +1978,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1973 1978
1974 errno = 0; 1979 errno = 0;
1975 1980
1976 vfsflags = parse_mount_options(mp->mnt_opts, &filteropts); 1981 vfsflags = parse_mount_options(mp->mnt_opts, &filteropts, NULL);
1977 1982
1978 // Treat fstype "auto" as unspecified 1983 // Treat fstype "auto" as unspecified
1979 if (mp->mnt_type && strcmp(mp->mnt_type, "auto") == 0) 1984 if (mp->mnt_type && strcmp(mp->mnt_type, "auto") == 0)
@@ -2047,7 +2052,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
2047 len, share, 2052 len, share,
2048 share + len + 1 /* "dir1/dir2" */ 2053 share + len + 1 /* "dir1/dir2" */
2049 ); 2054 );
2050 parse_mount_options(unc, &filteropts); 2055 parse_mount_options(unc, &filteropts, NULL);
2051 if (ENABLE_FEATURE_CLEAN_UP) free(unc); 2056 if (ENABLE_FEATURE_CLEAN_UP) free(unc);
2052 } 2057 }
2053 2058
@@ -2073,7 +2078,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
2073// (instead of _numeric_ iface_id) with glibc. 2078// (instead of _numeric_ iface_id) with glibc.
2074// This probably should be fixed in glibc, not here. 2079// This probably should be fixed in glibc, not here.
2075// The workaround is to manually specify correct "ip=ADDR%n" option. 2080// The workaround is to manually specify correct "ip=ADDR%n" option.
2076 parse_mount_options(ip, &filteropts); 2081 parse_mount_options(ip, &filteropts, NULL);
2077 if (ENABLE_FEATURE_CLEAN_UP) free(ip); 2082 if (ENABLE_FEATURE_CLEAN_UP) free(ip);
2078 } 2083 }
2079 2084
@@ -2355,7 +2360,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
2355 // Past this point, we are handling either "mount -a [opts]" 2360 // Past this point, we are handling either "mount -a [opts]"
2356 // or "mount [opts] single_param" 2361 // or "mount [opts] single_param"
2357 2362
2358 cmdopt_flags = parse_mount_options(cmdopts, NULL); 2363 cmdopt_flags = parse_mount_options(cmdopts, NULL, &option_mask32);
2359 if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags 2364 if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags
2360 bb_simple_error_msg_and_die(bb_msg_you_must_be_root); 2365 bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
2361 2366
@@ -2429,7 +2434,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
2429 continue; 2434 continue;
2430 2435
2431 // Skip noauto and swap anyway 2436 // Skip noauto and swap anyway
2432 if ((parse_mount_options(mtcur->mnt_opts, NULL) & (MOUNT_NOAUTO | MOUNT_SWAP)) 2437 if ((parse_mount_options(mtcur->mnt_opts, NULL, NULL) & (MOUNT_NOAUTO | MOUNT_SWAP))
2433 // swap is bogus "fstype", parse_mount_options can't check fstypes 2438 // swap is bogus "fstype", parse_mount_options can't check fstypes
2434 || strcasecmp(mtcur->mnt_type, "swap") == 0 2439 || strcasecmp(mtcur->mnt_type, "swap") == 0
2435 ) { 2440 ) {
@@ -2490,7 +2495,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
2490 // exit_group(32) = ? 2495 // exit_group(32) = ?
2491#if 0 2496#if 0
2492 // In case we want to simply skip swap partitions: 2497 // In case we want to simply skip swap partitions:
2493 l = parse_mount_options(mtcur->mnt_opts, NULL); 2498 l = parse_mount_options(mtcur->mnt_opts, NULL, NULL);
2494 if ((l & MOUNT_SWAP) 2499 if ((l & MOUNT_SWAP)
2495 // swap is bogus "fstype", parse_mount_options can't check fstypes 2500 // swap is bogus "fstype", parse_mount_options can't check fstypes
2496 || strcasecmp(mtcur->mnt_type, "swap") == 0 2501 || strcasecmp(mtcur->mnt_type, "swap") == 0
@@ -2500,7 +2505,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
2500#endif 2505#endif
2501 if (nonroot) { 2506 if (nonroot) {
2502 // fstab must have "users" or "user" 2507 // fstab must have "users" or "user"
2503 l = parse_mount_options(mtcur->mnt_opts, NULL); 2508 l = parse_mount_options(mtcur->mnt_opts, NULL, NULL);
2504 if (!(l & MOUNT_USERS)) 2509 if (!(l & MOUNT_USERS))
2505 bb_simple_error_msg_and_die(bb_msg_you_must_be_root); 2510 bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
2506 } 2511 }