summaryrefslogtreecommitdiffstats
path: root/libmount
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* tests: make tests more portable due to mtabKarel Zak2016-04-151-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mnt_table_parse_mtab() logicKarel Zak2016-04-152-15/+24
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: remove USE_LIBMOUNT_FORCE_MOUNTINFOKarel Zak2016-04-151-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't support /etc/mtab by defaultKarel Zak2016-04-143-11/+22
| | | | | | | | | | | | | | | | | 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>
* libmount: try absolute target before canonicalizeKarel Zak2016-04-131-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The path canonicalization is expensive and in many cases unwanted due to problems with readlink() on unreachable NFS and automounters. This patch add a possibility to search also by $(CWD)/<path> if the <path> is relative to reduce number of situation when we convert the path to the canonical absolute path. The common use-case: # cd /some/long/path # umount ./mountpoint old version: 15543: libmount: TAB: [0x560a99a54230]: lookup TARGET: './test' 15543: libmount: CACHE: [0x560a99a54290]: canonicalize path ./test 15543: libmount: CACHE: [0x560a99a54290]: add entry [ 1] (path): /mnt/test: ./test 15543: libmount: TAB: [0x560a99a54230]: lookup canonical TARGET: '/mnt/test' 15543: libmount: CXT: [0x560a99a54050]: umount fs: /mnt/test new version: 15597: libmount: TAB: [0xabf230]: lookup TARGET: './test' 15597: libmount: TAB: [0xabf230]: lookup absolute TARGET: '/mnt/test' 15597: libmount: CXT: [0xabf050]: umount fs: /mnt/test Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Fix possible NULL dereference in get_btrfs_fs_root()Karel Zak2016-03-312-3/+10
| | | | | | | | | | | The function mnt_table_get_fs_root() should be robust enough to accept NULL as mountinfo -- the right behaviour is to default to '/'. The set_fs_root() (tab_update.c) has to understand when mountinfo is necessary (for bind mounts and btrfs). Reported-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: result of operation is garbage or undefined [clang analyze]Karel Zak2016-03-291-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: pylibmount, mount context is Linux onlyRuediger Meier2016-03-213-2/+10
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: some libmount test progs are Linux onlyRuediger Meier2016-03-211-2/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: improve conversion from root= to the devnameKarel Zak2016-03-153-9/+122
| | | | | | | | Currently the code supports /dev/name or PARTUUID= only. We also need to support 'maj:min' and 'hexhex' notations. Reported-by: George Spelvin <linux@horizon.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: use AC_PROG_MKDIR_P and remove a few gnuismsRuediger Meier2016-03-131-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix icc/clang compiler warningsRuediger Meier2016-03-132-4/+3Star
| | | | | | | | | | | | | | | | | | | | | | | | | | clang warning: libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!mpc) ^~~~ icc printf warnings: libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing")); ^ login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments : _("You are using shadow passwords on this system.\n")); ^ icc enum warnings: disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD, ^ libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type &width, align, ^ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: fix if..endif for *_la_LDFLAGSKarel Zak2016-03-101-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Typo fixStanislav Brabec2016-03-101-2/+2
|
* Revert "include sysmacros.h where used"Karel Zak2016-03-083-3/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-083-0/+3
| | | | | | | | BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux libraries have been moving away from including sysmacros.h implicitly via sys/types.h, so include it directly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libmount: don't include libio.hRuediger Meier2016-03-071-1/+1
| | | | | | | This include was added just one month ago in 5a971329 but I don't see what it was good for. It's missing in musl libc. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: move fopen_at() to fileutils.h, remove at.hRuediger Meier2016-03-071-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: remove openat fallback functions (include/at.h)Ruediger Meier2016-03-071-4/+5
| | | | | | | | | | | | | | I have validated that we are still compatible at least back to - openSUSE 11.4 - SLE 11 - RHEL/CentOS 6 - OSX 10.10.x, (Xcode 6.3) - FreeBSD 10.2 Confirmed incompatibility: - OSX 10.9.x, (Xcode 6.2) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: disable unused parameter warnings for some test progsRuediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-239-46/+46
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: add mnt_fs_set_priority()Ruediger Meier2016-02-233-0/+3
| | | | | | | | | | | Looks like it got lost in ce4dd666. Compiler warning discoverd this issue: libmount/src/fs.c:1171:5: warning: no previous prototype for 'mnt_fs_set_priority' [-Wmissing-prototypes] int mnt_fs_set_priority(struct libmnt_fs *fs, int prio) ^ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: always add AM_CFLAGSRuediger Meier2016-02-231-0/+1
| | | | | | | | We were missing our nice compliler warnings for many programs and libs. See next commits how many trivial and non-trival warnings have to be fixed. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: always use global LDADDRuediger Meier2016-02-231-1/+1
| | | | | | | | This was a major showstopper when building on a system where LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test programs which wouldn't need LDADD ... never mind. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: check linker support for version scriptsRuediger Meier2016-02-181-1/+3
| | | | | | | The macro AX_CHECK_VSCRIPT was taken from gnu autoconf archive. http://www.gnu.org/software/autoconf-archive/ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: fix mnt_table_is_fs_mounted() loopdev useKarel Zak2016-02-163-15/+24
| | | | | | | | | | The function does not detect already mounted loop devices on systems with regular /etc/mtab file. The patch also improves test_is_mounted() to be useful with mtab. Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>