summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_mount.c
Commit message (Collapse)AuthorAgeFilesLines
* libmount: fix docs typoKarel Zak2019-06-131-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (docs) add reference to v2.33 and v2.34Karel Zak2019-06-071-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (tabdiff) use list_add_tail() in more robust wayKarel Zak2019-02-181-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add support for MS_REMOUNT on --allKarel Zak2019-01-161-0/+106
| | | | | | | | | | | | | 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: 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: switch namespace when appropriateVaclav Dolezal2018-06-111-2/+52
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: support for namespaces for helpersVaclav Dolezal2018-06-111-3/+19
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: added error MNT_ERR_NAMESPACEVaclav Dolezal2018-06-111-0/+8
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: don't use MS_MGC_VAL magic in mount(2) syscallKarel Zak2018-06-011-2/+0Star
| | | | | | | | | Specifying MS_MGC_VAL was required in kernel versions prior to 2.4, but since Linux 2.4 is no longer required and is ignored if specified The minimal kernel requirement for util-linux is Linux v2.6. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve MS_REC usageKarel Zak2018-06-011-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | 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: accept another flags on MS_REMOUNT|MS_BINDKarel Zak2018-05-281-14/+8Star
| | | | | | | | | | | | | | | | | | | | | | The current libmount MS_REMOUNT|MS_BIND support is restricted to MS_RDONLY (read-only bind mount). This is too restrictive as Linux kernel supports bind-remount for arbitrary VFS flags. After this update you can use # mount /dev/sdc1 /mnt/A # mount --bind -onosuid,noexec /mnt/A /mnt/B # findmnt /dev/sdc1 -oTARGET,SOURCE,FS-OPTIONS,VFS-OPTIONS TARGET SOURCE FS-OPTIONS VFS-OPTIONS /mnt/A /dev/sdc1 rw,stripe=512,data=ordered rw,relatime /mnt/B /dev/sdc1 rw,stripe=512,data=ordered rw,nosuid,noexec,relatime The "mount --bind" is composed from two syscalls of course (1st is bind, 2nd is bind,remount,nosuid,noexec). Addresses: https://github.com/karelzak/util-linux/issues/637 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve docs about mnt_context_mount() return codesKarel Zak2018-04-261-3/+31
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix fs pattern usage in mount --allKarel Zak2018-03-061-0/+12
| | | | | | | | | | | | | | | | | The command "mount -a -t <pattern>" uses the -t as pattern to filter fstab entries. And "mount -t <type>" is used to specify FS type. Unfortunately libmount does not care about this difference when it calls standard mount functionality. The original pattern is still in the library control struct and mnt_do_mount() tries to use it as FS type. This patch is just bugfix. Maybe the long term solution would be to differentiate between the pattern and type in the library API. Now the library follows mount(8) command line and it's little bit messy. Reported-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: minimize utimensat() write test usageKarel Zak2017-11-161-9/+19
| | | | | | | | | | | | | | | utimensat() is pretty expensive when mounting parallel filesystems from the same source. It's possible to ignore all this if mtab is not writable. Note that this change is irrelevant for default util-linux builds where all around mtab is already disabled since v2.30 (commit 89958178f6d6ebe0944d423feaea66be521fff43). This change is relevant only for users who still use --enable-libmount-support-mtab. Reported-by: Douglas Jacobsen <dmjacobsen@lbl.gov> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: check waitpid() return codeKarel Zak2017-11-061-5/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Use waitpid() when waiting for mount helper child processVratislav Podzimek2017-11-061-2/+4
| | | | | | | | | | | | | Using wait() in a library may be problematic as it may reap some totally unrelated child process instead of the just forked one. That can result in the library call doing weird things and returning bad return values, but also in a breakage of an arbitrary other thing in the program using the library. [[kzak@redhat.com: - use waitpid() for umount too - keep the current codding style] Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make sure we call stat() propely [coverity scan]Karel Zak2017-10-111-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add human compatible message for EBADMSG errnoKarel Zak2017-10-021-0/+8
| | | | | | | | | | | mount: /media/sdb5: mount(2) system call failed: Bad message. is really ugly for end users. It seems XFS, extN (etc) use EBADMSG for bad checksums. For network or pseudo filesystems continue to use "Bad message" error... Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1496764 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: export locking errors as MNT_EX_FILEIOKarel Zak2017-09-151-1/+10
| | | | | | | | | | | | The mount man page assumes locking errors mapped to MNT_EX_FILEIO (16) return code. Unfortunately, this is internally not exported as a special error code, so it's returned as a generic (errno based) stuff. This patch fixes this issue. Note that we still use locking for example for utab or when enabled /etc/mtab (disabled by default). Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: use _exit() in <type> handlersKarel Zak2017-06-291-4/+4
| | | | | | | The originally used exit() is bad idea for the shared library. Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: remove stray semicolonsSami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: add read-only warningKarel Zak2017-04-281-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_context_get_excode()Karel Zak2017-04-271-0/+329
| | | | | | | | | | | | | | | | 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-0/+27
| | | | | | | | 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>
* libmount: fix use of preprocessor identifierSami Kerola2017-03-131-1/+1
| | | | | | | libmount/src/context_mount.c:990:5: warning: undefined preprocessor identifier 'USE_LIBMOUNT_SUPPORT_MTAB' Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* If mtab support is disabled, disable ro/rw mtab checksStanislav Brabec2017-01-101-0/+2
| | | | | | | | | | | | | | | Commit f9906424 introduced a check that should prevent different information in mtab and /proc/mounts. The check can require significant amount of time, and for systems without mtab support it has no sense. Execute this code only on systems with mtab. When a systems with large number of nodes (thousands) mount the filesystems simultaneously, the time required for serialization causes the utimensat() to take a large amount of time (tens of minutes) when a large number of nodes are simultaneously updating the timestamp. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* mount: append inverting options for mount.<type> on "users"Karel Zak2016-10-271-1/+2
| | | | | | | | | | | | | | | If you call mount(8) as root, then we need to append inverting options (if specified by fstab) for "user" and "users" to /sbin/mount.<type> command line, because for UID=0 mount.nfs follows command line rather than the fstab setting. This has been originally implemented by commit a4c0cc75ff9744299f108c259efab1bd30c8007a for the old mount(8). The same feature is supported by libmount, unfortunately for "user" only. We need the same also for "users" to be backwardly compatible. Addresses: https://github.com/karelzak/util-linux/issues/368 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount, look: remove dead code [oclint]Sami Kerola2016-07-211-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* docs: fix typos found by codespellRuediger Meier2016-02-031-1/+1
| | | | | | Using "codespell" from https://github.com/lucasdemarchi/codespell Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: add support for "bind,ro"Karel Zak2015-08-171-1/+47
| | | | | | | | | | | | | | Now it's necessary t use two mount(8) calls to create a read-only mount: mount /foo /bar -o bind mount /bar -o remount,ro,bind This patch allows to specify "bind,ro" and the remount is done automatically by libmount by additional mount(2) syscall. It's not atomic of course. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup assert() usageKarel Zak2015-08-041-12/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve remount logicKarel Zak2015-02-161-1/+0Star
| | | | | | | * fix fs type detection for remount * parse mtab only for remount and umount Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mem leak in do_mount_by_types() [coverity scan]Karel Zak2015-01-291-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: use -t for type.subtype in helpers APIKarel Zak2014-08-211-1/+3
| | | | | References: https://github.com/karelzak/util-linux/issues/116 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't use /{proc,ext}/filesystems when more fs types specifiedKarel Zak2014-07-251-43/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | # 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>
* libmount: special treatment for auto in fstype patternKarel Zak2014-06-231-3/+21
| | | | | | | | | | 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: use new debug functionsKarel Zak2014-03-211-32/+30Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup fix_optstr() regards to selinux and smackKarel Zak2013-11-121-19/+47
| | | | | | | It's better (more robust) to make the code based on datetypes rather than on if(strcmp(...)). Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix typo in smack pathKarel Zak2013-11-121-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: remove smackfs* option when SMACK not enabledKarel Zak2013-11-121-0/+22
| | | | | | | | | | If there is no /sys/fs/smackfs then libmount removes smackfs*= mount options when compiled --with-smack. Note that we do the same for SELinux. References: http://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg13740.html Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: allow to use -s (sloppy) for all external helpersKarel Zak2013-11-041-6/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: small cleanup in umount codeKarel Zak2013-09-271-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Remove stale comment on mnt_context_mount()Namhyung Kim2013-09-261-5/+0Star
| | | | | | | The commit f9906424 ("libmount: add post-mount checks to detect ro/rw") added necessary check so the comment is not valid anymore. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
* lib/strutils: move *swith() functions to private librarySami Kerola2013-08-291-0/+1
| | | | | | | | Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: fix typosOndrej Oprala2013-08-051-25/+25
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libmount: use MS_SILENT for /{proc,etc}/filesystemsKarel Zak2013-05-091-1/+3
| | | | | | | | mount(8) needs to be doing silent mounts when doing this brute forcing or when the filesystem is not explicitly specified. Reported-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Spelling fixes.Ville Skyttä2013-04-081-2/+2
| | | | Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
* libmount: fix user-mount by root for mount.<type> helpersKarel Zak2013-03-261-0/+22
| | | | | | | | Append options like "exec" "suid" and "dev" to mount.<type> helpers command line if the options are in fstab. This is relevant for root user who calls mount(8) for fstab entries with "user,exec" etc. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: allow to use propagation flags in fstabKarel Zak2013-01-151-13/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux kernel does not allow to change more than one propagation flag by one mount(2) syscall. The flags also cannot be mixed with another mount options. It means that the propagation flags cannot be stored in /etc/fstab, manual "mount --make-* <mountpoint>" is always necessary after successful mount. Painful... This patch implements additional mount(2) after previous successful mount(2) (or exec /sbin/mount.<type>). For example: mount /dev/sda1 /A -o private,unbindable,ro or fstab entry: /dev/sda1 /A auto ro,private,unbindable is implemented by three mount(2) calls: - 1st mounts /dev/sda1 with MS_RDONLY - 2nd sets MS_PRIVATE flag - 3rd sets MS_UNBINDABLE flag. It's the same as as to manually call: mount /dev/sda1 /A -o ro mount --make-private /A mount --make-unbindable /A This solution is not atomic, and umount(2) is not called if propagation flags are not successfully applied, only error is returned. This change does not affect libmount API, so one beautiful day when mount(2) syscall will be improved we can drop this nasty patch. Signed-off-by: Karel Zak <kzak@redhat.com>