external/busybox
リビジョン | bbfc3392b8e61dd4c63b1926bab20445ac245bd3 (tree) |
---|---|
日時 | 2015-02-25 06:21:41 |
作者 | Dan Pasanen <dan.pasanen@gmai...> |
コミッター | Gerrit Code Review |
mount: respect a user-specified fstype
* Don't attempt to auto-detect the filesystem type using blkid
Change-Id: Icebbc3189fc59af9fe52e12b693f3b7ae516e2c7
@@ -341,6 +341,7 @@ struct globals { | ||
341 | 341 | unsigned verbose; |
342 | 342 | #endif |
343 | 343 | llist_t *fslist; |
344 | + int user_fstype; | |
344 | 345 | char getmntent_buf[1]; |
345 | 346 | } FIX_ALIASING; |
346 | 347 | enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) }; |
@@ -352,6 +353,7 @@ enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_b | ||
352 | 353 | #define verbose 0 |
353 | 354 | #endif |
354 | 355 | #define fslist (G.fslist ) |
356 | +#define user_fstype (G.user_fstype ) | |
355 | 357 | #define getmntent_buf (G.getmntent_buf ) |
356 | 358 | #define INIT_G() do { } while (0) |
357 | 359 |
@@ -1784,13 +1786,20 @@ static int singlemount(struct mntent *mp, int ignore_busy) | ||
1784 | 1786 | |
1785 | 1787 | vfsflags = parse_mount_options(mp->mnt_opts, &filteropts); |
1786 | 1788 | |
1787 | - detected_fstype = get_fstype_from_devname(mp->mnt_fsname); | |
1789 | + if (user_fstype) { | |
1790 | + // Treat fstype "auto" as unspecified | |
1791 | + if (mp->mnt_type && !strcmp(mp->mnt_type, "auto")) | |
1792 | + mp->mnt_type = NULL; | |
1793 | + } else { | |
1794 | + // If user didn't specify an fstype and blkid disagrees or the | |
1795 | + // fstype is "auto", trust blkid's determination of the fstype. | |
1796 | + | |
1797 | + detected_fstype = get_fstype_from_devname(mp->mnt_fsname); | |
1788 | 1798 | |
1789 | - // If fstype is auto or disagrees with blkid, trust blkid's | |
1790 | - // determination of the filesystem type | |
1791 | - if ((mp->mnt_type && !strcmp(mp->mnt_type, "auto")) || | |
1792 | - (detected_fstype && strcmp(detected_fstype, mp->mnt_type))) | |
1793 | - mp->mnt_type = detected_fstype; | |
1799 | + if ((mp->mnt_type && !strcmp(mp->mnt_type, "auto")) || | |
1800 | + (detected_fstype && strcmp(detected_fstype, mp->mnt_type))) | |
1801 | + mp->mnt_type = detected_fstype; | |
1802 | + } | |
1794 | 1803 | |
1795 | 1804 | // Might this be a virtual filesystem? |
1796 | 1805 | if (ENABLE_FEATURE_MOUNT_HELPERS && strchr(mp->mnt_fsname, '#')) { |
@@ -2067,6 +2076,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | ||
2067 | 2076 | opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv"); |
2068 | 2077 | opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch |
2069 | 2078 | IF_FEATURE_MOUNT_VERBOSE(, &verbose)); |
2079 | + | |
2080 | + if (opt & OPT_t) user_fstype = 1; | |
2070 | 2081 | while (lst_o) append_mount_options(&cmdopts, llist_pop(&lst_o)); // -o |
2071 | 2082 | if (opt & OPT_r) append_mount_options(&cmdopts, "ro"); // -r |
2072 | 2083 | if (opt & OPT_w) append_mount_options(&cmdopts, "rw"); // -w |
@@ -2280,6 +2291,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | ||
2280 | 2291 | mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); |
2281 | 2292 | append_mount_options(&(mtcur->mnt_opts), cmdopts); |
2282 | 2293 | resolve_mount_spec(&mtpair->mnt_fsname); |
2294 | + if (user_fstype) | |
2295 | + mtcur->mnt_type = fstype; | |
2283 | 2296 | rc = singlemount(mtcur, /*ignore_busy:*/ 0); |
2284 | 2297 | if (ENABLE_FEATURE_CLEAN_UP) |
2285 | 2298 | free(mtcur->mnt_opts); |