diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-10 11:39:18 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-10 11:39:18 +0000 |
| commit | 6a2d0d9b8d90ba76c2f90fc352acc886bd3e578d (patch) | |
| tree | 99df3d7e42990f69b4595e4241d054a8aea84df2 /util-linux | |
| parent | 3f8f4b2a93524c3c420241256a0c8cf915446bc7 (diff) | |
| download | busybox-w32-6a2d0d9b8d90ba76c2f90fc352acc886bd3e578d.tar.gz busybox-w32-6a2d0d9b8d90ba76c2f90fc352acc886bd3e578d.tar.bz2 busybox-w32-6a2d0d9b8d90ba76c2f90fc352acc886bd3e578d.zip | |
mount: make it more readable
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mount.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index 1c371518c..3b8311318 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
| @@ -256,23 +256,22 @@ static int verbose_mount(const char *source, const char *target, | |||
| 256 | #define verbose_mount(...) mount(__VA_ARGS__) | 256 | #define verbose_mount(...) mount(__VA_ARGS__) |
| 257 | #endif | 257 | #endif |
| 258 | 258 | ||
| 259 | static int resolve_mount_spec(char **fsname) | 259 | #if ENABLE_FEATURE_MOUNT_LABEL |
| 260 | static void resolve_mount_spec(char **fsname) | ||
| 260 | { | 261 | { |
| 261 | char *tmp = NULL; | 262 | char *tmp = NULL; |
| 262 | 263 | ||
| 263 | #if ENABLE_FEATURE_MOUNT_LABEL | ||
| 264 | if (!strncmp(*fsname, "UUID=", 5)) | 264 | if (!strncmp(*fsname, "UUID=", 5)) |
| 265 | tmp = get_devname_from_uuid(*fsname + 5); | 265 | tmp = get_devname_from_uuid(*fsname + 5); |
| 266 | else if (!strncmp(*fsname, "LABEL=", 6)) | 266 | else if (!strncmp(*fsname, "LABEL=", 6)) |
| 267 | tmp = get_devname_from_label(*fsname + 6); | 267 | tmp = get_devname_from_label(*fsname + 6); |
| 268 | #endif | ||
| 269 | 268 | ||
| 270 | if (tmp) { | 269 | if (tmp) |
| 271 | *fsname = tmp; | 270 | *fsname = tmp; |
| 272 | return 1; | ||
| 273 | } | ||
| 274 | return 0; | ||
| 275 | } | 271 | } |
| 272 | #else | ||
| 273 | #define resolve_mount_spec(fsname) ((void)0) | ||
| 274 | #endif | ||
| 276 | 275 | ||
| 277 | // Append mount options to string | 276 | // Append mount options to string |
| 278 | static void append_mount_options(char **oldopts, const char *newopts) | 277 | static void append_mount_options(char **oldopts, const char *newopts) |
| @@ -1798,9 +1797,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
| 1798 | mtpair->mnt_dir = argv[1]; | 1797 | mtpair->mnt_dir = argv[1]; |
| 1799 | mtpair->mnt_type = fstype; | 1798 | mtpair->mnt_type = fstype; |
| 1800 | mtpair->mnt_opts = cmdopts; | 1799 | mtpair->mnt_opts = cmdopts; |
| 1801 | if (ENABLE_FEATURE_MOUNT_LABEL) { | 1800 | resolve_mount_spec(&mtpair->mnt_fsname); |
| 1802 | resolve_mount_spec(&mtpair->mnt_fsname); | ||
| 1803 | } | ||
| 1804 | rc = singlemount(mtpair, 0); | 1801 | rc = singlemount(mtpair, 0); |
| 1805 | return rc; | 1802 | return rc; |
| 1806 | } | 1803 | } |
| @@ -1881,12 +1878,12 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
| 1881 | if (nonroot) | 1878 | if (nonroot) |
| 1882 | bb_error_msg_and_die(must_be_root); | 1879 | bb_error_msg_and_die(must_be_root); |
| 1883 | 1880 | ||
| 1884 | // Mount this thing | 1881 | resolve_mount_spec(&mtpair->mnt_fsname); |
| 1885 | if (ENABLE_FEATURE_MOUNT_LABEL) | ||
| 1886 | resolve_mount_spec(&mtpair->mnt_fsname); | ||
| 1887 | 1882 | ||
| 1888 | // NFS mounts want this to be xrealloc-able | 1883 | // NFS mounts want this to be xrealloc-able |
| 1889 | mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); | 1884 | mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); |
| 1885 | |||
| 1886 | // Mount this thing | ||
| 1890 | if (singlemount(mtcur, 1)) { | 1887 | if (singlemount(mtcur, 1)) { |
| 1891 | // Count number of failed mounts | 1888 | // Count number of failed mounts |
| 1892 | rc++; | 1889 | rc++; |
| @@ -1911,9 +1908,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
| 1911 | // Mount the last thing we found | 1908 | // Mount the last thing we found |
| 1912 | mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); | 1909 | mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); |
| 1913 | append_mount_options(&(mtcur->mnt_opts), cmdopts); | 1910 | append_mount_options(&(mtcur->mnt_opts), cmdopts); |
| 1914 | if (ENABLE_FEATURE_MOUNT_LABEL) { | 1911 | resolve_mount_spec(&mtpair->mnt_fsname); |
| 1915 | resolve_mount_spec(&mtpair->mnt_fsname); | ||
| 1916 | } | ||
| 1917 | rc = singlemount(mtcur, 0); | 1912 | rc = singlemount(mtcur, 0); |
| 1918 | if (ENABLE_FEATURE_CLEAN_UP) | 1913 | if (ENABLE_FEATURE_CLEAN_UP) |
| 1919 | free(mtcur->mnt_opts); | 1914 | free(mtcur->mnt_opts); |
