]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: first look for mountpoint
authorKarel Zak <kzak@redhat.com>
Wed, 29 Jun 2011 07:02:50 +0000 (09:02 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 29 Jun 2011 07:02:50 +0000 (09:02 +0200)
  # mount <device|dir>

The current code looks for a device and then for a mountpoint in
/etc/fstab. This is not user friendly solution. People usually use

 # mount /dir

to mount any filesystem. It makes more sense to check for mountpoint
and if not found then for device.

This is also important for bind mounts, for example if you have in
your fstab:

/dev/sda1 /mnt/foo auto defaults
/mnt/foo /mnt/bar none bind

then
# mount /mnt/foo

should be interpreted as the first entry and /dev/sda1 should be
mounted.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=716483
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/mount.8
mount/mount.c

index 89825376921fa7b8d8f7a57dfebf0c0c94780c14..e9a52dd55c6608c90f6d23de5ffce5e4969762a7 100644 (file)
@@ -101,6 +101,17 @@ the pathname
 refers to the root of the filesystem on
 .IR device .
 
+If only directory or device is given, for example:
+.RS
+
+.br
+.BI "mount /dir"
+.br
+
+.RE
+then mount looks for a mountpoint and if not found then for a device in the
+/etc/fstab file.
+
 .B The listing and help.
 .RS
 Three forms of invocation do not actually mount anything:
index 3ba705f3ee292e0bf79295610536e66f99401b21..00637f52bc476adb26cdf33965148a7111177653 100644 (file)
@@ -2347,10 +2347,10 @@ getfs(const char *spec, const char *uuid, const char *label)
        else if (label)
                mc = getfs_by_label(label);
        else {
-               mc = getfs_by_spec(spec);
+               mc = getfs_by_dir(spec);
 
                if (!mc)
-                       mc = getfs_by_dir(spec);
+                       mc = getfs_by_spec(spec);
        }
        if (mc)
                return mc;