diff options
| author | Isaac Dunham <ibid.ag@gmail.com> | 2015-03-11 16:07:24 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-03-11 16:07:24 +0100 |
| commit | 7b434a67dcaa88047095cf0196941c5456bb1c87 (patch) | |
| tree | 8351fef0f03720421f3aed7ea6a2a68be45ca1d0 /util-linux | |
| parent | 3c31b092ac21c09ce6c76111bceba00debe300c3 (diff) | |
| download | busybox-w32-7b434a67dcaa88047095cf0196941c5456bb1c87.tar.gz busybox-w32-7b434a67dcaa88047095cf0196941c5456bb1c87.tar.bz2 busybox-w32-7b434a67dcaa88047095cf0196941c5456bb1c87.zip | |
mount: -T OTHERTAB support
function old new delta
mount_main 1221 1241 +20
packed_usage 30616 30610 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Isaac Dunham <ibid.ag@gmail.com>
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/Config.src | 88 | ||||
| -rw-r--r-- | util-linux/mount.c | 114 |
2 files changed, 108 insertions, 94 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/mount.c b/util-linux/mount.c index 62fd41fd7..fbc89c862 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 |
| @@ -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 |
