summaryrefslogtreecommitdiffstats
path: root/sys-utils/mount.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: never use usage(stderr)Ruediger Meier2017-06-261-9/+16
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix xalloc.h related exit codesRuediger Meier2017-06-221-1/+3
| | | | | | | | | Found by: grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \ $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c")) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix more strutils related exit codesRuediger Meier2017-06-221-0/+2
| | | | | | | | | | | | Found by grep: grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \ strutils_set_exitcode $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c")) The Command shows also some false positives (fstrim.c, context_mount.c, ...) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: add read-only warningKarel Zak2017-04-281-6/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: use MNT_EX_* from libmountKarel Zak2017-04-271-29/+28Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount, umount: use mnt_context_get_excode()Karel Zak2017-04-271-343/+17Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: support MS_RDONLY on write-protected devicesKarel Zak2017-04-261-31/+15Star
| | | | | | | | This feature is supported by mount(8) only. It seems better move this code to libmount. The results is more simple mount(8) and the feature is accessible for all libmount users. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-34/+34
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* Use --help suggestion on invalid optionKarel Zak2016-12-191-2/+1Star
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: Handle MNT_ERR_LOOPOVERLAPStanislav Brabec2016-08-031-0/+3
| | | | | | | | 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>
* mount: Handle EROFS before calling mount() syscallStanislav Brabec2016-04-221-0/+9
| | | | | | | | | | | | | | | | | | 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>
* mount: try to tell what mount was doing when it failedSami Kerola2016-04-171-2/+7
| | | | | | | | | | | 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>
* mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messagesBenno Schulenberg2016-03-161-2/+1Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* mount: allow nofail to silence ENOMEDIUM casesMike Frysinger2016-01-211-0/+3
| | | | | | | | 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>
* mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed linesKarel Zak2015-10-151-1/+1
| | | | | | | | | | | | | | | | | 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: remove duplications of --help and --version from usage textBenno Schulenberg2015-08-031-5/+6
| | | | | | And slice up the affected portions. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* mount: don't remount read-only on --bindKarel Zak2015-03-201-0/+3
| | | | | | | | 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>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | 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>
* mount: don't ignore mtab for --bind -o remountKarel Zak2014-10-171-2/+12
| | | | | Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't use /{proc,ext}/filesystems when more fs types specifiedKarel Zak2014-07-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | # 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>
* mount: apply "nofail" to MNT_ERR_NOSOURCE libmount errorKarel Zak2014-04-071-0/+2
| | | | | | | | | | | | | 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>
* mount: fix --all and nofail return codeKarel Zak2014-04-071-4/+6
| | | | | | | | | 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>
* losetup, mount: remove --pass-fd at allKarel Zak2014-01-061-6/+2Star
| | | | | | | | 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>
* mount: make NAME=value tags usable for non-rootKarel Zak2013-11-191-4/+22
| | | | | | | | | | | | | | | 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 51e3530cdcb1d4f3ab91ae953ebc5adcdc5f9239, v2.24). This patch also checks if source or target is specified more than once. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use libmnt_table reference counterKarel Zak2013-08-211-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use libmnt_cache reference countingKarel Zak2013-08-211-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: more robust options string parsingKarel Zak2013-05-301-0/+2
| | | | | | | | | # mount -o=rw /dev/sdb /mnt/test mount: libmount/src/optmap.c:212: mnt_optmap_get_entry: Assertion `namelen' failed. Aborted (core dumped) Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=968786 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: add --read-write to man pageKarel Zak2013-04-051-1/+1
|
* mount: improve --move error message on shared treesKarel Zak2013-03-251-6/+40
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: correctly propagate ambivalent blkid probing resultsKarel Zak2013-02-131-0/+5
| | | | | | | | 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>
* mount: fix bind mount success messageBernhard Voelker2013-02-061-1/+1
| | | | | | * sys-utils/mount.c (success_message): s/binded/bound/. Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* mount: make --verbose more verbose about propagationKarel Zak2013-01-151-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: write success messages to stdoutKarel Zak2013-01-151-5/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: support multiple MS_PROPAGATION flags in one mount(8) execKarel Zak2013-01-151-27/+37
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: Fix -t in listing mode when run as non-rootRichard Tollerton2013-01-091-1/+6
| | | | | | | | | | | 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: sanitize paths from non-root usersKarel Zak2012-11-261-0/+35
| | | | | | | | | | | | | | | | | | | | | | $ 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>
* mount: supports paths canonicalization for alternative fstabsKarel Zak2012-10-241-0/+10
| | | | | | | | # mount --fstab /path/my.fstab has to support standard operations with paths. Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: add verbose messagesKarel Zak2012-10-091-1/+25
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=864227 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: losetup: remove obsolete encryption supportLudwig Nussel2012-09-111-40/+2Star
| | | | | | | | | | | | | | | 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>
* mount: replace control chars in mountpoint nameKarel Zak2012-08-061-1/+20
| | | | | | | | | | 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>
* mount: remove unnecessary free()Karel Zak2012-07-261-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: use err_exclusive_options()Karel Zak2012-07-261-33/+14Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: (new) add --source and --targetKarel Zak2012-07-171-25/+73
| | | | | | | | | | | | | | | | | | | | | | | | 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: (new) use exclusive_option()Sami Kerola2012-06-171-7/+28
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mount: (new) allow sloppy for non-rootKarel Zak2012-06-141-1/+1
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=825836 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: (new) fix MS_REC usageKarel Zak2012-05-281-1/+1
| | | | | | | | # 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>
* libmount: add MNT_ERR_MOUNTOPTKarel Zak2012-05-281-0/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: (new) add loopdev specific error messageKarel Zak2012-05-281-3/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sys-utils: cleanup strtoxx_or_err()Karel Zak2012-05-151-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>