Commit Graph

31 Commits

Author SHA1 Message Date
Benno Schulenberg b779c1aecb mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:38 +01:00
Karel Zak 1cd9d0d746 mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed lines
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>
2015-10-15 12:01:48 +02:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
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>
2015-01-06 11:27:38 +01:00
Karel Zak 86c58c4a82 umount: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 15:12:35 +02:00
Nicolas Boichat a9add961e9 umount: Make sure exit code does not overflow
POSIX exit code is only 8-bit, and since umount sums up error
codes, it can sometimes report success (exit code 0) even though
a number of operations failed.

For example, running, in an empty directory:
 umount `seq 1 7`
returns 224 (7*32), since none of the 7 mount point exists but
 umount `seq 1 8`
returns 0 (8*32=256)

This patch clips the return value to 255.

Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
2014-06-07 21:46:02 +08:00
Karel Zak fd7c492401 umount: add info that --all-targets works with mtab symlink only
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-26 11:37:02 +02:00
Jonathan Liu 8356d27d66 umount: fix typo in usage
Signed-off-by: Jonathan Liu <net147@gmail.com>
2014-04-07 12:38:20 +02:00
Karel Zak 0ce2fe8738 umount: more robust success message for --all
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-07 12:00:51 +02:00
Karel Zak d41acf740e umount: fix umount by tag for non-roots
$ umount LABEL=foo

currently does not work for non-root users as umount uses the
LABEL= as a path in sanitize_path().

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-19 17:55:12 +01:00
Karel Zak 726f9fbf46 umount: provide more helpful error message
non-root user on device that is not mounted:

 $ umount /mnt/flash
 umount: /mnt/flash: umount failed: Operation not permitted

this is true, because we cannot evaluate permissions as there is no
entry in mtab, but users expect something more helpful -- for example

 umount: /mnt/flash: not mounted

References: https://bugs.archlinux.org/task/31647
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-27 10:06:44 +02:00
Karel Zak 50fccba1ab misc: use libmnt_table reference counter
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 16:07:51 +02:00
Karel Zak 7ba207e781 libmount: be robust for empty target/source strings
* lib/canonicalize.c: don't interpret empty strings as relative paths
 * libmount: more robust libmnt_table find function and debug messages

References: https://bugzilla.novell.com/show_bug.cgi?id=825150
Signed-off-by: Karel Zak <kzak@redhat.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-17 13:02:15 +02:00
Benno Schulenberg 4ce393f4d8 textual: fix several typos and angular brackets in messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-06-07 12:11:14 +02:00
Karel Zak f697d61b6e umount: use devno to identify --all-target devices
# mount -t tmpfs tmp /mnt/A
 # mount --bind /mnt/A /mnt/B
 # mount -t tmpfs tmp /mnt/C

the command:

  umount --all-targets /mnt/A

has to umount only A and B, but not C. The C is a another filesystem.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-23 10:25:02 +02:00
Karel Zak 6f7bce8651 umount: add note about namespaces too --all-targets
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-27 11:23:33 +01:00
Karel Zak 4eb49f6392 umount: add --all-targets
The same source (whole filesystem or filesystems subvolume) could be
mounted on more targets (mountpoints). For example bind mounts or
btrfs sub-volumes.

If you want to detach the source device from the system then you need
to unmount all the mountpoints.

 umount --all-targets <device|mountpoint>

provides this functionality. This option could be used together with
--recursive. Then all nested mountpoints within the filesystem are
unmounted too. For example:

 umount --recursive --all-targets /dev/sdb1

should be a way how to make the device unmounted at all.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-26 14:50:26 +01:00
Sami Kerola 83d9110053 umount: make usage() translator friendly
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 16:40:05 +01:00
Karel Zak cc8cc8f32c umount: sanitize paths from non-root users
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26 16:25:46 +01:00
Dave Reisner 7b4a2697b1 umount: (recursive) add a cache to the table
Without this table libmount will not resolve paths, meaning that
umounting by relative path will fail.

[kzak@redhat.com: - use mnt_context_get_cache() to make it sensitive
                    to --no-canonicalize cmdline option]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-16 10:41:36 +01:00
Karel Zak ae978c4d6c umount: (recursive) don't call umount(2) for already unmounted targets
In the umount --recursive we follow entries from mountinfo, but the
entries maybe already obsolete. Especially if the hierarchy of the
mountpoints contains shared subtrees and umount(2) for one entry may
generate umount for some other entry too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-15 16:44:07 +01:00
Karel Zak a8cc72dea0 umount: clean --recursive
- mark some options combinations mutually exclusive
 - reset libmount context before next umount (this is important!)

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-15 11:55:48 +01:00
Karel Zak 06069d5f63 umount: allways return MOUNT_EX_*
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 16:50:02 +01:00
Dave Reisner 13ee1c9116 umount: add -R, --recursive option
This allows unmounting of an entire tree of filesystems, which might be
of particular interest for a shutdown initramfs.

[kzak@redhat.com: - always return MOUNT_EX_* codes
                  - cosmetic changes on coding style]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 16:46:07 +01:00
Karel Zak 84600ddc6d mount: add verbose messages
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=864227
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-09 11:56:35 +02:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Karel Zak 7e1b144664 umount: add missing break
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-31 20:58:30 +01:00
Karel Zak 0f2d647611 umount: (new) fix resource leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:49:23 +01:00
Karel Zak ac8ecab4be mount: add info about libmount features to --version output
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-23 12:28:05 +01:00
Karel Zak 73f9a11404 umount: (new) use the same exit codes as mount(8)
Note that old umount(8) uses 0 and 1 exit codes, and some
exceptions like 4 or 32.

The new umount(8) cleanups this mess and uses the same exit codes as
mount(8) (see mount(8) man page).

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-23 11:15:41 +01:00
Karel Zak ecdba5ddfc build-sys: add --enable-new-mount
Now we have three versions of the mount(8) utility

 * old mount(8)
   --enable-mount [default]

 * old mount(8) linked with libmount
   This is this is necessary for systems without mtab file.
   --enable-libmount-mount

 - new mount(8)
   This is completely new pure-libmount based mount(8).
   --enable-new-mount

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-11 17:05:08 +01:00