summaryrefslogtreecommitdiffstats
path: root/libmount
Commit message (Collapse)AuthorAgeFilesLines
* 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-282-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (docs) add unused declarationsKarel Zak2017-04-271-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_context_get_excode()Karel Zak2017-04-277-5/+609
| | | | | | | | | | | | | | | | 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-266-1/+89
| | | | | | | | 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: Ensure utab.lock mode 644Stanislav Brabec2017-04-181-0/+5
| | | | | | | | | If utab.lock is created by a process with a restricted umask, utab.lock is created with restricted permissions. It breaks userspace monitor. Ensure that the mode is always 644. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: fix file descriptor leakSami Kerola2017-04-101-6/+5Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* tests: add static keyword where needed [smatch scan]Sami Kerola2017-03-172-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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>
* libmount: cosmetic change to mnt_table_find_srcpath()Karel Zak2017-02-281-6/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: return tab entry for default nodePetr Vorel2017-02-281-1/+28
| | | | | | This is useful for lsblk. Signed-off-by: Petr Vorel <pvorel@suse.cz>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-204-70/+70
| | | | | | | | | | 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-133-3/+3
|
* libmount: make rootfs lookup by parent-id more robustKarel Zak2017-02-011-4/+30
| | | | | | | The root FS id really does not have to be the smallest one. Reported-by: Michal Soltys <soltys@ziu.info> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Fix incorrect detach of reused loop deviceStanislav Brabec2017-01-161-3/+7
| | | | | | | | | | | | | | | If -oloop is used and the loop device is reused, the loop device is detached after umount. It is incorrect as it could break the another task using the loop device. This is caused by mnt_context_enable_loopdel(,TRUE) that is called from mnt_context_prepare_umount() whenever "loop" option is used, independently on AUTOCLEAR flag. Remove the "loop" option for reused devices to prevent detaching of reused loop device. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: fix mount -oloop=/dev/loopX regressionStanislav Brabec2017-01-161-1/+6
| | | | | | | | | | | | | | | | | | | | | | | If mount option "loop" is used with an argument, it should be respected. Commit 8efad715 introduced a regression. Even with an argument, overlaying loop device is searched and argument is ignored. It could have unexpected side effects. If argument is set, never allocate a new loop device. How to reproduce: mkdir -p cdrom mkisofs -o cdrom.iso cdrom/ 2>/dev/null losetup /dev/loop0 cdrom.iso strace mount -t auto -o ro,loop=/dev/loop1 cdrom.iso /mnt 2>&1 | grep ^mount cat /proc/self/mountinfo | grep /mnt umount /mnt losetup -d /dev/loop0 mount("/dev/loop0", "/mnt", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL) = 0 327 60 7:0 / /mnt ro,relatime shared:241 - iso9660 /dev/loop0 ro losetup: /dev/loop0: detach failed: No such device or address Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* 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>
* libmount: support name=value for mnt_match_options()Karel Zak2016-12-201-5/+13
| | | | | | | | | $ findmnt --options mode=755 TARGET SOURCE FSTYPE OPTIONS /sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,mode=755 /dev udev devtmpfs rw,relatime,size=1983516k,nr_inodes=495879,mode=755 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: reimplement mnt_match_options()Karel Zak2016-12-203-93/+80Star
| | | | | | | | Let's use optstr.c functions to parse pattern and options strings. It's more robust that the old original mount(8) code and it supports quotes in the options strings. Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: replace FTP by HTTPS in kernel.org URLsSébastien Helleu2016-12-191-1/+1
| | | | | | | The links to ftp://ftp.kernel.org/ are replaced by https://www.kernel.org/. Signed-off-by: Karel Zak <kzak@redhat.com>
* findmnt: error on --target /non-existKarel Zak2016-12-161-0/+4
| | | | | | | | | | | | | | | The original --target implementation (< v2.27) has been based on stat(), so it was usable for valid paths only. The new implementation is based on search in the mountinfo file, so it works for arbitrary crazy path. This is not backwardly compatible and if the path does not exist then it still returns at least root directory mount entry. This patch forces mnt_table_find_mountpoint() to check if the path is valid before we search in the mountinfo file. Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'build-fixes' of https://github.com/rudimeier/util-linuxKarel Zak2016-12-091-2/+0Star
|\ | | | | | | | | * 'build-fixes' of https://github.com/rudimeier/util-linux: build-sys: don't clean *.img files
| * build-sys: don't clean *.img filesRuediger Meier2016-12-091-2/+0Star
| | | | | | | | | | | | | | | | Don't know why this was added in d78df0ac but it can't be right that libmount/python removes these files in the toplevel builddir. Moreover I've never seen such *.img files appearing during build at all. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | libmount: revert X-* and x-* meaningKarel Zak2016-12-093-13/+11Star
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: use x-systemd options as X-*Karel Zak2016-12-081-0/+7
| | | | | | | | | | | | | | | | The previous patch introduces X-* options namespace for options that have to be maintained in user space. Unfortunately, systemd users already use mount options that are necessary by umount or another operations. The conclusion from discussion with systemd guys is to store all the systemd options in userspace. It seems better to add one line exception to libmount than force all fstab users to rename x-systemd to X-systemd. Addresses: https://github.com/systemd/systemd/pull/3904 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: introduce X-* commentsKarel Zak2016-12-082-1/+4
| | | | | | | | | | | | | x-* are fstab only and not stored in userspace (utab). In some cases it's not optional solution because the option is also necessary for umount or another operations. The X-* is exactly the same as x-*, but stored to utab (or mtab on old systems). It's usually bad idea to store mount options in userspace, but it's better to provide any solution that force users to bypass mount(8) (and friends) and implement 3rd-party incompatible solutions. Signed-off-by: Karel Zak <kzak@redhat.com>
* 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: fix null-checking [coverity scan]Karel Zak2016-10-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: paranoid change in mnt_table_is_fs_mounted()Karel Zak2016-09-291-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mount -a for cifsAurelien Aptel2016-09-291-3/+24
| | | | | | | | | | | | | when mounting a cifs share, the src is actually an UNC path which can in in several forms: simple: //host/share, //host/share/ including subpath: //host/share/sub/path to check if the cifs fs is mounted we have to extract the subpath and compare *that* to the root. Signed-off-by: Aurelien Aptel <aaptel@suse.com>
* docs: some random fixesKarel Zak2016-09-274-2/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Preserve empty string value in optstr parsingFilipe Brandenburger2016-08-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent mount (since the switch to libmount in v2.22) drops the '=' in mount options that are set to an empty value. For example, the command line below will be affected: # mount -o rw,myopt='' -t tmpfs tmpfs /mnt/tmp Fix that by preserving an empty string in the options passed to the mount(2) syscall when they are present on the command line. Add test cases to ensure empty string handling is working as expected and in order to prevent regressions in the future. Also tested manually by stracing mount commands (on a kernel which accepts a special extra option, for testing purposes.) Before this commit: # strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myarg") = -1 EINVAL (Invalid argument) After this commit: # strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myopt=") = 0 All test cases pass, including newly added test cases. Also checked them with valgrind using: $ tests/run.sh --memcheck libmount/optstr Fixes #332. Signed-off-by: Filipe Brandenburger <filbranden@google.com>
* libmount: ignore redundant slashesKarel Zak2016-08-082-7/+9
| | | | | | | | | | | | | | | ///aaa/bbb and /aaa/bbb/ are the same paths. This is important especially with NFS where number of slashes are not the same in the /proc/self/mountinfo and fstab or utab. The regular URI is euler://tmp but /proc contains euler:/tmp Reported-by: Ales Novak <alnovak@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: one iteration to detect overlap and reuse loopdevKarel Zak2016-08-041-32/+31Star
| | | | | | | | | | The current code scans loopdevs to detect already used loop device and another scan to detect overlap. Let's use one scan only, for this purpose loopcxt_find_overlap() has been modified to return info (rc==2) about full size and offset match. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: cleanup sizelimit checkKarel Zak2016-08-041-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmout: Reuse loop device safelyStanislav Brabec2016-08-031-13/+52
| | | | | | | | Add a safety check to mnt_context_setup_loopdev(). Only a loop device with equal offset and sizelimit will be reused. If any overlapping loop device exists, MNT_ERR_LOOPOVERLAP is returned. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* Add sizelimit to internal APIStanislav Brabec2016-08-033-5/+5
| | | | | | | | | | | | | | Fully safe checks of loop device need to check sizelimit. To prevent need of two nearly equal functions, introduce sizelimit parameter to several internal functions: loopdev_is_used() loopdev_find_by_backing_file() loopcxt_is_used() loopcxt_find_by_backing_file() If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit). Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: Introduce new error: MNT_ERR_LOOPOVERLAPStanislav Brabec2016-08-031-1/+7
| | | | | | | This error code is intended for situations where overlapping loop device exists and cannot be reused. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: Fix possible crash in mnt_context_setup_loopdev()Stanislav Brabec2016-08-031-2/+4
| | | | | | If loopcxt_init() fails, Iloopcxt_deinit() should not be called. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount, look: remove dead code [oclint]Sami Kerola2016-07-212-2/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-212-9/+6Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: don't check nonnull attributes for NULL [-Wnonnull-compare]Karel Zak2016-06-142-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-3115-39/+39
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libmount: remove duplicate codeKarel Zak2016-04-222-92/+12Star
| | | | | | | | For petty long time we have strdup_to_struct_member() macro to avoid duplicate code when strdup() strings in setter functions. Let's use it for libmount. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: reuse existing loop deviceStanislav Brabec2016-04-221-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | According to the Al Viro[1], kernel has no way to detect that a single file is used by multiple loop devices, and multiple mounts of the same file using different loop devices will result in a data corruption. Exactly this now happens, if multiple btrfs sub-volumes in one file are mounted with "-oloop". Make use of multiple -oloop mounting the same file safe: Do a loop devices lookup, and if a loop device is already initialized, use it. Hopefully it is possible, as "losetup -d" will return OK, even if the device itself is in use, and is not released. Problems: There is a risk of race condition between the lookup and real mount. Once loop device is initialized read-only, kernel offers no way to turn it to read-write. It has to fail. References: https://lkml.org/lkml/2016/2/26/897 Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: Re-organize is_mounted_same_loopfile()Stanislav Brabec2016-04-221-12/+14
| | | | | | | | First parse options, then initialize context. No change in function. The change is needed for loop device reuse. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: fix memory leakSami Kerola2016-04-191-2/+2
| | | | | | Found with scan-build. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pylibmount: include c.hKarel Zak2016-04-181-0/+1
| | | | | | | ... for sys/sysmacros.h and major() and minor() macros. Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make kernel_fs_postparse() more robustKarel Zak2016-04-151-3/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mnt_table_parse_stream() logicKarel Zak2016-04-151-1/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>