Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/util-linux/mount.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/util-linux/mount.c
r3232 r3621 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 115 //usage:#define mount_trivial_usage 21 //usage: "[OPTIONS] [-o OPT S] DEVICE NODE"116 //usage: "[OPTIONS] [-o OPT] DEVICE NODE" 22 117 //usage:#define mount_full_usage "\n\n" 23 118 //usage: "Mount a filesystem. Filesystem autodetection requires /proc.\n" … … 42 137 ////usage: "\n -s Sloppy (ignored)" 43 138 //usage: "\n -r Read-only mount" 44 // usage: "\n -w Read-write mount (default)"139 ////usage: "\n -w Read-write mount (default)" 45 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 144 //usage: "\n -O OPT Mount only filesystems with option OPT (-a only)" 47 145 //usage: "\n-o OPT:" … … 65 163 //usage: ) 66 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 166 //usage: "\n" 69 167 //usage: "\nThere are filesystem-specific -o flags." … … 126 224 127 225 #include "libbb.h" 226 #include "common_bufsiz.h" 128 227 #if ENABLE_FEATURE_MOUNT_LABEL 129 228 # include "volume_id.h" … … 162 261 // Not real flags, but we want to be able to check for this. 163 262 enum { 164 MOUNT_USERS = (1 << 28) * ENABLE_DESKTOP, 263 MOUNT_USERS = (1 << 27) * ENABLE_DESKTOP, 264 MOUNT_NOFAIL = (1 << 28) * ENABLE_DESKTOP, 165 265 MOUNT_NOAUTO = (1 << 29), 166 266 MOUNT_SWAP = (1 << 30), 267 MOUNT_FAKEFLAGS = MOUNT_USERS | MOUNT_NOFAIL | MOUNT_NOAUTO | MOUNT_SWAP 167 268 }; 168 269 169 270 170 #define OPTION_STR "o:t:rwanfvsiO:" 271 #define OPTION_STR "o:t:rwanfvsiO:" IF_FEATURE_MOUNT_OTHERTAB("T:") 171 272 enum { 172 273 OPT_o = (1 << 0), … … 181 282 OPT_i = (1 << 9), 182 283 OPT_O = (1 << 10), 284 OPT_T = (1 << 11), 183 285 }; 184 286 … … 228 330 IF_DESKTOP(/* "user" */ MOUNT_USERS,) 229 331 IF_DESKTOP(/* "users" */ MOUNT_USERS,) 332 IF_DESKTOP(/* "nofail" */ MOUNT_NOFAIL,) 230 333 /* "_netdev" */ 0, 231 334 IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */ … … 275 378 }; 276 379 277 static const char mount_option_str[] =380 static const char mount_option_str[] ALIGN1 = 278 381 IF_FEATURE_MOUNT_LOOP( 279 382 "loop\0" … … 287 390 IF_DESKTOP("user\0") 288 391 IF_DESKTOP("users\0") 392 IF_DESKTOP("nofail\0") 289 393 "_netdev\0" 290 394 IF_DESKTOP("comment=\0") /* systemd uses this in fstab */ … … 345 449 } FIX_ALIASING; 346 450 enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) }; 347 #define G (*(struct globals*) &bb_common_bufsiz1)451 #define G (*(struct globals*)bb_common_bufsiz1) 348 452 #define nfs_mount_version (G.nfs_mount_version) 349 453 #if ENABLE_FEATURE_MOUNT_VERBOSE … … 354 458 #define fslist (G.fslist ) 355 459 #define getmntent_buf (G.getmntent_buf ) 356 #define INIT_G() do { } while (0)460 #define INIT_G() do { setup_common_bufsiz(); } while (0) 357 461 358 462 #if ENABLE_FEATURE_MTAB_SUPPORT … … 543 647 544 648 while ((buf = xmalloc_fgetline(f)) != NULL) { 545 if ( strncmp(buf, "nodev", 5) == 0&& isspace(buf[5]))649 if (is_prefixed_with(buf, "nodev") && isspace(buf[5])) 546 650 goto next; 547 651 fs = skip_whitespace(buf); … … 573 677 { 574 678 int rc = 0; 679 680 vfsflags &= ~(unsigned long)MOUNT_FAKEFLAGS; 575 681 576 682 if (FAKE_IT) { … … 898 1004 #endif 899 1005 /* Convert each NFSERR_BLAH into EBLAH */ 900 static const uint8_t nfs_err_stat[] = {1006 static const uint8_t nfs_err_stat[] ALIGN1 = { 901 1007 1, 2, 5, 6, 13, 17, 902 1008 19, 20, 21, 22, 27, 28, … … 911 1017 typedef uint16_t nfs_err_type; 912 1018 #endif 913 static const nfs_err_type nfs_err_errnum[] = {1019 static const nfs_err_type nfs_err_errnum[] ALIGN2 = { 914 1020 EPERM , ENOENT , EIO , ENXIO , EACCES, EEXIST, 915 1021 ENODEV, ENOTDIR , EISDIR , EINVAL, EFBIG , ENOSPC, … … 1266 1372 continue; 1267 1373 case 18: // "proto" 1268 if ( !strncmp(opteq, "tcp", 3))1374 if (is_prefixed_with(opteq, "tcp")) 1269 1375 tcp = 1; 1270 else if ( !strncmp(opteq, "udp", 3))1376 else if (is_prefixed_with(opteq, "udp")) 1271 1377 tcp = 0; 1272 1378 else … … 1361 1467 "acl\0"; 1362 1468 int val = 1; 1363 if ( !strncmp(opt, "no", 2)) {1469 if (is_prefixed_with(opt, "no")) { 1364 1470 val = 0; 1365 1471 opt += 2; … … 1857 1963 share + len + 1 /* "dir1/dir2" */ 1858 1964 ); 1859 1860 1965 parse_mount_options(unc, &filteropts); 1966 if (ENABLE_FEATURE_CLEAN_UP) free(unc); 1861 1967 } 1862 1968 … … 1881 1987 1882 1988 // Might this be an NFS filesystem? 1883 if ((!mp->mnt_type || strncmp(mp->mnt_type, "nfs", 3) == 0)1989 if ((!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs")) 1884 1990 && strchr(mp->mnt_fsname, ':') != NULL 1885 1991 ) { … … 1953 2059 if (ENABLE_FEATURE_CLEAN_UP) { 1954 2060 free(loopFile); 1955 free(mp->mnt_fsname);2061 /* No, "rc != 0" needs it: free(mp->mnt_fsname); */ 1956 2062 } 1957 2063 } … … 1962 2068 1963 2069 if (errno == EBUSY && ignore_busy) 2070 return 0; 2071 if (errno == ENOENT && (vfsflags & MOUNT_NOFAIL)) 1964 2072 return 0; 1965 2073 if (rc != 0) … … 2035 2143 char *storage_path; 2036 2144 llist_t *lst_o = NULL; 2037 const char *fstabname ;2145 const char *fstabname = "/etc/fstab"; 2038 2146 FILE *fstab; 2039 2147 int i, j; … … 2062 2170 opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv"); 2063 2171 opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch 2172 IF_FEATURE_MOUNT_OTHERTAB(, &fstabname) 2064 2173 IF_FEATURE_MOUNT_VERBOSE(, &verbose)); 2065 2174 while (lst_o) append_mount_options(&cmdopts, llist_pop(&lst_o)); // -o … … 2129 2238 } 2130 2239 2240 // A malicious user could overmount /usr without this. 2241 if (ENABLE_FEATURE_MOUNT_OTHERTAB && nonroot) 2242 fstabname = "/etc/fstab"; 2131 2243 // Open either fstab or mtab 2132 fstabname = "/etc/fstab";2133 2244 if (cmdopt_flags & MS_REMOUNT) { 2134 2245 // WARNING. I am not sure this matches util-linux's
Note:
See TracChangeset
for help on using the changeset viewer.