diff options
author | Ron Yorston <rmy@pobox.com> | 2015-03-14 20:33:00 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-03-14 20:33:00 +0000 |
commit | a4f58436b78fe59e57620c6e0301f213ee25f273 (patch) | |
tree | 8355f724926e605280af2d6f2b1ccc6b1bd02dee /util-linux | |
parent | ba0c36cfcf84efbac6f89e27238e04bb57e9cd45 (diff) | |
parent | 49acc1a7618a28d34381cbb7661d7c981fcb238f (diff) | |
download | busybox-w32-a4f58436b78fe59e57620c6e0301f213ee25f273.tar.gz busybox-w32-a4f58436b78fe59e57620c6e0301f213ee25f273.tar.bz2 busybox-w32-a4f58436b78fe59e57620c6e0301f213ee25f273.zip |
Merge branch 'busybox' into merge
Conflicts:
coreutils/od_bloaty.c
libbb/lineedit.c
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/Config.src | 88 | ||||
-rw-r--r-- | util-linux/acpid.c | 10 | ||||
-rw-r--r-- | util-linux/fdisk.c | 6 | ||||
-rw-r--r-- | util-linux/fdisk_osf.c | 2 | ||||
-rw-r--r-- | util-linux/fdisk_sgi.c | 2 | ||||
-rw-r--r-- | util-linux/findfs.c | 2 | ||||
-rw-r--r-- | util-linux/fstrim.c | 2 | ||||
-rw-r--r-- | util-linux/hwclock.c | 2 | ||||
-rw-r--r-- | util-linux/mdev.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 124 | ||||
-rw-r--r-- | util-linux/rdate.c | 8 | ||||
-rw-r--r-- | util-linux/rtcwake.c | 14 | ||||
-rw-r--r-- | util-linux/swaponoff.c | 18 | ||||
-rw-r--r-- | util-linux/volume_id/get_devname.c | 4 |
14 files changed, 152 insertions, 132 deletions
diff --git a/util-linux/Config.src b/util-linux/Config.src index c1cd6daa4..854b3682e 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src | |||
@@ -434,94 +434,6 @@ config MORE | |||
434 | you will probably find this utility very helpful. If you don't have | 434 | you will probably find this utility very helpful. If you don't have |
435 | any need to reading text files, you can leave this disabled. | 435 | any need to reading text files, you can leave this disabled. |
436 | 436 | ||
437 | config MOUNT | ||
438 | bool "mount" | ||
439 | default y | ||
440 | select PLATFORM_LINUX | ||
441 | help | ||
442 | All files and filesystems in Unix are arranged into one big directory | ||
443 | tree. The 'mount' utility is used to graft a filesystem onto a | ||
444 | particular part of the tree. A filesystem can either live on a block | ||
445 | device, or it can be accessible over the network, as is the case with | ||
446 | NFS filesystems. Most people using BusyBox will also want to enable | ||
447 | the 'mount' utility. | ||
448 | |||
449 | config FEATURE_MOUNT_FAKE | ||
450 | bool "Support option -f" | ||
451 | default y | ||
452 | depends on MOUNT | ||
453 | help | ||
454 | Enable support for faking a file system mount. | ||
455 | |||
456 | config FEATURE_MOUNT_VERBOSE | ||
457 | bool "Support option -v" | ||
458 | default y | ||
459 | depends on MOUNT | ||
460 | help | ||
461 | Enable multi-level -v[vv...] verbose messages. Useful if you | ||
462 | debug mount problems and want to see what is exactly passed | ||
463 | to the kernel. | ||
464 | |||
465 | config FEATURE_MOUNT_HELPERS | ||
466 | bool "Support mount helpers" | ||
467 | default n | ||
468 | depends on MOUNT | ||
469 | help | ||
470 | Enable mounting of virtual file systems via external helpers. | ||
471 | E.g. "mount obexfs#-b00.11.22.33.44.55 /mnt" will in effect call | ||
472 | "obexfs -b00.11.22.33.44.55 /mnt" | ||
473 | Also "mount -t sometype [-o opts] fs /mnt" will try | ||
474 | "sometype [-o opts] fs /mnt" if simple mount syscall fails. | ||
475 | The idea is to use such virtual filesystems in /etc/fstab. | ||
476 | |||
477 | config FEATURE_MOUNT_LABEL | ||
478 | bool "Support specifying devices by label or UUID" | ||
479 | default y | ||
480 | depends on MOUNT | ||
481 | select VOLUMEID | ||
482 | help | ||
483 | This allows for specifying a device by label or uuid, rather than by | ||
484 | name. This feature utilizes the same functionality as blkid/findfs. | ||
485 | This also enables label or uuid support for swapon. | ||
486 | |||
487 | config FEATURE_MOUNT_NFS | ||
488 | bool "Support mounting NFS file systems on Linux < 2.6.23" | ||
489 | default n | ||
490 | depends on MOUNT | ||
491 | select FEATURE_HAVE_RPC | ||
492 | select FEATURE_SYSLOG | ||
493 | help | ||
494 | Enable mounting of NFS file systems on Linux kernels prior | ||
495 | to version 2.6.23. Note that in this case mounting of NFS | ||
496 | over IPv6 will not be possible. | ||
497 | |||
498 | Note that this option links in RPC support from libc, | ||
499 | which is rather large (~10 kbytes on uclibc). | ||
500 | |||
501 | config FEATURE_MOUNT_CIFS | ||
502 | bool "Support mounting CIFS/SMB file systems" | ||
503 | default y | ||
504 | depends on MOUNT | ||
505 | help | ||
506 | Enable support for samba mounts. | ||
507 | |||
508 | config FEATURE_MOUNT_FLAGS | ||
509 | depends on MOUNT | ||
510 | bool "Support lots of -o flags in mount" | ||
511 | default y | ||
512 | help | ||
513 | Without this, mount only supports ro/rw/remount. With this, it | ||
514 | supports nosuid, suid, dev, nodev, exec, noexec, sync, async, atime, | ||
515 | noatime, diratime, nodiratime, loud, bind, move, shared, slave, | ||
516 | private, unbindable, rshared, rslave, rprivate, and runbindable. | ||
517 | |||
518 | config FEATURE_MOUNT_FSTAB | ||
519 | depends on MOUNT | ||
520 | bool "Support /etc/fstab and -a" | ||
521 | default y | ||
522 | help | ||
523 | Support mount all and looking for files in /etc/fstab. | ||
524 | |||
525 | config PIVOT_ROOT | 437 | config PIVOT_ROOT |
526 | bool "pivot_root" | 438 | bool "pivot_root" |
527 | default y | 439 | default y |
diff --git a/util-linux/acpid.c b/util-linux/acpid.c index 38421c2d7..0f2cb6bdc 100644 --- a/util-linux/acpid.c +++ b/util-linux/acpid.c | |||
@@ -121,10 +121,8 @@ static void process_event(const char *event) | |||
121 | char *handler = xasprintf("./%s", event); | 121 | char *handler = xasprintf("./%s", event); |
122 | const char *args[] = { "run-parts", handler, NULL }; | 122 | const char *args[] = { "run-parts", handler, NULL }; |
123 | 123 | ||
124 | // debug info | 124 | // log the event |
125 | if (option_mask32 & OPT_d) { | 125 | bb_error_msg("%s", event); |
126 | bb_error_msg("%s", event); | ||
127 | } | ||
128 | 126 | ||
129 | // spawn handler | 127 | // spawn handler |
130 | // N.B. run-parts would require scripts to have #!/bin/sh | 128 | // N.B. run-parts would require scripts to have #!/bin/sh |
@@ -153,7 +151,7 @@ static const char *find_action(struct input_event *ev, const char *buf) | |||
153 | } | 151 | } |
154 | 152 | ||
155 | if (buf) { | 153 | if (buf) { |
156 | if (strncmp(buf, evt_tab[i].desc, strlen(buf)) == 0) { | 154 | if (is_prefixed_with(evt_tab[i].desc, buf)) { |
157 | action = evt_tab[i].desc; | 155 | action = evt_tab[i].desc; |
158 | break; | 156 | break; |
159 | } | 157 | } |
@@ -256,7 +254,7 @@ int acpid_main(int argc UNUSED_PARAM, char **argv) | |||
256 | /* No -d "Debug", we log to log file. | 254 | /* No -d "Debug", we log to log file. |
257 | * This includes any output from children. | 255 | * This includes any output from children. |
258 | */ | 256 | */ |
259 | xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_TRUNC), STDOUT_FILENO); | 257 | xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_APPEND), STDOUT_FILENO); |
260 | xdup2(STDOUT_FILENO, STDERR_FILENO); | 258 | xdup2(STDOUT_FILENO, STDERR_FILENO); |
261 | /* Also, acpid's messages (but not children) will go to syslog too */ | 259 | /* Also, acpid's messages (but not children) will go to syslog too */ |
262 | openlog(applet_name, LOG_PID, LOG_DAEMON); | 260 | openlog(applet_name, LOG_PID, LOG_DAEMON); |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 39eb27b47..7fe70fb72 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -2781,14 +2781,14 @@ is_ide_cdrom_or_tape(const char *device) | |||
2781 | the process hangs on the attempt to read a music CD. | 2781 | the process hangs on the attempt to read a music CD. |
2782 | So try to be careful. This only works since 2.1.73. */ | 2782 | So try to be careful. This only works since 2.1.73. */ |
2783 | 2783 | ||
2784 | if (strncmp("/dev/hd", device, 7)) | 2784 | if (!is_prefixed_with(device, "/dev/hd")) |
2785 | return 0; | 2785 | return 0; |
2786 | 2786 | ||
2787 | snprintf(buf, sizeof(buf), "/proc/ide/%s/media", device+5); | 2787 | snprintf(buf, sizeof(buf), "/proc/ide/%s/media", device+5); |
2788 | procf = fopen_for_read(buf); | 2788 | procf = fopen_for_read(buf); |
2789 | if (procf != NULL && fgets(buf, sizeof(buf), procf)) | 2789 | if (procf != NULL && fgets(buf, sizeof(buf), procf)) |
2790 | is_ide = (!strncmp(buf, "cdrom", 5) || | 2790 | is_ide = (is_prefixed_with(buf, "cdrom") || |
2791 | !strncmp(buf, "tape", 4)); | 2791 | is_prefixed_with(buf, "tape")); |
2792 | else | 2792 | else |
2793 | /* Now when this proc file does not exist, skip the | 2793 | /* Now when this proc file does not exist, skip the |
2794 | device when it is read-only. */ | 2794 | device when it is read-only. */ |
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index ff16389bd..af04cfcc8 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c | |||
@@ -854,7 +854,7 @@ xbsd_initlabel(struct partition *p) | |||
854 | 854 | ||
855 | d->d_magic = BSD_DISKMAGIC; | 855 | d->d_magic = BSD_DISKMAGIC; |
856 | 856 | ||
857 | if (strncmp(disk_device, "/dev/sd", 7) == 0) | 857 | if (is_prefixed_with(disk_device, "/dev/sd")) |
858 | d->d_type = BSD_DTYPE_SCSI; | 858 | d->d_type = BSD_DTYPE_SCSI; |
859 | else | 859 | else |
860 | d->d_type = BSD_DTYPE_ST506; | 860 | d->d_type = BSD_DTYPE_ST506; |
diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c index 785fc661b..23ebc56ef 100644 --- a/util-linux/fdisk_sgi.c +++ b/util-linux/fdisk_sgi.c | |||
@@ -440,7 +440,7 @@ sgi_write_table(void) | |||
440 | (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0); | 440 | (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0); |
441 | 441 | ||
442 | write_sector(0, sgilabel); | 442 | write_sector(0, sgilabel); |
443 | if (!strncmp((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8)) { | 443 | if (is_prefixed_with((char*)sgilabel->directory[0].vol_file_name, "sgilabel")) { |
444 | /* | 444 | /* |
445 | * keep this habit of first writing the "sgilabel". | 445 | * keep this habit of first writing the "sgilabel". |
446 | * I never tested whether it works without (AN 981002). | 446 | * I never tested whether it works without (AN 981002). |
diff --git a/util-linux/findfs.c b/util-linux/findfs.c index 49e8979ac..07734f359 100644 --- a/util-linux/findfs.c +++ b/util-linux/findfs.c | |||
@@ -27,7 +27,7 @@ int findfs_main(int argc UNUSED_PARAM, char **argv) | |||
27 | if (!dev) | 27 | if (!dev) |
28 | bb_show_usage(); | 28 | bb_show_usage(); |
29 | 29 | ||
30 | if (strncmp(dev, "/dev/", 5) == 0) { | 30 | if (is_prefixed_with(dev, "/dev/")) { |
31 | /* Just pass any /dev/xxx name right through. | 31 | /* Just pass any /dev/xxx name right through. |
32 | * This might aid in some scripts being able | 32 | * This might aid in some scripts being able |
33 | * to call this unconditionally */ | 33 | * to call this unconditionally */ |
diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c index 675a02184..51400ef0b 100644 --- a/util-linux/fstrim.c +++ b/util-linux/fstrim.c | |||
@@ -32,7 +32,7 @@ | |||
32 | //usage: " -o OFFSET Offset in bytes to discard from" | 32 | //usage: " -o OFFSET Offset in bytes to discard from" |
33 | //usage: "\n -l LEN Bytes to discard" | 33 | //usage: "\n -l LEN Bytes to discard" |
34 | //usage: "\n -m MIN Minimum extent length" | 34 | //usage: "\n -m MIN Minimum extent length" |
35 | //usage: "\n -v, Print number of discarded bytes" | 35 | //usage: "\n -v Print number of discarded bytes" |
36 | //usage: ) | 36 | //usage: ) |
37 | 37 | ||
38 | #include "libbb.h" | 38 | #include "libbb.h" |
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 3f531555b..6c99977cf 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c | |||
@@ -69,7 +69,7 @@ static void show_clock(const char **pp_rtcname, int utc) | |||
69 | strftime(cp, sizeof(cp), "%c", ptm); | 69 | strftime(cp, sizeof(cp), "%c", ptm); |
70 | #else | 70 | #else |
71 | char *cp = ctime(&t); | 71 | char *cp = ctime(&t); |
72 | strchrnul(cp, '\n')[0] = '\0'; | 72 | chomp(cp); |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | #if !SHOW_HWCLOCK_DIFF | 75 | #if !SHOW_HWCLOCK_DIFF |
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index b2d56575f..ccc00d365 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -610,7 +610,7 @@ static void make_device(char *device_name, char *path, int operation) | |||
610 | * We use strstr("/block/") to forestall future surprises. | 610 | * We use strstr("/block/") to forestall future surprises. |
611 | */ | 611 | */ |
612 | type = S_IFCHR; | 612 | type = S_IFCHR; |
613 | if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0)) | 613 | if (strstr(path, "/block/") || (G.subsystem && is_prefixed_with(G.subsystem, "block"))) |
614 | type = S_IFBLK; | 614 | type = S_IFBLK; |
615 | 615 | ||
616 | #if ENABLE_FEATURE_MDEV_CONF | 616 | #if ENABLE_FEATURE_MDEV_CONF |
diff --git a/util-linux/mount.c b/util-linux/mount.c index 62fd41fd7..cb40c802d 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -17,8 +17,103 @@ | |||
17 | // mount_it_now() does the actual mount. | 17 | // mount_it_now() does the actual mount. |
18 | // | 18 | // |
19 | 19 | ||
20 | //config:config MOUNT | ||
21 | //config: bool "mount" | ||
22 | //config: default y | ||
23 | //config: select PLATFORM_LINUX | ||
24 | //config: help | ||
25 | //config: All files and filesystems in Unix are arranged into one big directory | ||
26 | //config: tree. The 'mount' utility is used to graft a filesystem onto a | ||
27 | //config: particular part of the tree. A filesystem can either live on a block | ||
28 | //config: device, or it can be accessible over the network, as is the case with | ||
29 | //config: NFS filesystems. Most people using BusyBox will also want to enable | ||
30 | //config: the 'mount' utility. | ||
31 | //config: | ||
32 | //config:config FEATURE_MOUNT_FAKE | ||
33 | //config: bool "Support option -f" | ||
34 | //config: default y | ||
35 | //config: depends on MOUNT | ||
36 | //config: help | ||
37 | //config: Enable support for faking a file system mount. | ||
38 | //config: | ||
39 | //config:config FEATURE_MOUNT_VERBOSE | ||
40 | //config: bool "Support option -v" | ||
41 | //config: default y | ||
42 | //config: depends on MOUNT | ||
43 | //config: help | ||
44 | //config: Enable multi-level -v[vv...] verbose messages. Useful if you | ||
45 | //config: debug mount problems and want to see what is exactly passed | ||
46 | //config: to the kernel. | ||
47 | //config: | ||
48 | //config:config FEATURE_MOUNT_HELPERS | ||
49 | //config: bool "Support mount helpers" | ||
50 | //config: default n | ||
51 | //config: depends on MOUNT | ||
52 | //config: help | ||
53 | //config: Enable mounting of virtual file systems via external helpers. | ||
54 | //config: E.g. "mount obexfs#-b00.11.22.33.44.55 /mnt" will in effect call | ||
55 | //config: "obexfs -b00.11.22.33.44.55 /mnt" | ||
56 | //config: Also "mount -t sometype [-o opts] fs /mnt" will try | ||
57 | //config: "sometype [-o opts] fs /mnt" if simple mount syscall fails. | ||
58 | //config: The idea is to use such virtual filesystems in /etc/fstab. | ||
59 | //config: | ||
60 | //config:config FEATURE_MOUNT_LABEL | ||
61 | //config: bool "Support specifying devices by label or UUID" | ||
62 | //config: default y | ||
63 | //config: depends on MOUNT | ||
64 | //config: select VOLUMEID | ||
65 | //config: help | ||
66 | //config: This allows for specifying a device by label or uuid, rather than by | ||
67 | //config: name. This feature utilizes the same functionality as blkid/findfs. | ||
68 | //config: This also enables label or uuid support for swapon. | ||
69 | //config: | ||
70 | //config:config FEATURE_MOUNT_NFS | ||
71 | //config: bool "Support mounting NFS file systems on Linux < 2.6.23" | ||
72 | //config: default n | ||
73 | //config: depends on MOUNT | ||
74 | //config: select FEATURE_HAVE_RPC | ||
75 | //config: select FEATURE_SYSLOG | ||
76 | //config: help | ||
77 | //config: Enable mounting of NFS file systems on Linux kernels prior | ||
78 | //config: to version 2.6.23. Note that in this case mounting of NFS | ||
79 | //config: over IPv6 will not be possible. | ||
80 | //config: | ||
81 | //config: Note that this option links in RPC support from libc, | ||
82 | //config: which is rather large (~10 kbytes on uclibc). | ||
83 | //config: | ||
84 | //config:config FEATURE_MOUNT_CIFS | ||
85 | //config: bool "Support mounting CIFS/SMB file systems" | ||
86 | //config: default y | ||
87 | //config: depends on MOUNT | ||
88 | //config: help | ||
89 | //config: Enable support for samba mounts. | ||
90 | //config: | ||
91 | //config:config FEATURE_MOUNT_FLAGS | ||
92 | //config: depends on MOUNT | ||
93 | //config: bool "Support lots of -o flags in mount" | ||
94 | //config: default y | ||
95 | //config: help | ||
96 | //config: Without this, mount only supports ro/rw/remount. With this, it | ||
97 | //config: supports nosuid, suid, dev, nodev, exec, noexec, sync, async, atime, | ||
98 | //config: noatime, diratime, nodiratime, loud, bind, move, shared, slave, | ||
99 | //config: private, unbindable, rshared, rslave, rprivate, and runbindable. | ||
100 | //config: | ||
101 | //config:config FEATURE_MOUNT_FSTAB | ||
102 | //config: depends on MOUNT | ||
103 | //config: bool "Support /etc/fstab and -a" | ||
104 | //config: default y | ||
105 | //config: help | ||
106 | //config: Support mount all and looking for files in /etc/fstab. | ||
107 | //config: | ||
108 | //config:config FEATURE_MOUNT_OTHERTAB | ||
109 | //config: depends on FEATURE_MOUNT_FSTAB | ||
110 | //config: bool "Support -T <alt_fstab>" | ||
111 | //config: default y | ||
112 | //config: help | ||
113 | //config: Support mount -T (specifying an alternate fstab) | ||
114 | |||
20 | //usage:#define mount_trivial_usage | 115 | //usage:#define mount_trivial_usage |
21 | //usage: "[OPTIONS] [-o OPTS] DEVICE NODE" | 116 | //usage: "[OPTIONS] [-o OPT] DEVICE NODE" |
22 | //usage:#define mount_full_usage "\n\n" | 117 | //usage:#define mount_full_usage "\n\n" |
23 | //usage: "Mount a filesystem. Filesystem autodetection requires /proc.\n" | 118 | //usage: "Mount a filesystem. Filesystem autodetection requires /proc.\n" |
24 | //usage: "\n -a Mount all filesystems in fstab" | 119 | //usage: "\n -a Mount all filesystems in fstab" |
@@ -41,8 +136,11 @@ | |||
41 | //usage: ) | 136 | //usage: ) |
42 | ////usage: "\n -s Sloppy (ignored)" | 137 | ////usage: "\n -s Sloppy (ignored)" |
43 | //usage: "\n -r Read-only mount" | 138 | //usage: "\n -r Read-only mount" |
44 | //usage: "\n -w Read-write mount (default)" | 139 | ////usage: "\n -w Read-write mount (default)" |
45 | //usage: "\n -t FSTYPE[,...] Filesystem type(s)" | 140 | //usage: "\n -t FSTYPE[,...] Filesystem type(s)" |
141 | //usage: IF_FEATURE_MOUNT_OTHERTAB( | ||
142 | //usage: "\n -T FILE Read FILE instead of /etc/fstab" | ||
143 | //usage: ) | ||
46 | //usage: "\n -O OPT Mount only filesystems with option OPT (-a only)" | 144 | //usage: "\n -O OPT Mount only filesystems with option OPT (-a only)" |
47 | //usage: "\n-o OPT:" | 145 | //usage: "\n-o OPT:" |
48 | //usage: IF_FEATURE_MOUNT_LOOP( | 146 | //usage: IF_FEATURE_MOUNT_LOOP( |
@@ -64,7 +162,7 @@ | |||
64 | //usage: "\n move Relocate an existing mount point" | 162 | //usage: "\n move Relocate an existing mount point" |
65 | //usage: ) | 163 | //usage: ) |
66 | //usage: "\n remount Remount a mounted filesystem, changing flags" | 164 | //usage: "\n remount Remount a mounted filesystem, changing flags" |
67 | //usage: "\n ro/rw Same as -r/-w" | 165 | //usage: "\n ro Same as -r" |
68 | //usage: "\n" | 166 | //usage: "\n" |
69 | //usage: "\nThere are filesystem-specific -o flags." | 167 | //usage: "\nThere are filesystem-specific -o flags." |
70 | //usage: | 168 | //usage: |
@@ -167,7 +265,7 @@ enum { | |||
167 | }; | 265 | }; |
168 | 266 | ||
169 | 267 | ||
170 | #define OPTION_STR "o:t:rwanfvsiO:" | 268 | #define OPTION_STR "o:t:rwanfvsiO:" IF_FEATURE_MOUNT_OTHERTAB("T:") |
171 | enum { | 269 | enum { |
172 | OPT_o = (1 << 0), | 270 | OPT_o = (1 << 0), |
173 | OPT_t = (1 << 1), | 271 | OPT_t = (1 << 1), |
@@ -180,6 +278,7 @@ enum { | |||
180 | OPT_s = (1 << 8), | 278 | OPT_s = (1 << 8), |
181 | OPT_i = (1 << 9), | 279 | OPT_i = (1 << 9), |
182 | OPT_O = (1 << 10), | 280 | OPT_O = (1 << 10), |
281 | OPT_T = (1 << 11), | ||
183 | }; | 282 | }; |
184 | 283 | ||
185 | #if ENABLE_FEATURE_MTAB_SUPPORT | 284 | #if ENABLE_FEATURE_MTAB_SUPPORT |
@@ -542,7 +641,7 @@ static llist_t *get_block_backed_filesystems(void) | |||
542 | if (!f) continue; | 641 | if (!f) continue; |
543 | 642 | ||
544 | while ((buf = xmalloc_fgetline(f)) != NULL) { | 643 | while ((buf = xmalloc_fgetline(f)) != NULL) { |
545 | if (strncmp(buf, "nodev", 5) == 0 && isspace(buf[5])) | 644 | if (is_prefixed_with(buf, "nodev") && isspace(buf[5])) |
546 | goto next; | 645 | goto next; |
547 | fs = skip_whitespace(buf); | 646 | fs = skip_whitespace(buf); |
548 | if (*fs == '#' || *fs == '*' || !*fs) | 647 | if (*fs == '#' || *fs == '*' || !*fs) |
@@ -1265,9 +1364,9 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1265 | strcspn(opteq, " \t\n\r,")); | 1364 | strcspn(opteq, " \t\n\r,")); |
1266 | continue; | 1365 | continue; |
1267 | case 18: // "proto" | 1366 | case 18: // "proto" |
1268 | if (!strncmp(opteq, "tcp", 3)) | 1367 | if (is_prefixed_with(opteq, "tcp")) |
1269 | tcp = 1; | 1368 | tcp = 1; |
1270 | else if (!strncmp(opteq, "udp", 3)) | 1369 | else if (is_prefixed_with(opteq, "udp")) |
1271 | tcp = 0; | 1370 | tcp = 0; |
1272 | else | 1371 | else |
1273 | bb_error_msg("warning: unrecognized proto= option"); | 1372 | bb_error_msg("warning: unrecognized proto= option"); |
@@ -1360,7 +1459,7 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi | |||
1360 | "rdirplus\0" | 1459 | "rdirplus\0" |
1361 | "acl\0"; | 1460 | "acl\0"; |
1362 | int val = 1; | 1461 | int val = 1; |
1363 | if (!strncmp(opt, "no", 2)) { | 1462 | if (is_prefixed_with(opt, "no")) { |
1364 | val = 0; | 1463 | val = 0; |
1365 | opt += 2; | 1464 | opt += 2; |
1366 | } | 1465 | } |
@@ -1880,7 +1979,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1880 | } | 1979 | } |
1881 | 1980 | ||
1882 | // Might this be an NFS filesystem? | 1981 | // Might this be an NFS filesystem? |
1883 | if ((!mp->mnt_type || strncmp(mp->mnt_type, "nfs", 3) == 0) | 1982 | if ((!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs")) |
1884 | && strchr(mp->mnt_fsname, ':') != NULL | 1983 | && strchr(mp->mnt_fsname, ':') != NULL |
1885 | ) { | 1984 | ) { |
1886 | if (!mp->mnt_type) | 1985 | if (!mp->mnt_type) |
@@ -2034,7 +2133,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2034 | char *O_optmatch = NULL; | 2133 | char *O_optmatch = NULL; |
2035 | char *storage_path; | 2134 | char *storage_path; |
2036 | llist_t *lst_o = NULL; | 2135 | llist_t *lst_o = NULL; |
2037 | const char *fstabname; | 2136 | const char *fstabname = "/etc/fstab"; |
2038 | FILE *fstab; | 2137 | FILE *fstab; |
2039 | int i, j; | 2138 | int i, j; |
2040 | int rc = EXIT_SUCCESS; | 2139 | int rc = EXIT_SUCCESS; |
@@ -2061,6 +2160,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2061 | // Max 2 params; -o is a list, -v is a counter | 2160 | // Max 2 params; -o is a list, -v is a counter |
2062 | opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv"); | 2161 | opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv"); |
2063 | opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch | 2162 | opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch |
2163 | IF_FEATURE_MOUNT_OTHERTAB(, &fstabname) | ||
2064 | IF_FEATURE_MOUNT_VERBOSE(, &verbose)); | 2164 | IF_FEATURE_MOUNT_VERBOSE(, &verbose)); |
2065 | while (lst_o) append_mount_options(&cmdopts, llist_pop(&lst_o)); // -o | 2165 | while (lst_o) append_mount_options(&cmdopts, llist_pop(&lst_o)); // -o |
2066 | if (opt & OPT_r) append_mount_options(&cmdopts, "ro"); // -r | 2166 | if (opt & OPT_r) append_mount_options(&cmdopts, "ro"); // -r |
@@ -2128,8 +2228,10 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2128 | return rc; | 2228 | return rc; |
2129 | } | 2229 | } |
2130 | 2230 | ||
2231 | // A malicious user could overmount /usr without this. | ||
2232 | if (ENABLE_FEATURE_MOUNT_OTHERTAB && nonroot) | ||
2233 | fstabname = "/etc/fstab"; | ||
2131 | // Open either fstab or mtab | 2234 | // Open either fstab or mtab |
2132 | fstabname = "/etc/fstab"; | ||
2133 | if (cmdopt_flags & MS_REMOUNT) { | 2235 | if (cmdopt_flags & MS_REMOUNT) { |
2134 | // WARNING. I am not sure this matches util-linux's | 2236 | // WARNING. I am not sure this matches util-linux's |
2135 | // behavior. It's possible util-linux does not | 2237 | // behavior. It's possible util-linux does not |
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index 6e35cd519..8075ef6af 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c | |||
@@ -11,9 +11,9 @@ | |||
11 | //usage:#define rdate_trivial_usage | 11 | //usage:#define rdate_trivial_usage |
12 | //usage: "[-sp] HOST" | 12 | //usage: "[-sp] HOST" |
13 | //usage:#define rdate_full_usage "\n\n" | 13 | //usage:#define rdate_full_usage "\n\n" |
14 | //usage: "Get and possibly set the system date/time from a remote HOST\n" | 14 | //usage: "Get and possibly set system time from a remote HOST\n" |
15 | //usage: "\n -s Set the system date/time (default)" | 15 | //usage: "\n -s Set system time (default)" |
16 | //usage: "\n -p Print the date/time" | 16 | //usage: "\n -p Print time" |
17 | 17 | ||
18 | #include "libbb.h" | 18 | #include "libbb.h" |
19 | 19 | ||
@@ -36,7 +36,7 @@ static time_t askremotedate(const char *host) | |||
36 | fd = create_and_connect_stream_or_die(host, bb_lookup_port("time", "tcp", 37)); | 36 | fd = create_and_connect_stream_or_die(host, bb_lookup_port("time", "tcp", 37)); |
37 | 37 | ||
38 | if (safe_read(fd, &nett, 4) != 4) /* read time from server */ | 38 | if (safe_read(fd, &nett, 4) != 4) /* read time from server */ |
39 | bb_error_msg_and_die("%s did not send the complete time", host); | 39 | bb_error_msg_and_die("%s: %s", host, "short read"); |
40 | if (ENABLE_FEATURE_CLEAN_UP) | 40 | if (ENABLE_FEATURE_CLEAN_UP) |
41 | close(fd); | 41 | close(fd); |
42 | 42 | ||
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c index 33cdbfad4..8aee0cfcb 100644 --- a/util-linux/rtcwake.c +++ b/util-linux/rtcwake.c | |||
@@ -32,18 +32,18 @@ | |||
32 | //usage: "\n -l,--local Clock is set to local time" | 32 | //usage: "\n -l,--local Clock is set to local time" |
33 | //usage: "\n -u,--utc Clock is set to UTC time" | 33 | //usage: "\n -u,--utc Clock is set to UTC time" |
34 | //usage: "\n -d,--device=DEV Specify the RTC device" | 34 | //usage: "\n -d,--device=DEV Specify the RTC device" |
35 | //usage: "\n -m,--mode=MODE Set the sleep state (default: standby)" | 35 | //usage: "\n -m,--mode=MODE Set sleep state (default: standby)" |
36 | //usage: "\n -s,--seconds=SEC Set the timeout in SEC seconds from now" | 36 | //usage: "\n -s,--seconds=SEC Set timeout in SEC seconds from now" |
37 | //usage: "\n -t,--time=TIME Set the timeout to TIME seconds from epoch" | 37 | //usage: "\n -t,--time=TIME Set timeout to TIME seconds from epoch" |
38 | //usage: ) | 38 | //usage: ) |
39 | //usage: IF_NOT_LONG_OPTS( | 39 | //usage: IF_NOT_LONG_OPTS( |
40 | //usage: "\n -a Read clock mode from adjtime" | 40 | //usage: "\n -a Read clock mode from adjtime" |
41 | //usage: "\n -l Clock is set to local time" | 41 | //usage: "\n -l Clock is set to local time" |
42 | //usage: "\n -u Clock is set to UTC time" | 42 | //usage: "\n -u Clock is set to UTC time" |
43 | //usage: "\n -d DEV Specify the RTC device" | 43 | //usage: "\n -d DEV Specify the RTC device" |
44 | //usage: "\n -m MODE Set the sleep state (default: standby)" | 44 | //usage: "\n -m MODE Set sleep state (default: standby)" |
45 | //usage: "\n -s SEC Set the timeout in SEC seconds from now" | 45 | //usage: "\n -s SEC Set timeout in SEC seconds from now" |
46 | //usage: "\n -t TIME Set the timeout to TIME seconds from epoch" | 46 | //usage: "\n -t TIME Set timeout to TIME seconds from epoch" |
47 | //usage: ) | 47 | //usage: ) |
48 | 48 | ||
49 | #include "libbb.h" | 49 | #include "libbb.h" |
@@ -66,7 +66,7 @@ static NOINLINE bool may_wakeup(const char *rtcname) | |||
66 | return false; | 66 | return false; |
67 | 67 | ||
68 | /* wakeup events could be disabled or not supported */ | 68 | /* wakeup events could be disabled or not supported */ |
69 | return strncmp(buf, "enabled\n", 8) == 0; | 69 | return is_prefixed_with(buf, "enabled\n") != NULL; |
70 | } | 70 | } |
71 | 71 | ||
72 | static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time) | 72 | static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time) |
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 75487267b..5cd1fbe70 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | //usage:#define swapon_trivial_usage | 10 | //usage:#define swapon_trivial_usage |
11 | //usage: "[-a]" IF_FEATURE_SWAPON_DISCARD(" [-d[POL]]") IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]" | 11 | //usage: "[-a] [-e]" IF_FEATURE_SWAPON_DISCARD(" [-d[POL]]") IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]" |
12 | //usage:#define swapon_full_usage "\n\n" | 12 | //usage:#define swapon_full_usage "\n\n" |
13 | //usage: "Start swapping on DEVICE\n" | 13 | //usage: "Start swapping on DEVICE\n" |
14 | //usage: "\n -a Start swapping on all swap devices" | 14 | //usage: "\n -a Start swapping on all swap devices" |
@@ -16,15 +16,17 @@ | |||
16 | //usage: "\n -d[POL] Discard blocks at swapon (POL=once)," | 16 | //usage: "\n -d[POL] Discard blocks at swapon (POL=once)," |
17 | //usage: "\n as freed (POL=pages), or both (POL omitted)" | 17 | //usage: "\n as freed (POL=pages), or both (POL omitted)" |
18 | //usage: ) | 18 | //usage: ) |
19 | //usage: "\n -e Silently skip devices that do not exist" | ||
19 | //usage: IF_FEATURE_SWAPON_PRI( | 20 | //usage: IF_FEATURE_SWAPON_PRI( |
20 | //usage: "\n -p PRI Set swap device priority" | 21 | //usage: "\n -p PRI Set swap device priority" |
21 | //usage: ) | 22 | //usage: ) |
22 | //usage: | 23 | //usage: |
23 | //usage:#define swapoff_trivial_usage | 24 | //usage:#define swapoff_trivial_usage |
24 | //usage: "[-a] [DEVICE]" | 25 | //usage: "[-a] [-e] [DEVICE]" |
25 | //usage:#define swapoff_full_usage "\n\n" | 26 | //usage:#define swapoff_full_usage "\n\n" |
26 | //usage: "Stop swapping on DEVICE\n" | 27 | //usage: "Stop swapping on DEVICE\n" |
27 | //usage: "\n -a Stop swapping on all swap devices" | 28 | //usage: "\n -a Stop swapping on all swap devices" |
29 | //usage: "\n -e Silently skip devices that do not exist" | ||
28 | 30 | ||
29 | #include "libbb.h" | 31 | #include "libbb.h" |
30 | #include <mntent.h> | 32 | #include <mntent.h> |
@@ -77,15 +79,18 @@ struct globals { | |||
77 | /* Command line options */ | 79 | /* Command line options */ |
78 | enum { | 80 | enum { |
79 | OPTBIT_a, /* -a all */ | 81 | OPTBIT_a, /* -a all */ |
82 | OPTBIT_e, /* -e ifexists */ | ||
80 | IF_FEATURE_SWAPON_DISCARD( OPTBIT_d ,) /* -d discard */ | 83 | IF_FEATURE_SWAPON_DISCARD( OPTBIT_d ,) /* -d discard */ |
81 | IF_FEATURE_SWAPON_PRI ( OPTBIT_p ,) /* -p priority */ | 84 | IF_FEATURE_SWAPON_PRI ( OPTBIT_p ,) /* -p priority */ |
82 | OPT_a = 1 << OPTBIT_a, | 85 | OPT_a = 1 << OPTBIT_a, |
86 | OPT_e = 1 << OPTBIT_e, | ||
83 | OPT_d = IF_FEATURE_SWAPON_DISCARD((1 << OPTBIT_d)) + 0, | 87 | OPT_d = IF_FEATURE_SWAPON_DISCARD((1 << OPTBIT_d)) + 0, |
84 | OPT_p = IF_FEATURE_SWAPON_PRI ((1 << OPTBIT_p)) + 0, | 88 | OPT_p = IF_FEATURE_SWAPON_PRI ((1 << OPTBIT_p)) + 0, |
85 | }; | 89 | }; |
86 | 90 | ||
87 | #define OPT_ALL (option_mask32 & OPT_a) | 91 | #define OPT_ALL (option_mask32 & OPT_a) |
88 | #define OPT_DISCARD (option_mask32 & OPT_d) | 92 | #define OPT_DISCARD (option_mask32 & OPT_d) |
93 | #define OPT_IFEXISTS (option_mask32 & OPT_e) | ||
89 | #define OPT_PRIO (option_mask32 & OPT_p) | 94 | #define OPT_PRIO (option_mask32 & OPT_p) |
90 | 95 | ||
91 | static int swap_enable_disable(char *device) | 96 | static int swap_enable_disable(char *device) |
@@ -95,6 +100,8 @@ static int swap_enable_disable(char *device) | |||
95 | struct stat st; | 100 | struct stat st; |
96 | 101 | ||
97 | resolve_mount_spec(&device); | 102 | resolve_mount_spec(&device); |
103 | if (!OPT_IFEXISTS) | ||
104 | xstat(device, &st); | ||
98 | 105 | ||
99 | if (do_swapoff) { | 106 | if (do_swapoff) { |
100 | err = swapoff(device); | 107 | err = swapoff(device); |
@@ -112,7 +119,8 @@ static int swap_enable_disable(char *device) | |||
112 | } | 119 | } |
113 | err = swapon(device, g_flags); | 120 | err = swapon(device, g_flags); |
114 | /* Don't complain on swapon -a if device is already in use */ | 121 | /* Don't complain on swapon -a if device is already in use */ |
115 | quiet = (OPT_ALL && errno == EBUSY); | 122 | /* Don't complain if file does not exist with -e option */ |
123 | quiet = (OPT_ALL && errno == EBUSY) || (OPT_IFEXISTS && errno == ENOENT); | ||
116 | } | 124 | } |
117 | } | 125 | } |
118 | 126 | ||
@@ -229,7 +237,7 @@ static int do_all_in_proc_swaps(void) | |||
229 | return err; | 237 | return err; |
230 | } | 238 | } |
231 | 239 | ||
232 | #define OPTSTR_SWAPON "a" \ | 240 | #define OPTSTR_SWAPON "ae" \ |
233 | IF_FEATURE_SWAPON_DISCARD("d::") \ | 241 | IF_FEATURE_SWAPON_DISCARD("d::") \ |
234 | IF_FEATURE_SWAPON_PRI("p:") | 242 | IF_FEATURE_SWAPON_PRI("p:") |
235 | 243 | ||
@@ -242,7 +250,7 @@ int swap_on_off_main(int argc UNUSED_PARAM, char **argv) | |||
242 | 250 | ||
243 | INIT_G(); | 251 | INIT_G(); |
244 | 252 | ||
245 | getopt32(argv, do_swapoff ? "a" : OPTSTR_SWAPON | 253 | getopt32(argv, do_swapoff ? "ae" : OPTSTR_SWAPON |
246 | IF_FEATURE_SWAPON_DISCARD(, &discard) | 254 | IF_FEATURE_SWAPON_DISCARD(, &discard) |
247 | IF_FEATURE_SWAPON_PRI(, &prio) | 255 | IF_FEATURE_SWAPON_PRI(, &prio) |
248 | ); | 256 | ); |
diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c index 0c6bdfddf..53bdbdf09 100644 --- a/util-linux/volume_id/get_devname.c +++ b/util-linux/volume_id/get_devname.c | |||
@@ -302,9 +302,9 @@ int resolve_mount_spec(char **fsname) | |||
302 | { | 302 | { |
303 | char *tmp = *fsname; | 303 | char *tmp = *fsname; |
304 | 304 | ||
305 | if (strncmp(*fsname, "UUID=", 5) == 0) | 305 | if (is_prefixed_with(*fsname, "UUID=")) |
306 | tmp = get_devname_from_uuid(*fsname + 5); | 306 | tmp = get_devname_from_uuid(*fsname + 5); |
307 | else if (strncmp(*fsname, "LABEL=", 6) == 0) | 307 | else if (is_prefixed_with(*fsname, "LABEL=") == 0) |
308 | tmp = get_devname_from_label(*fsname + 6); | 308 | tmp = get_devname_from_label(*fsname + 6); |
309 | 309 | ||
310 | if (tmp == *fsname) | 310 | if (tmp == *fsname) |