Use warnx(), as there is no strerror() text associated with it.
There is currently no easy way to report name and type of conflict.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
If the loop device is already initialized read-only, the new code for loop
device reuse returns -EROFS. There is no solution of this situation. But mount
can behave in the same way, as it does for EROFS returned by mount syscall: Try
again in read-only mode.
Before:
mount: /mnt/2: mount failed: Read-only file system
After:
mount: /btrfs.img is used as read only loop, mounting read-only
Note: It would be nice to mention loop device name in the warning message, but
it is not available in the mount context.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Earlier output did not give enough information to system admin to fix an
issue in /etc/fstab effectively.
$ sudo mount -a
mount: mount(2) failed: No such file or directory
Addresses: https://bugs.launchpad.net/bugs/1557145
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Allow people to use nofail to ignore empty cd/dvd drive errors.
URL: https://bugs.gentoo.org/559356
Reported-by: William Hubbs <williamh@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The libmount provides way how to deal with parsing errors in fstab --
on error callback function is executed and according to the return
libmount manipulate with the malformed line, possible are three
states:
1/ fatal error; all file ignored (callback rc < 0)
2/ recoverable error; malformed line ignored (callback rc > 0)
3/ ignore the error (callback rc == 0)
The 2/ is the default if no callback specified.
Unfortunately our utils uses 3/. The correct way is to use 2/.
Signed-off-by: Karel Zak <kzak@redhat.com>
mount(8) tries to mount read-only when the previous attempt ends with
EROFS or EACCES. This is bad idea for bind mounts as "ro,bind" has
a special semantic.
Signed-off-by: Karel Zak <kzak@redhat.com>
This adds a concise description of a tool to its usage text.
A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
# mkfs.ext4 /dev/sda1
# mount -t foo,bar /dev/sda1 /mnt
successfully mount the device, this is unexpected as extN is no
between wanted (by -t specified) filesystems.
Summary about -t:
* "mount -t foo" mount(2) with "foo" type
* "mount -t foo,bar" try mount(2) with "foo" or "bar"
* "mount -t foo,auto" try mount(2) with "foo" or ask libblkid for
the type
* "mount -t nofoo,bar" try types from /{etc,proc}/filesystems, but
exclude "foo" and "bar"
Note that more filesystems may be specified in fstab (as comma
delimited list). The stuff from fstab is always interpreted as list
and never as a pattern ("no" prefix makes no sense in fstab).
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
fstab:
UUID=nonexist /mnt/nonexist1 ext4 nofail 0 1
# mount -av
mount: can't find UUID=nonexist
.. this is bug of course.
Reported-by: Patrick McLean <chutzpah@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Now the "nofail" affects warnings warning messages only. That's wrong
and regression (against original non-libmount version). The nofail has
to control return code too.
Reported-by: Patrick McLean <chutzpah@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
The option is unsupported since v2.23, let's cleanup man pages and
code to remove it at all.
Reported-by: "Dale R. Worley" <worley@alum.mit.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
The libmount does not care if we set source or target, it's able to
swap it, but the mount.c function sanitize_paths() does not work as
expected if we set NAME=value as target. It means that
$ mount LABEL=foo
does not work for non-root users (since 51e3530cdc, v2.24).
This patch also checks if source or target is specified more
than once.
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount ignores "ambivalent probing result" from libblkid and tries
filesystems /etc/filesystems. This is incorrect behavior.
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Presently, libmount-mount completely prohibits the use of -t by non-root
users. This breaks using -t in listing mode as a user, which represents
a regression against mount-deprecated, macosx and presumably *BSD.
This commit fixes the issue by deferring the mnt_context_is_restricted
check for -t until we know we're not in listing mode.
Signed-off-by: Rich Tollerton <rich.tollerton@ni.com>
$ mount /root/.ssh/../../dev/sda2
mount: only root can mount UUID=17bc65ec-4125-4e7c-8a7d-e2795064c736 on /boot
this is too promiscuous. It seems better to ignore on command line
specified paths which are not resolve-able for non-root users.
Fixed version:
$ mount /root/.ssh/../../dev/sda2
mount: /root/.ssh/../../dev/sda2: Permission denied
$ mount /dev/sda2
mount: only root can mount UUID=17bc65ec-4125-4e7c-8a7d-e2795064c736 on /boot
Note that this bug has no relation to mount(2) permissions evaluation
in suid mode. The way how non-root user specifies paths on command
line is completely irrelevant for comparison with fstab entries.
Signed-off-by: Karel Zak <kzak@redhat.com>
kernel cryptoloop is deprecated since ages and support for cryptoloop
in util-linux is incomplete/broken.
- no password hashing
- last 8 bit of key are always set to zero
- no binary keys possible (stops reading key at \n and \0)
In the past some Distros added the above features with patches. So
remove cryptoloop support from util-linux completely to make sure
people won't try using it.
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
For compatibility with coreutils and to avoid complex solutions in
mount output mount replaces control characters with '?'.
Note that the listing mode in mount(8) is in maintenance mode --
findmnt(8) provides more robust and better solutions.
Signed-off-by: Karel Zak <kzak@redhat.com>
In some cases (for example if only one mount argument is given) may be
mount request ambivalent:
# mount /foo
and fstab:
/dev/sda5 /foo rw 0 0
/foo /bar bind 0 0
the new options allows to be more explicit
# mount --target /foo (mounts /dev/sda5)
# mount --source /foo (binds /foo to /bar)
It's possible to use the options together
# mount --source /dev/sda2 --target /home
Signed-off-by: Karel Zak <kzak@redhat.com>
# mount -R /mnt/test /mnt/test
mount: propagation flags (--make-* or --bind options) are mutually exclusive
Reported-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
We have to be careful with "none" or another dummy sources for pseudo
filesystems. These strings should be canonicalized or compared as a
paths.
The function is not exported by library API.
Signed-off-by: Karel Zak <kzak@redhat.com>