summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* libmount: (docs) add reference to v2.33 and v2.34Karel Zak2019-06-071-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add selinuxfs between pseudo filesystemsKarel Zak2019-05-291-0/+1
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add bpf between pseudo filesystemsKarel Zak2019-05-291-0/+1
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix "maybe be" duplicationAustin English2019-05-151-1/+1
| | | | Signed-off-by: Austin English <austinenglish@gmail.com>
* libmount: Recognize more fuse filesystems as pseudofs and netfsStanislav Brabec2019-03-041-1/+10
| | | | | | | | Add some fuse filesystems to the list of pseudofs and netfs. There are still tens of filesystems that should be evaluated and added. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: (umount) make mnt_stat_mountpoin() usable for relative pathsKarel Zak2018-12-101-1/+1
| | | | | | | | | # mount -o loop devicefile /mnt/test # umount devicefile umount: devicefile: not mounted. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653781 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: export mnt_guess_system_root() by APIKarel Zak2018-12-101-1/+6
| | | | 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: (utils) fix compiler warnings [-Wcast-qual]Karel Zak2018-07-231-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add nsfs between pseudo filesystemsKarel Zak2017-11-211-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: minimize utimensat() write test usageKarel Zak2017-11-161-0/+2
| | | | | | | | | | | | | | | 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: fix access() utab write testKarel Zak2017-11-081-11/+31
| | | | | | | | | | | | | | | | | The commit c08396c7691e1e6a04b6b45892e7e4612ceed8d7 replaces open(O_CREATE) with ecaccess(). Unfortunately, another code depends on the original behavior. * let's make utab when really necessary rather than in the try_write() test * __mnt_new_table_from_file() returns NULL if tab-file does not exists. This is incorrect for tab_update.c stuff. We need empty table in this case. * we can check /run/mount/ directory for write access if eaccess(filename) return ENOENT (because file does not exist) Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: use eacess() rather than open() to check mtab/utabKarel Zak2017-10-201-6/+13
| | | | | | | | | The open() syscall is probably the most strong way how to check write accessibility in all situations, but it's overkill and on some paranoid systems with enabled audit/selinux. It fills logs with "Permission denied" entries. Let's use eaccess() if available. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't pass -1 to close() [coverity scan]Karel Zak2017-05-171-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix file descriptor leakSami Kerola2017-04-101-6/+5Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: reimplement mnt_match_options()Karel Zak2016-12-201-92/+0Star
| | | | | | | | 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>
* libmount: fix null-checking [coverity scan]Karel Zak2016-10-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-4/+2Star
| | | | 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>
* libmount: fix memory leakSami Kerola2016-04-191-2/+2
| | | | | | Found with scan-build. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: improve conversion from root= to the devnameKarel Zak2016-03-151-0/+115
| | | | | | | | 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>
* tests: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-231-11/+11
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: fix mnt_table_is_fs_mounted() loopdev useKarel Zak2016-02-161-1/+4
| | | | | | | | | | 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>
* login, mount: fix __SC_GETPW_R_SIZE_MAX usageKarel Zak2015-12-151-19/+6Star
| | | | | | | | | | sysconf(_SC_GETPW_R_SIZE_MAX) returns initial suggested size for pwd buffer (see getpwnam_r man page or POSIX). This is not large enough in some cases. Yes, this sysconf option is misnamed (should be _SC_GETPW_R_SIZE_MIN). Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: use fstatat(AT_NO_AUTOMOUNT) for mountpointsKarel Zak2015-12-091-2/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add cgroup2 pseudo FSKarel Zak2015-12-081-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make mnt_get_filesystems() more robust [clang analyze]Karel Zak2015-07-301-2/+2
| | | | | | | | | The mnt_free_filesystems() relies on NULL as the last item in the filesystems array. It's necessary to keep NULL there after failed strdup() too, because we call mnt_free_filesystems() to deallocate after error. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: sort pseudo filesystems by LC_COLLATE=CKarel Zak2015-07-291-1/+1
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/212 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: mark overlay as pseudo-FSKarel Zak2015-03-111-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup fs root detection codeKarel Zak2015-03-101-34/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* findmnt: don't rely on st_dev for --targetKarel Zak2015-03-101-0/+4
| | | | | | | | | | | | The overlay filesystem does not provide usable st_dev (in traditional UNIX way). It's necessary to search in /proc/self/mountinfo to detect which path element is mountpoint. $ findmnt --target /mnt/merged/dir-a/foo TARGET SOURCE FSTYPE OPTIONS /mnt/merged overlay overlay rw,relatime,lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: remove assert(arg) from public functionsKarel Zak2015-02-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix memory overflow [AddressSanitizer]Sami Kerola2014-11-181-1/+1
| | | | | | | | | | | | | | | | | | ==10918==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffd795b680 at pc 0x0000004447c6 bp 0x7fffd795b3e0 sp 0x7fffd795ab78 WRITE of size 129 at 0x7fffd795b680 thread T0 #0 0x4447c5 in scanf_common(void*, int, bool, char const*, __va_list_tag*) (/home/src/util-linux/.libs/lt-mount+0x4447c5) #1 0x445892 in sscanf (/home/src/util-linux/.libs/lt-mount+0x445892) #2 0x7fe78709a3d3 in get_filesystems /home/src/util-linux/libmount/src/utils.c:581:7 #3 0x7fe78709a1ba in mnt_get_filesystems /home/src/util-linux/libmount/src/utils.c:622:7 #4 0x7fe7870aa78f in do_mount_by_pattern /home/src/util-linux/libmount/src/context_mount.c:833:7 #5 0x7fe7870a9534 in mnt_context_do_mount /home/src/util-linux/libmount/src/context_mount.c:951:9 #6 0x7fe7870aab2b in mnt_context_mount /home/src/util-linux/libmount/src/context_mount.c:1051:8 #7 0x4ba9f5 in main /home/src/util-linux/sys-utils/mount.c:1107:7 #8 0x7fe785caa03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f) #9 0x4b9f9c in _start (/home/src/util-linux/.libs/lt-mount+0x4b9f9c) Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve kernel command line parsingMike Frysinger2014-10-311-10/+24
| | | | | | | | | | | | | | | | | | | | | | | The current command line parser will stop at the first occurrence of an option, however the kernel does the opposite. So if you have: root=/dev/sda1 root=/dev/sda2 When you look for "root", the kernel will use /dev/sda2, but util-linux uses /dev/sda1. Further, if args are passed to custom init programs, the parser will pick those up as kernel options. So if you have: root=/dev/sda1 -- /foo bar=yes The kernel will stop at the "--" and pass the rest to userland. But if you look for "bar", util-linux will incorrectly return "yes". Ultimately, there's no way for util-linux to exactly parse the command line the same way as the kernel -- we don't know exactly which ones the kernel picks up and which it passes on to userland (either as env vars or as command line args). The kernel passes all unrecognized options. These updates are simple best effort. URL: https://bugs.gentoo.org/526754 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libmount: fix mnt_is_readonly() #ifdefKarel Zak2014-10-071-1/+1
| | | | | | | This issue affects util-linux portability to GNU/HURD Reported-by: Pino Toscano (from Red Hat) Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add stripoff_last_component() from libmountKarel Zak2014-06-091-12/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add mkdir_p() from libmountKarel Zak2014-06-091-37/+1Star
|
* libmount: use new debug functionsKarel Zak2014-03-211-15/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add statfs_magic.hKarel Zak2014-03-061-74/+74
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: define BTRFS_TEST_MAGIC if missingBernhard Voelker2014-03-051-0/+3
| | | | | | | * libmount/src/utils.c (BTRFS_TEST_MAGIC): Conditionally add define which is used since commit v2.24-243-g6a52473. Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* libmount: cgroup magic already definedKarel Zak2014-03-031-3/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* umount: don't use mountinfo if possibleKarel Zak2014-03-031-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | 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: add efivarfs to the list of pseudo filesystemsKarel Zak2013-12-101-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_tag_is_valid()Karel Zak2013-11-191-0/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: remove dead code [coverity scan]Karel Zak2013-10-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Save errno if mkostemp() failedNamhyung Kim2013-09-301-1/+3
| | | | | | | | After mkostemp() failed, umask() and free() might alter the errno to another value. Not sure those calls really changes the errno or not. But let's be more conservative. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
* libmount: use memmove when overlap possibleDave Reisner2013-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | When unmounting some mountpoints as an unprivileged user (via the 'user' option in fstab), the umount fails. Debug output of 'umount /opt' reveals: 17760: libmount: CXT: [0x22890e0]: do umount 17760: libmount: UTILS: moving to /opt parent 17760: libmount: CXT: current directory moved to / [last_component='opt'] 17760: libmount: CXT: [0x22890e0]: umount(2) [target='pt', flags=0x00000000] valgrind shows the problem: ==23544== Source and destination overlap in memcpy(0x58d1370, 0x58d1371, 4) ==23544== at 0x4C2BBC3: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==23544== by 0x4E537C3: mnt_chdir_to_parent (utils.c:168) ==23544== by 0x4E45E4C: mnt_context_do_umount (context_umount.c:601) ==23544== by 0x4E46513: mnt_context_umount (context_umount.c:855) ==23544== by 0x403476: umount_one (umount.c:299) ==23544== by 0x402B34: main (umount.c:629) ==23544== ref: https://bugs.archlinux.org/task/36968 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* lib/strutils: move *swith() functions to private librarySami Kerola2013-08-291-31/+0Star
| | | | | | | | 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-26/+26
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libmount: fix memory leak [clang-analyzer]Karel Zak2013-07-091-1/+2
| | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>