summaryrefslogtreecommitdiffstats
path: root/sys-utils/mount.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add print_version() macroKarel Zak2019-04-161-2/+2
| | | | | | | | | | | Let's consolidate the version printing code. It also seems better to use exit() after --version, because it's handled in different way by ASAN. It's strange, but ASAN reports leaks after return in main(). Note that we do not use free-before-exit. Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: Do not call mnt_pretty_path() on net file systems.Stanislav Brabec2019-02-061-1/+1
| | | | | | | | | | | | Calling mnt_pretty_path() on network file systems can cause mangling of the output: root# mount | grep nfs nfs.example.com:/home on /home type nfs4 ... root# mkdir -p nfs.example.com:/home root# mount | grep nfs /root/nfs.example.com:/home on /home type nfs4 ... Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: add support for MS_REMOUNT on --allKarel Zak2019-01-161-1/+55
| | | | | | | | | | | | | This patch add to support for remount-all operation to libmount and mount(8). For example: mount --all -o remount,ro -t vfat to remount read-only all VFAT filesystems. Addresses: https://github.com/karelzak/util-linux/issues/589 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: allow PID as --namespace argumentVaclav Dolezal2018-06-111-2/+23
| | | | | | | [[kzak@redhat.com: - update code] Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* mount: document --namespace in man/helpVaclav Dolezal2018-06-111-0/+2
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: make errno usable after mnt_context_set_target_ns()Karel Zak2018-06-111-6/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: add support for namespacesVaclav Dolezal2018-06-111-1/+11
| | | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: keep MS_MOVE as flagKarel Zak2018-06-011-2/+6
| | | | | | | | The previous commit 4ebea84bb1ca6b0fa817588aba13de26c8d5e5a0 replaced all operations by strings, but it does not work for MS_MOVE as this operation is not supported in fstab by libmount. Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: use internally string to set move/bind operationsKarel Zak2018-06-011-8/+7Star
| | | | | | | | | It's better to inform libmount about operations by string than by flags, because for example "rbind,slave" cannot be specified by MS_REC|MS_BIND|MS_SLAVE. https://bugzilla.redhat.com/show_bug.cgi?id=1584443 Signed-off-by: Karel Zak <kzak@redhat.com>
* nls: remove translation stringsSami Kerola2018-05-281-1/+1
| | | | | | | | | | While looking earlier commit I noticed everything but formatting was removed from a message in namei.c file. That inspired me to look if there are more strings that does not need translation project attention. This change removes at least some of them, if not all. Reference: e19cc7b65b31c57f0fe9cb73c9afad5197796f82 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mount: use string_to_bitmask()Vaclav Dolezal2018-03-281-29/+32
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* mount: document --options-* in man/helpVaclav Dolezal2018-02-081-0/+7
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* mount: added options exposing libmount's optsmodeVaclav Dolezal2018-02-011-1/+74
| | | | | | | | | | | Added: --options-mode={ignore,append,prepend,replace} MNT_OMODE_{IGNORE, ...} --options-source={fstab,mtab,disable} MNT_OMODE_{FSTAB,MTAB,NOTAB} --options-source-force MNT_OMODE_FORCE See mnt_context_set_optsmode() documentation for details. Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 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>