diff options
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r-- | util-linux/mount.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index 05e532cda..f94b6e643 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -38,7 +38,7 @@ | |||
38 | //usage: ) | 38 | //usage: ) |
39 | //usage: "\n -r Read-only mount" | 39 | //usage: "\n -r Read-only mount" |
40 | //usage: "\n -w Read-write mount (default)" | 40 | //usage: "\n -w Read-write mount (default)" |
41 | //usage: "\n -t FSTYPE Filesystem type" | 41 | //usage: "\n -t FSTYPE[,...] Filesystem type(s)" |
42 | //usage: "\n -O OPT Mount only filesystems with option OPT (-a only)" | 42 | //usage: "\n -O OPT Mount only filesystems with option OPT (-a only)" |
43 | //usage: "\n-o OPT:" | 43 | //usage: "\n-o OPT:" |
44 | //usage: IF_FEATURE_MOUNT_LOOP( | 44 | //usage: IF_FEATURE_MOUNT_LOOP( |
@@ -339,6 +339,7 @@ enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_b | |||
339 | #endif | 339 | #endif |
340 | #define fslist (G.fslist ) | 340 | #define fslist (G.fslist ) |
341 | #define getmntent_buf (G.getmntent_buf ) | 341 | #define getmntent_buf (G.getmntent_buf ) |
342 | #define INIT_G() do { } while (0) | ||
342 | 343 | ||
343 | #if ENABLE_FEATURE_MTAB_SUPPORT | 344 | #if ENABLE_FEATURE_MTAB_SUPPORT |
344 | /* | 345 | /* |
@@ -521,12 +522,13 @@ static llist_t *get_block_backed_filesystems(void) | |||
521 | 522 | ||
522 | while ((buf = xmalloc_fgetline(f)) != NULL) { | 523 | while ((buf = xmalloc_fgetline(f)) != NULL) { |
523 | if (strncmp(buf, "nodev", 5) == 0 && isspace(buf[5])) | 524 | if (strncmp(buf, "nodev", 5) == 0 && isspace(buf[5])) |
524 | continue; | 525 | goto next; |
525 | fs = skip_whitespace(buf); | 526 | fs = skip_whitespace(buf); |
526 | if (*fs == '#' || *fs == '*' || !*fs) | 527 | if (*fs == '#' || *fs == '*' || !*fs) |
527 | continue; | 528 | goto next; |
528 | 529 | ||
529 | llist_add_to_end(&list, xstrdup(fs)); | 530 | llist_add_to_end(&list, xstrdup(fs)); |
531 | next: | ||
530 | free(buf); | 532 | free(buf); |
531 | } | 533 | } |
532 | if (ENABLE_FEATURE_CLEAN_UP) fclose(f); | 534 | if (ENABLE_FEATURE_CLEAN_UP) fclose(f); |
@@ -1809,7 +1811,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1809 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { | 1811 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { |
1810 | loopFile = bb_simplify_path(mp->mnt_fsname); | 1812 | loopFile = bb_simplify_path(mp->mnt_fsname); |
1811 | mp->mnt_fsname = NULL; // will receive malloced loop dev name | 1813 | mp->mnt_fsname = NULL; // will receive malloced loop dev name |
1812 | if (set_loop(&mp->mnt_fsname, loopFile, 0) < 0) { | 1814 | if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ 0) < 0) { |
1813 | if (errno == EPERM || errno == EACCES) | 1815 | if (errno == EPERM || errno == EACCES) |
1814 | bb_error_msg(bb_msg_perm_denied_are_you_root); | 1816 | bb_error_msg(bb_msg_perm_denied_are_you_root); |
1815 | else | 1817 | else |
@@ -1825,7 +1827,16 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1825 | // If we know the fstype (or don't need to), jump straight | 1827 | // If we know the fstype (or don't need to), jump straight |
1826 | // to the actual mount. | 1828 | // to the actual mount. |
1827 | if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) { | 1829 | if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) { |
1828 | rc = mount_it_now(mp, vfsflags, filteropts); | 1830 | char *next; |
1831 | for (;;) { | ||
1832 | next = mp->mnt_type ? strchr(mp->mnt_type, ',') : NULL; | ||
1833 | if (next) | ||
1834 | *next = '\0'; | ||
1835 | rc = mount_it_now(mp, vfsflags, filteropts); | ||
1836 | if (rc == 0 || !next) | ||
1837 | break; | ||
1838 | mp->mnt_type = next + 1; | ||
1839 | } | ||
1829 | } else { | 1840 | } else { |
1830 | // Loop through filesystem types until mount succeeds | 1841 | // Loop through filesystem types until mount succeeds |
1831 | // or we run out | 1842 | // or we run out |
@@ -1842,7 +1853,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1842 | for (fl = fslist; fl; fl = fl->link) { | 1853 | for (fl = fslist; fl; fl = fl->link) { |
1843 | mp->mnt_type = fl->data; | 1854 | mp->mnt_type = fl->data; |
1844 | rc = mount_it_now(mp, vfsflags, filteropts); | 1855 | rc = mount_it_now(mp, vfsflags, filteropts); |
1845 | if (!rc) | 1856 | if (rc == 0) |
1846 | break; | 1857 | break; |
1847 | } | 1858 | } |
1848 | } | 1859 | } |
@@ -1944,6 +1955,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
1944 | 1955 | ||
1945 | IF_DESKTOP(int nonroot = ) sanitize_env_if_suid(); | 1956 | IF_DESKTOP(int nonroot = ) sanitize_env_if_suid(); |
1946 | 1957 | ||
1958 | INIT_G(); | ||
1959 | |||
1947 | // Parse long options, like --bind and --move. Note that -o option | 1960 | // Parse long options, like --bind and --move. Note that -o option |
1948 | // and --option are synonymous. Yes, this means --remount,rw works. | 1961 | // and --option are synonymous. Yes, this means --remount,rw works. |
1949 | for (i = j = 1; argv[i]; i++) { | 1962 | for (i = j = 1; argv[i]; i++) { |