summaryrefslogtreecommitdiffstats
path: root/libmount/src/context.c
Commit message (Collapse)AuthorAgeFilesLines
* libmount: add support for MS_REMOUNT on --allKarel Zak2019-01-161-0/+43
| | | | | | | | | | | | | 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>
* libmount: keep namespaces support optionalKarel Zak2018-10-051-4/+18
| | | | | Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup licenses sections in the filesKarel Zak2018-08-161-3/+8
| | | | | | | | | * add SPDX-License-Identifier (see https://spdx.org/licenses/) * add "This file part of libmount from util-linux project." * use proper text for LGPL-2.1-or-later * use the same texts everywhere Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: report context paths on debugKarel Zak2018-08-141-2/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add since tag for new functionsKarel Zak2018-07-191-0/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: switch namespace when appropriateVaclav Dolezal2018-06-111-16/+133
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: make errno usable after mnt_context_set_target_ns()Karel Zak2018-06-111-4/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: note namespaces in mnt_reset_context() docsVaclav Dolezal2018-06-111-2/+3
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: add support for switching namespacesVaclav Dolezal2018-06-111-0/+202
| | | | | | | [kzak@redhat.com: - cosmetic changes, add some comments] 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-1/+4
| | | | | | | | 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>
* libmount: improve MS_REC usageKarel Zak2018-06-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | libmount allows to split one library (mount(8)) call to multiple mount(2) syscalls, for example --rbind --make-rslave in this case we have to be careful with MS_REC because the flag is applied to multiple operations. # strace -e mount mount --rbind --make-rslave /mnt/A /mnt/B Old version: mount("/mnt/A", "/mnt/B", 0x13ecac0, MS_MGC_VAL|MS_BIND, NULL) = 0 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0 Fixed version: mount("/mnt/A", "/mnt/B", 0x1f22ac0, MS_MGC_VAL|MS_BIND|MS_REC, NULL) = 0 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1584443 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make mnt_context_is_fs_mounted work for /procIvan Delalande2017-07-181-2/+12
| | | | | | | | | | | | Assume that /proc is not mounted instead of returning an error when we are unable to open the mounts and mountinfo files in /proc. Also set cxt->mtab back to NULL so that it gets properly parsed when we check if the next filesystem is mounted. The goal is to have mount -a work when /proc is not mounted, typically with /proc on the first line of fstab. Signed-off-by: Ivan Delalande <colona@arista.com>
* libmount: ignore "bind" from fstab on command line "remount"Karel Zak2017-06-201-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code always apply all flags from /etc/fstab on remount. Unfortunately remount+bind has special semantic and it's impossible from command line to avoid interaction with the "bind" from fstab. Example, fstab: /dev/sda1 /bar ext4 defaults 0 1 /bar /foo none bind 0 0 Command line: # mount /foo -o remount,rw produces: mount(... MS_REMOUNT|MS_BIND ) syscall This changes the per-mountpoint (VFS) ro flag to rw, but doesn't change the filesystem itself. This patch forces libmount to ignore "bind" from fstab when "-o remount" specified on command line. If you need remount+bind semantic you have to specify the "bind" flag on command line. This allow to differentiate between # mount /foo -o remount,bind,rw --> mount(MS_REMOUNT|MS_BIND) and # mount /foo -o remount,rw --> mount(MS_REMOUNT) Suggested-by: NeilBrown <neilb@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: use mount table filter on --no-canonicalizeKarel Zak2017-06-071-6/+7
| | | | | | | The umount command option --no-canonicalize means that the path is already canonical. So, we can use mount table filter in this case too. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (docs) add missing 'since' tagsKarel Zak2017-05-231-0/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (docs) remove unwanted tagKarel Zak2017-04-281-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add read-only warningKarel Zak2017-04-281-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_context_get_excode()Karel Zak2017-04-271-1/+96
| | | | | | | | | | | | | | | | It's pretty complex task to make mount(8) and umount(8) return code and generate error message. It seems better to do that in the libmount rather than force all library users to duplicate mount(8) mk_exit_code() functions. It also means that all the messages will be translated only once. Changes: * all error messages are printed by warn() * no more multi-line messages * all messages prefixed by mount target (mountpoint) * library provides mount(8) compatible MNT_EX_* codes Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1429531 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: support MS_RDONLY on write-protected devicesKarel Zak2017-04-261-1/+46
| | | | | | | | 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>
* tests: add static keyword where needed [smatch scan]Sami Kerola2017-03-171-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: revert X-* and x-* meaningKarel Zak2016-12-091-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's hope this is last change necessary to cleanup x-* usage: x-* persistent option, stored in utab, available for umount, etc. X-* fstab comment only mount(8) supports x-mount.mkdir= as well as newly recommended X-mount.mkdir= Advantages: * less invasive * does not require exception for x-systemd * does not require rename x-initrd to X-initrd The systemd and dracut users will get the new (=fixed) functionality without a change in fstab configuration. This is the primary goal. Disadvantages: * not 100% compatible libmount behavior, x-* options have not been previously stored in utab. The API is the same, options will be still available, but on x-* libmount will write to /run/mount/utab. For now it seems only systemd uses x-*, and they like this behavior, so... Addresses: https://github.com/systemd/systemd/pull/4515 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't check nonnull attributes for NULL [-Wnonnull-compare]Karel Zak2016-06-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-12/+12
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libmount: don't support /etc/mtab by defaultKarel Zak2016-04-141-4/+9
| | | | | | | | | | | | | | | | | The file mtab is evil and already unused by mainstream distributions. Now libmount is able to detect mtab->/proc/mounts and use /proc/self/mountinfo if necessary. This heuristic seems overkill in many cases. It's also dangerous on systems where mountinfo is strongly required (systemd based distros). This patch #ifdefs mtab code and forces libmount to always use /proc/self/mountinfo. The new configure option --enable-libmount-support-mtab is necessary to enable old behavior to support mtab. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-231-4/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: use fstatat(AT_NO_AUTOMOUNT) for mountpointsKarel Zak2015-12-091-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup assert() usageKarel Zak2015-08-041-14/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: do not call umount helper on --fakeKarel Zak2015-06-031-3/+3
| | | | | | | | | The umount.<type> helpers does not support --fake option and it does not make sense to call the helpers at all. All we need is to remove mtab/utab entries. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1172297 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: remove assert(arg) from public functionsKarel Zak2015-02-161-52/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve remount logicKarel Zak2015-02-161-2/+5
| | | | | | | * fix fs type detection for remount * parse mtab only for remount and umount Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add --enable-libmount-force-mountinfoKarel Zak2015-02-161-0/+4
| | | | | | | | | | | | | | | | | | The default libmount mtab management depends on mtan symlink. If the symlink exists than libmount parses /proc/self/mountinfo, otherwise it parses regular classic /etc/mtab. This is backwardly compatible and transparent solution. Unfortunately, this is not robust enough because some broken init scripts or 3-party mount helpers may remove the symlink and create regular mtab file. This is pretty bad if initd (systemd) depends on libmount. Fortunately we known that mtab is absolutely unwanted on some distros, so it's fine too ignore mtab at all and don't care about the symlink. Reported-by: Martin Pitt <martin.pitt@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "libmount: MNT_OMODE_FORCE usage"Karel Zak2015-02-101-3/+2Star
| | | | This reverts commit 6f41c5de40629c71a8f79e9be4b94f9a75f9ad21.
* libmount: MNT_OMODE_FORCE usageFridolin Pokorny2015-02-101-2/+3
| | | | | | | | | | | Hi, I have found out that libmount does not respect MNT_OMODE_FORCE mode. I don't see any usage in sources and libmount does not respect this mode when calling library functions. I'm proposing a patch to fix this. Have a nice day! Fridolin Pokorny
* libmount: fix type pointer usageKarel Zak2015-02-031-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mem leak in do_mount_by_types() [coverity scan]Karel Zak2015-01-291-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: revert "read mtab on remount" ideaKarel Zak2015-01-161-6/+1Star
| | | | | | | | | | | | | | It's backwardly incompatible nonsense to prefer mtab on remount. mount -o remount /foo has to read mount options from fstab otherwise the remount has no effect. (The ideal solution would be to read both mtab, then modify the options according to fstab -- but for now more important is to be backwardly compatible.) References: https://bugzilla.redhat.com/show_bug.cgi?id=1182778 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: allow unspecified source on remountKarel Zak2014-12-181-1/+9
| | | | | | | | | | | | kernel does not require mount source (e.g. device name) on remount, it means that fstab/mtab/mountinfo should be optional in this case. For example: mount -o rw,remount / has to work on system without mounted /proc. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix utab entry on remountKarel Zak2014-11-191-0/+3
| | | | | | | | | | mount(8) command does not set ROOT= field to utab entry on remount, for example: mount -oremount,_netdev /mnt Reported-by: Chris Leech <cleech@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add private mnt_context_get_mtab_for_target()Karel Zak2014-11-191-5/+60
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: hide details about failed search in fstab/mtabKarel Zak2014-09-161-2/+8
| | | | | | | | | | | | The current code returns -errno when not found "mount /foo" in fstab and mtab does not exist (or /etc/mtab points to non-mounted /proc). This is problem because the return value is too low-level and maybe misinterpreted by top level code. It's better to always return MNT_ERR_NOFSTAB when not found in fstab/mtab. Reported-by: Dylan Cali <calid1984@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: special treatment for auto in fstype patternKarel Zak2014-06-231-25/+39
| | | | | | | | | | Let's support mount -t ext2,auto /dev/sde /media/stick Reported-by: Andreas Henriksson <andreas@fatal.se> Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506695 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't touch mtab when mount -n specifiedKarel Zak2014-06-171-11/+63
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1109367 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add mkdir_p() from libmountKarel Zak2014-06-091-0/+1
|
* mount: apply "nofail" to MNT_ERR_NOSOURCE libmount errorKarel Zak2014-04-071-0/+5
| | | | | | | | | | | | | 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>
* libmount: use new debug functionsKarel Zak2014-03-211-49/+49
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* umount: don't use mountinfo if possibleKarel Zak2014-03-031-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | The umount(8) always parses /proc/self/mountinfo to get fstype and to merge kernel mount options with userspace mount options from /run/mount/utab. This behavior is overkill in many cases and it's pretty expensive as kernel has to always compose *whole* mountinfo. This performance disadvantage is visible for crazy use-cases with huge number of mountpoints and frequently called umount(8). It seems that we can bypass /proc/self/mountinfo by statfs() to get filesystem type (statfs.f_type magic) and analyze /run/mount/utab before we parse mountinfo. This optimization is not used when: * umount(8) executed by non-root (as user= in utab is expected) * umount --lazy / --force (target is probably unreachable NFS, then use statfs() is pretty bad idea) * target is not a directory (e.g. umount /dev/sda1) * there is (deprecated) writeable mtab Reported-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: update utab after successful extern helper mountKarel Zak2013-11-041-10/+20
| | | | | | | | | | | | | | | This patch allows to maintain private utab libmount file also for external mount/umount helpers that are not linked with libmount. The libmount check if utab has been updated after successful extern helper execution (status=0). If not then the file is updated. This patch affects only 'user' fstab mount option. So, for example with suid mount.cifs you can use: //server/foo /mnt cifs username=foo,noauto,user Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mnt_context_is_child() commentKarel Zak2013-10-111-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Fix typo in commentNamhyung Kim2013-10-111-2/+2
| | | | | | s/MNT_OMASK_/MNT_OMODE_/ Signed-off-by: Namhyung Kim <namhyung@gmail.com>