summaryrefslogtreecommitdiff
path: root/util-linux/mount.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-18 21:08:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-18 21:08:49 +0000
commitde7684a309ad20c1b889d048d741cb1dd52245f7 (patch)
treeefae3387e1978cdd128ff2a922b734d0e9d0180f /util-linux/mount.c
parent27dd495b98a6135554b1d839fefe436ba3c6ca71 (diff)
downloadbusybox-w32-de7684a309ad20c1b889d048d741cb1dd52245f7.tar.gz
busybox-w32-de7684a309ad20c1b889d048d741cb1dd52245f7.tar.bz2
busybox-w32-de7684a309ad20c1b889d048d741cb1dd52245f7.zip
support for mount by label (not yet tested)
Also adds findfs applet. Closes bug 1143.
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r--util-linux/mount.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 8b3230935..b19c3a3ef 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -19,10 +19,13 @@
19*/ 19*/
20 20
21#include <mntent.h> 21#include <mntent.h>
22#include "libbb.h"
23#include <syslog.h> 22#include <syslog.h>
23#include "libbb.h"
24 24
25/* Needed for nfs support only... */ 25/* For FEATURE_MOUNT_LABEL only */
26#include "volume_id.h"
27
28/* Needed for nfs support only */
26#include <sys/utsname.h> 29#include <sys/utsname.h>
27#undef TRUE 30#undef TRUE
28#undef FALSE 31#undef FALSE
@@ -245,6 +248,22 @@ static int verbose_mount(const char *source, const char *target,
245#define verbose_mount(...) mount(__VA_ARGS__) 248#define verbose_mount(...) mount(__VA_ARGS__)
246#endif 249#endif
247 250
251static int resolve_mount_spec(char **fsname)
252{
253 char *tmp = NULL;
254
255 if (!strncmp(*fsname, "UUID=", 5))
256 tmp = get_devname_from_uuid(*fsname + 5);
257 else if (!strncmp(*fsname, "LABEL=", 6))
258 tmp = get_devname_from_label(*fsname + 6);
259
260 if (tmp) {
261 *fsname = tmp;
262 return 1;
263 }
264 return 0;
265}
266
248/* Append mount options to string */ 267/* Append mount options to string */
249static void append_mount_options(char **oldopts, const char *newopts) 268static void append_mount_options(char **oldopts, const char *newopts)
250{ 269{
@@ -1781,6 +1800,9 @@ int mount_main(int argc, char **argv)
1781 mtpair->mnt_dir = argv[1]; 1800 mtpair->mnt_dir = argv[1];
1782 mtpair->mnt_type = fstype; 1801 mtpair->mnt_type = fstype;
1783 mtpair->mnt_opts = cmdopts; 1802 mtpair->mnt_opts = cmdopts;
1803 if (ENABLE_FEATURE_MOUNT_LABEL) {
1804 resolve_mount_spec(&mtpair->mnt_fsname);
1805 }
1784 rc = singlemount(mtpair, 0); 1806 rc = singlemount(mtpair, 0);
1785 goto clean_up; 1807 goto clean_up;
1786 } 1808 }
@@ -1842,6 +1864,9 @@ int mount_main(int argc, char **argv)
1842 1864
1843 mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); 1865 mtcur->mnt_opts = xstrdup(mtcur->mnt_opts);
1844 append_mount_options(&(mtcur->mnt_opts), cmdopts); 1866 append_mount_options(&(mtcur->mnt_opts), cmdopts);
1867 if (ENABLE_FEATURE_MOUNT_LABEL) {
1868 resolve_mount_spec(&mtpair->mnt_fsname);
1869 }
1845 rc = singlemount(mtcur, 0); 1870 rc = singlemount(mtcur, 0);
1846 free(mtcur->mnt_opts); 1871 free(mtcur->mnt_opts);
1847 } 1872 }
@@ -1884,6 +1909,9 @@ int mount_main(int argc, char **argv)
1884 bb_error_msg_and_die(must_be_root); 1909 bb_error_msg_and_die(must_be_root);
1885 1910
1886 // Mount this thing. 1911 // Mount this thing.
1912 if (ENABLE_FEATURE_MOUNT_LABEL) {
1913 resolve_mount_spec(&mtpair->mnt_fsname);
1914 }
1887 1915
1888 // NFS mounts want this to be xrealloc-able 1916 // NFS mounts want this to be xrealloc-able
1889 mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); 1917 mtcur->mnt_opts = xstrdup(mtcur->mnt_opts);