Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/util-linux/mount.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/util-linux/mount.c
r2725 r3232 17 17 // mount_it_now() does the actual mount. 18 18 // 19 20 //usage:#define mount_trivial_usage 21 //usage: "[OPTIONS] [-o OPTS] DEVICE NODE" 22 //usage:#define mount_full_usage "\n\n" 23 //usage: "Mount a filesystem. Filesystem autodetection requires /proc.\n" 24 //usage: "\n -a Mount all filesystems in fstab" 25 //usage: IF_FEATURE_MOUNT_FAKE( 26 //usage: IF_FEATURE_MTAB_SUPPORT( 27 //usage: "\n -f Update /etc/mtab, but don't mount" 28 //usage: ) 29 //usage: IF_NOT_FEATURE_MTAB_SUPPORT( 30 //usage: "\n -f Dry run" 31 //usage: ) 32 //usage: ) 33 //usage: IF_FEATURE_MOUNT_HELPERS( 34 //usage: "\n -i Don't run mount helper" 35 //usage: ) 36 //usage: IF_FEATURE_MTAB_SUPPORT( 37 //usage: "\n -n Don't update /etc/mtab" 38 //usage: ) 39 //usage: IF_FEATURE_MOUNT_VERBOSE( 40 //usage: "\n -v Verbose" 41 //usage: ) 42 ////usage: "\n -s Sloppy (ignored)" 43 //usage: "\n -r Read-only mount" 44 //usage: "\n -w Read-write mount (default)" 45 //usage: "\n -t FSTYPE[,...] Filesystem type(s)" 46 //usage: "\n -O OPT Mount only filesystems with option OPT (-a only)" 47 //usage: "\n-o OPT:" 48 //usage: IF_FEATURE_MOUNT_LOOP( 49 //usage: "\n loop Ignored (loop devices are autodetected)" 50 //usage: ) 51 //usage: IF_FEATURE_MOUNT_FLAGS( 52 //usage: "\n [a]sync Writes are [a]synchronous" 53 //usage: "\n [no]atime Disable/enable updates to inode access times" 54 //usage: "\n [no]diratime Disable/enable atime updates to directories" 55 //usage: "\n [no]relatime Disable/enable atime updates relative to modification time" 56 //usage: "\n [no]dev (Dis)allow use of special device files" 57 //usage: "\n [no]exec (Dis)allow use of executable files" 58 //usage: "\n [no]suid (Dis)allow set-user-id-root programs" 59 //usage: "\n [r]shared Convert [recursively] to a shared subtree" 60 //usage: "\n [r]slave Convert [recursively] to a slave subtree" 61 //usage: "\n [r]private Convert [recursively] to a private subtree" 62 //usage: "\n [un]bindable Make mount point [un]able to be bind mounted" 63 //usage: "\n [r]bind Bind a file or directory [recursively] to another location" 64 //usage: "\n move Relocate an existing mount point" 65 //usage: ) 66 //usage: "\n remount Remount a mounted filesystem, changing flags" 67 //usage: "\n ro/rw Same as -r/-w" 68 //usage: "\n" 69 //usage: "\nThere are filesystem-specific -o flags." 70 //usage: 71 //usage:#define mount_example_usage 72 //usage: "$ mount\n" 73 //usage: "/dev/hda3 on / type minix (rw)\n" 74 //usage: "proc on /proc type proc (rw)\n" 75 //usage: "devpts on /dev/pts type devpts (rw)\n" 76 //usage: "$ mount /dev/fd0 /mnt -t msdos -o ro\n" 77 //usage: "$ mount /tmp/diskimage /opt -t ext2 -o loop\n" 78 //usage: "$ mount cd_image.iso mydir\n" 79 //usage:#define mount_notes_usage 80 //usage: "Returns 0 for success, number of failed mounts for -a, or errno for one mount." 81 19 82 #include <mntent.h> 20 83 #include <syslog.h> … … 55 118 # define MS_RELATIME (1 << 21) 56 119 #endif 120 #ifndef MS_STRICTATIME 121 # define MS_STRICTATIME (1 << 24) 122 #endif 123 124 /* Any ~MS_FOO value has this bit set: */ 125 #define BB_MS_INVERTED_VALUE (1u << 31) 57 126 58 127 #include "libbb.h" … … 160 229 IF_DESKTOP(/* "users" */ MOUNT_USERS,) 161 230 /* "_netdev" */ 0, 231 IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */ 162 232 ) 163 233 … … 181 251 /* "relatime" */ MS_RELATIME, 182 252 /* "norelatime" */ ~MS_RELATIME, 253 /* "strictatime" */ MS_STRICTATIME, 183 254 /* "loud" */ ~MS_SILENT, 255 /* "rbind" */ MS_BIND|MS_RECURSIVE, 184 256 185 257 // action flags … … 193 265 /* "rshared" */ MS_SHARED|MS_RECURSIVE, 194 266 /* "rslave" */ MS_SLAVE|MS_RECURSIVE, 195 /* "rprivate" */ MS_ SLAVE|MS_RECURSIVE,267 /* "rprivate" */ MS_PRIVATE|MS_RECURSIVE, 196 268 /* "runbindable" */ MS_UNBINDABLE|MS_RECURSIVE, 197 269 ) … … 216 288 IF_DESKTOP("users\0") 217 289 "_netdev\0" 290 IF_DESKTOP("comment=\0") /* systemd uses this in fstab */ 218 291 ) 219 292 IF_FEATURE_MOUNT_FLAGS( … … 236 309 "relatime\0" 237 310 "norelatime\0" 311 "strictatime\0" 238 312 "loud\0" 313 "rbind\0" 239 314 240 315 // action flags … … 242 317 "bind\0" 243 318 "move\0" 244 " shared\0"245 " slave\0"246 " private\0"247 " unbindable\0"248 " rshared\0"249 " rslave\0"250 " rprivate\0"251 " runbindable\0"319 "make-shared\0" 320 "make-slave\0" 321 "make-private\0" 322 "make-unbindable\0" 323 "make-rshared\0" 324 "make-rslave\0" 325 "make-rprivate\0" 326 "make-runbindable\0" 252 327 ) 253 328 … … 279 354 #define fslist (G.fslist ) 280 355 #define getmntent_buf (G.getmntent_buf ) 281 356 #define INIT_G() do { } while (0) 357 358 #if ENABLE_FEATURE_MTAB_SUPPORT 359 /* 360 * update_mtab_entry_on_move() is used to update entry in case of mount --move. 361 * we are looking for existing entries mnt_dir which is equal to mnt_fsname of 362 * input mntent and replace it by new one. 363 */ 364 static void FAST_FUNC update_mtab_entry_on_move(const struct mntent *mp) 365 { 366 struct mntent *entries, *m; 367 int i, count; 368 FILE *mountTable; 369 370 mountTable = setmntent(bb_path_mtab_file, "r"); 371 if (!mountTable) { 372 bb_perror_msg(bb_path_mtab_file); 373 return; 374 } 375 376 entries = NULL; 377 count = 0; 378 while ((m = getmntent(mountTable)) != NULL) { 379 entries = xrealloc_vector(entries, 3, count); 380 entries[count].mnt_fsname = xstrdup(m->mnt_fsname); 381 entries[count].mnt_dir = xstrdup(m->mnt_dir); 382 entries[count].mnt_type = xstrdup(m->mnt_type); 383 entries[count].mnt_opts = xstrdup(m->mnt_opts); 384 entries[count].mnt_freq = m->mnt_freq; 385 entries[count].mnt_passno = m->mnt_passno; 386 count++; 387 } 388 endmntent(mountTable); 389 390 mountTable = setmntent(bb_path_mtab_file, "w"); 391 if (mountTable) { 392 for (i = 0; i < count; i++) { 393 if (strcmp(entries[i].mnt_dir, mp->mnt_fsname) != 0) 394 addmntent(mountTable, &entries[i]); 395 else 396 addmntent(mountTable, mp); 397 } 398 endmntent(mountTable); 399 } else if (errno != EROFS) 400 bb_perror_msg(bb_path_mtab_file); 401 402 if (ENABLE_FEATURE_CLEAN_UP) { 403 for (i = 0; i < count; i++) { 404 free(entries[i].mnt_fsname); 405 free(entries[i].mnt_dir); 406 free(entries[i].mnt_type); 407 free(entries[i].mnt_opts); 408 } 409 free(entries); 410 } 411 } 412 #endif 282 413 283 414 #if ENABLE_FEATURE_MOUNT_VERBOSE … … 334 465 // Use the mount_options list to parse options into flags. 335 466 // Also update list of unrecognized options if unrecognized != NULL 336 static long parse_mount_options(char *options, char **unrecognized)337 { 338 long flags = MS_SILENT;467 static unsigned long parse_mount_options(char *options, char **unrecognized) 468 { 469 unsigned long flags = MS_SILENT; 339 470 340 471 // Loop through options … … 349 480 // Find this option in mount_options 350 481 for (i = 0; i < ARRAY_SIZE(mount_options); i++) { 351 if (strcasecmp(option_str, options) == 0) { 352 long fl = mount_options[i]; 353 if (fl < 0) 482 unsigned opt_len = strlen(option_str); 483 484 if (strncasecmp(option_str, options, opt_len) == 0 485 && (options[opt_len] == '\0' 486 /* or is it "comment=" thingy in fstab? */ 487 IF_FEATURE_MOUNT_FSTAB(IF_DESKTOP( || option_str[opt_len-1] == '=' )) 488 ) 489 ) { 490 unsigned long fl = mount_options[i]; 491 if (fl & BB_MS_INVERTED_VALUE) 354 492 flags &= fl; 355 493 else … … 357 495 goto found; 358 496 } 359 option_str += strlen(option_str)+ 1;497 option_str += opt_len + 1; 360 498 } 361 499 // We did not recognize this option. … … 406 544 while ((buf = xmalloc_fgetline(f)) != NULL) { 407 545 if (strncmp(buf, "nodev", 5) == 0 && isspace(buf[5])) 408 continue;546 goto next; 409 547 fs = skip_whitespace(buf); 410 548 if (*fs == '#' || *fs == '*' || !*fs) 411 continue;549 goto next; 412 550 413 551 llist_add_to_end(&list, xstrdup(fs)); 552 next: 414 553 free(buf); 415 554 } … … 431 570 // Perform actual mount of specific filesystem at specific location. 432 571 // NB: mp->xxx fields may be trashed on exit 433 static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)572 static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filteropts) 434 573 { 435 574 int rc = 0; … … 497 636 498 637 if (!mountTable) { 499 bb_ error_msg("no %s",bb_path_mtab_file);638 bb_perror_msg(bb_path_mtab_file); 500 639 goto ret; 501 640 } 502 641 503 642 // Add vfs string flags 504 505 643 for (i = 0; mount_options[i] != MS_REMOUNT; i++) { 506 644 if (mount_options[i] > 0 && (mount_options[i] & vfsflags)) … … 510 648 511 649 // Remove trailing / (if any) from directory we mounted on 512 513 650 i = strlen(mp->mnt_dir) - 1; 514 if (i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = '\0'; 651 while (i > 0 && mp->mnt_dir[i] == '/') 652 mp->mnt_dir[i--] = '\0'; 515 653 516 654 // Convert to canonical pathnames as needed 517 518 655 mp->mnt_dir = bb_simplify_path(mp->mnt_dir); 519 fsname = 0;656 fsname = NULL; 520 657 if (!mp->mnt_type || !*mp->mnt_type) { // bind mount 521 658 mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname); … … 524 661 mp->mnt_freq = mp->mnt_passno = 0; 525 662 526 // Write and close. 527 528 addmntent(mountTable, mp); 663 // Write and close 664 #if ENABLE_FEATURE_MTAB_SUPPORT 665 if (vfsflags & MS_MOVE) 666 update_mtab_entry_on_move(mp); 667 else 668 #endif 669 addmntent(mountTable, mp); 529 670 endmntent(mountTable); 671 530 672 if (ENABLE_FEATURE_CLEAN_UP) { 531 673 free(mp->mnt_dir); … … 700 842 701 843 struct nfs2_fh { 702 char 844 char data[32]; 703 845 }; 704 846 struct nfs3_fh { 705 unsigned short 706 unsigned char 847 unsigned short size; 848 unsigned char data[64]; 707 849 }; 708 850 709 851 struct nfs_mount_data { 710 int version; 711 int fd; 712 struct nfs2_fh old_root; 713 int flags; 714 int rsize; 715 int wsize; 716 int timeo; 717 int retrans; 718 int acregmin; 719 int acregmax; 720 int acdirmin; 721 int acdirmax; 722 struct sockaddr_in addr; 723 char hostname[256]; 724 int namlen; 725 unsigned int bsize; 726 struct nfs3_fh root; 852 int version; /* 1 */ 853 int fd; /* 1 */ 854 struct nfs2_fh old_root; /* 1 */ 855 int flags; /* 1 */ 856 int rsize; /* 1 */ 857 int wsize; /* 1 */ 858 int timeo; /* 1 */ 859 int retrans; /* 1 */ 860 int acregmin; /* 1 */ 861 int acregmax; /* 1 */ 862 int acdirmin; /* 1 */ 863 int acdirmax; /* 1 */ 864 struct sockaddr_in addr; /* 1 */ 865 char hostname[256]; /* 1 */ 866 int namlen; /* 2 */ 867 unsigned int bsize; /* 3 */ 868 struct nfs3_fh root; /* 4 */ 727 869 }; 728 870 … … 739 881 NFS_MOUNT_KERBEROS = 0x0100, /* 3 */ 740 882 NFS_MOUNT_NONLM = 0x0200, /* 3 */ 883 NFS_MOUNT_NOACL = 0x0800, /* 4 */ 741 884 NFS_MOUNT_NORDIRPLUS = 0x4000 742 885 }; … … 792 935 { 793 936 if (!xdr_u_int(xdrs, &objp->fhs_status)) 794 937 return FALSE; 795 938 if (objp->fhs_status == 0) 796 939 return xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle); … … 806 949 { 807 950 return xdr_bytes(xdrs, (char **)&objp->fhandle3_val, 808 809 951 (unsigned int *) &objp->fhandle3_len, 952 FHSIZE3); 810 953 } 811 954 … … 815 958 return FALSE; 816 959 return xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), 817 818 819 820 960 &(objp->auth_flavours.auth_flavours_len), 961 ~0, 962 sizeof(int), 963 (xdrproc_t) xdr_int); 821 964 } 822 965 … … 959 1102 960 1103 /* NB: mp->xxx fields may be trashed on exit */ 961 static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)1104 static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts) 962 1105 { 963 1106 CLIENT *mclient; … … 1003 1146 int nordirplus; 1004 1147 int nolock; 1148 int noacl; 1005 1149 1006 1150 find_kernel_nfs_mount_version(); … … 1022 1166 *s = '\0'; 1023 1167 /* Ignore all but first hostname in replicated mounts 1024 1168 * until they can be fully supported. (mack@sgi.com) */ 1025 1169 s = strchr(hostname, ','); 1026 1170 if (s) { … … 1075 1219 noac = 0; 1076 1220 nordirplus = 0; 1221 noacl = 0; 1077 1222 retry = 10000; /* 10000 minutes ~ 1 week */ 1078 tcp = 0;1223 tcp = 1; /* nfs-utils uses tcp per default */ 1079 1224 1080 1225 mountprog = MOUNTPROG; … … 1130 1275 case 20: // "addr" - ignore 1131 1276 continue; 1277 case -1: // unknown 1278 if (vfsflags & MS_REMOUNT) 1279 continue; 1132 1280 } 1133 1281 … … 1210 1358 "udp\0" 1211 1359 "lock\0" 1212 "rdirplus\0"; 1360 "rdirplus\0" 1361 "acl\0"; 1213 1362 int val = 1; 1214 1363 if (!strncmp(opt, "no", 2)) { … … 1260 1409 nordirplus = !val; 1261 1410 break; 1411 case 12: // acl 1412 noacl = !val; 1413 break; 1262 1414 default: 1263 1415 bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt); … … 1273 1425 | (nocto ? NFS_MOUNT_NOCTO : 0) 1274 1426 | (noac ? NFS_MOUNT_NOAC : 0) 1275 | (nordirplus ? NFS_MOUNT_NORDIRPLUS : 0); 1427 | (nordirplus ? NFS_MOUNT_NORDIRPLUS : 0) 1428 | (noacl ? NFS_MOUNT_NOACL : 0); 1276 1429 if (nfs_mount_version >= 2) 1277 1430 data.flags |= (tcp ? NFS_MOUNT_TCP : 0); … … 1377 1530 case IPPROTO_UDP: 1378 1531 mclient = clntudp_create(&mount_server_addr, 1379 1380 1381 1382 1532 pm_mnt.pm_prog, 1533 pm_mnt.pm_vers, 1534 retry_timeout, 1535 &msock); 1383 1536 if (mclient) 1384 1537 break; … … 1387 1540 case IPPROTO_TCP: 1388 1541 mclient = clnttcp_create(&mount_server_addr, 1389 1390 1391 1542 pm_mnt.pm_prog, 1543 pm_mnt.pm_vers, 1544 &msock, 0, 0); 1392 1545 break; 1393 1546 default: … … 1410 1563 if (pm_mnt.pm_vers == 3) 1411 1564 clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT, 1412 1413 1414 1415 1416 1565 (xdrproc_t) xdr_dirpath, 1566 (caddr_t) &pathname, 1567 (xdrproc_t) xdr_mountres3, 1568 (caddr_t) &status, 1569 total_timeout); 1417 1570 else 1418 1571 clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, 1419 1420 1421 1422 1423 1572 (xdrproc_t) xdr_dirpath, 1573 (caddr_t) &pathname, 1574 (xdrproc_t) xdr_fhstatus, 1575 (caddr_t) &status, 1576 total_timeout); 1424 1577 1425 1578 if (clnt_stat == RPC_SUCCESS) … … 1552 1705 /* Perform actual mount */ 1553 1706 do_mount: 1554 mp->mnt_type = (char*)"nfs";1555 1707 retval = mount_it_now(mp, vfsflags, (char*)&data); 1556 1708 goto ret; … … 1577 1729 #else // !ENABLE_FEATURE_MOUNT_NFS 1578 1730 1579 // Never called. Call should be optimized out. 1580 int nfsmount(struct mntent *mp, long vfsflags, char *filteropts); 1731 /* Linux 2.6.23+ supports nfs mounts with options passed as a string. 1732 * For older kernels, you must build busybox with ENABLE_FEATURE_MOUNT_NFS. 1733 * (However, note that then you lose any chances that NFS over IPv6 would work). 1734 */ 1735 static int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts) 1736 { 1737 len_and_sockaddr *lsa; 1738 char *opts; 1739 char *end; 1740 char *dotted; 1741 int ret; 1742 1743 # if ENABLE_FEATURE_IPV6 1744 end = strchr(mp->mnt_fsname, ']'); 1745 if (end && end[1] == ':') 1746 end++; 1747 else 1748 # endif 1749 /* mount_main() guarantees that ':' is there */ 1750 end = strchr(mp->mnt_fsname, ':'); 1751 1752 *end = '\0'; 1753 lsa = xhost2sockaddr(mp->mnt_fsname, /*port:*/ 0); 1754 *end = ':'; 1755 dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); 1756 if (ENABLE_FEATURE_CLEAN_UP) free(lsa); 1757 opts = xasprintf("%s%saddr=%s", 1758 filteropts ? filteropts : "", 1759 filteropts ? "," : "", 1760 dotted 1761 ); 1762 if (ENABLE_FEATURE_CLEAN_UP) free(dotted); 1763 ret = mount_it_now(mp, vfsflags, opts); 1764 if (ENABLE_FEATURE_CLEAN_UP) free(opts); 1765 1766 return ret; 1767 } 1581 1768 1582 1769 #endif // !ENABLE_FEATURE_MOUNT_NFS … … 1588 1775 { 1589 1776 int rc = -1; 1590 long vfsflags;1777 unsigned long vfsflags; 1591 1778 char *loopFile = NULL, *filteropts = NULL; 1592 1779 llist_t *fl = NULL; … … 1638 1825 int len; 1639 1826 char c; 1827 char *hostname, *share; 1828 char *dotted, *ip; 1640 1829 len_and_sockaddr *lsa; 1641 char *hostname, *dotted, *ip; 1830 1831 // Parse mp->mnt_fsname of the form "//hostname/share[/dir1/dir2]" 1642 1832 1643 1833 hostname = mp->mnt_fsname + 2; 1644 1834 len = strcspn(hostname, "/\\"); 1645 if (len == 0 || hostname[len] == '\0') 1835 share = hostname + len + 1; 1836 if (len == 0 // 3rd char is a [back]slash (IOW: empty hostname) 1837 || share[-1] == '\0' // no [back]slash after hostname 1838 || share[0] == '\0' // empty share name 1839 ) { 1646 1840 goto report_error; 1647 c = hostname[len]; 1648 hostname[len] = '\0'; 1841 } 1842 c = share[-1]; 1843 share[-1] = '\0'; 1844 len = strcspn(share, "/\\"); 1845 1846 // "unc=\\hostname\share" option is mandatory 1847 // after CIFS option parsing was rewritten in Linux 3.4. 1848 // Must use backslashes. 1849 // If /dir1/dir2 is present, also add "prefixpath=dir1/dir2" 1850 { 1851 char *unc = xasprintf( 1852 share[len] != '\0' /* "/dir1/dir2" exists? */ 1853 ? "unc=\\\\%s\\%.*s,prefixpath=%s" 1854 : "unc=\\\\%s\\%.*s", 1855 hostname, 1856 len, share, 1857 share + len + 1 /* "dir1/dir2" */ 1858 ); 1859 parse_mount_options(unc, &filteropts); 1860 if (ENABLE_FEATURE_CLEAN_UP) free(unc); 1861 } 1862 1649 1863 lsa = host2sockaddr(hostname, 0); 1650 hostname[len] = c;1864 share[-1] = c; 1651 1865 if (!lsa) 1652 1866 goto report_error; … … 1660 1874 if (ENABLE_FEATURE_CLEAN_UP) free(ip); 1661 1875 1662 // "-o mand" is required [why?]1663 vfsflags |= MS_MANDLOCK;1664 1876 mp->mnt_type = (char*)"cifs"; 1665 1877 rc = mount_it_now(mp, vfsflags, filteropts); … … 1669 1881 1670 1882 // Might this be an NFS filesystem? 1671 if (ENABLE_FEATURE_MOUNT_NFS 1672 && (!mp->mnt_type || strcmp(mp->mnt_type, "nfs") == 0) 1883 if ((!mp->mnt_type || strncmp(mp->mnt_type, "nfs", 3) == 0) 1673 1884 && strchr(mp->mnt_fsname, ':') != NULL 1674 1885 ) { 1886 if (!mp->mnt_type) 1887 mp->mnt_type = (char*)"nfs"; 1675 1888 rc = nfsmount(mp, vfsflags, filteropts); 1676 1889 goto report_error; … … 1688 1901 loopFile = bb_simplify_path(mp->mnt_fsname); 1689 1902 mp->mnt_fsname = NULL; // will receive malloced loop dev name 1690 if (set_loop(&mp->mnt_fsname, loopFile, 0 ) < 0) {1903 if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ (vfsflags & MS_RDONLY)) < 0) { 1691 1904 if (errno == EPERM || errno == EACCES) 1692 1905 bb_error_msg(bb_msg_perm_denied_are_you_root); … … 1704 1917 // to the actual mount. 1705 1918 if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) { 1706 rc = mount_it_now(mp, vfsflags, filteropts); 1919 char *next; 1920 for (;;) { 1921 next = mp->mnt_type ? strchr(mp->mnt_type, ',') : NULL; 1922 if (next) 1923 *next = '\0'; 1924 rc = mount_it_now(mp, vfsflags, filteropts); 1925 if (rc == 0 || !next) 1926 break; 1927 mp->mnt_type = next + 1; 1928 } 1707 1929 } else { 1708 1930 // Loop through filesystem types until mount succeeds … … 1721 1943 mp->mnt_type = fl->data; 1722 1944 rc = mount_it_now(mp, vfsflags, filteropts); 1723 if ( !rc)1945 if (rc == 0) 1724 1946 break; 1725 1947 } … … 1817 2039 int i, j; 1818 2040 int rc = EXIT_SUCCESS; 2041 unsigned long cmdopt_flags; 1819 2042 unsigned opt; 1820 2043 struct mntent mtpair[2], *mtcur = mtpair; … … 1822 2045 1823 2046 IF_DESKTOP(int nonroot = ) sanitize_env_if_suid(); 2047 2048 INIT_G(); 1824 2049 1825 2050 // Parse long options, like --bind and --move. Note that -o option … … 1889 2114 // or "mount [opts] single_param" 1890 2115 1891 i = parse_mount_options(cmdopts, NULL); // FIXME: should be "long", not "int"1892 if (nonroot && ( i& ~MS_SILENT)) // Non-root users cannot specify flags2116 cmdopt_flags = parse_mount_options(cmdopts, NULL); 2117 if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags 1893 2118 bb_error_msg_and_die(bb_msg_you_must_be_root); 1894 2119 1895 2120 // If we have a shared subtree flag, don't worry about fstab or mtab. 1896 2121 if (ENABLE_FEATURE_MOUNT_FLAGS 1897 && ( i& (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))2122 && (cmdopt_flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) 1898 2123 ) { 1899 2124 // verbose_mount(source, target, type, flags, data) 1900 rc = verbose_mount("", argv[0], "", i, "");2125 rc = verbose_mount("", argv[0], "", cmdopt_flags, ""); 1901 2126 if (rc) 1902 2127 bb_simple_perror_msg_and_die(argv[0]); … … 1906 2131 // Open either fstab or mtab 1907 2132 fstabname = "/etc/fstab"; 1908 if ( i& MS_REMOUNT) {2133 if (cmdopt_flags & MS_REMOUNT) { 1909 2134 // WARNING. I am not sure this matches util-linux's 1910 2135 // behavior. It's possible util-linux does not … … 2005 2230 // Were we looking for something specific? 2006 2231 if (argv[0]) { // yes 2007 long l;2232 unsigned long l; 2008 2233 2009 2234 // If we didn't find anything, complain
Note:
See TracChangeset
for help on using the changeset viewer.