summaryrefslogtreecommitdiffstats
path: root/libmount/src
Commit message (Collapse)AuthorAgeFilesLines
* 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: 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-082-2/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-082-0/+2
| | | | | | | | 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-232-0/+2
| | | | | | | | | | | 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>
* libmount: add loop to debug outputKarel Zak2016-02-163-16/+19
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix memleak in mnt_pretty_path()Karel Zak2016-02-121-0/+1
| | | | | References: https://github.com/karelzak/util-linux/issues/275 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mnt_table_is_fs_mounted() for loopdevKarel Zak2016-02-121-4/+8
| | | | | Reported-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.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: move btrfs subvol code refactoringKarel Zak2016-02-011-99/+115
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix target resolving for btrfs stuffKarel Zak2016-02-011-9/+14
| | | | | | and make the code more verbose. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: code re-indentationStanislav Brabec2016-02-011-43/+44
| | | | | | | | | | For easier review, the fix of libmount comes in two patches: PATCH 1/2: libmount: run btrfs subvol checks for "subvolid" option PATCH 2/2: code re-indentation No code change is present in this patch. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: run btrfs subvol checks for "subvolid" optionStanislav Brabec2016-02-011-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is possible to identify btrfs subvolume with "subvolid" instead of "subvol". In such case, btrfs specific check mistakenly assumes that the default subvolume is going to be mounted, even if subvolid specifies id of non-default subvolume. Implement a code for "subvolid" option. For easier review, this fix comes in two patches: PATCH 1/2: libmount: run btrfs subvol checks for "subvolid" option PATCH 2/2: code re-indentation How to reproduce: truncate -s1G btrfs_test.img mkdir -p btrfs_mnt /sbin/mkfs.btrfs -f -d single -m single ./btrfs_test.img mount -o loop btrfs_test.img btrfs_mnt pushd . cd btrfs_mnt mkdir -p d0/dd0/ddd0 cd d0/dd0/ddd0 touch file{1..5} btrfs subvol create s1 cd s1 touch file{1..5} mkdir -p d1/dd1/ddd1 cd d1/dd1/ddd1 btrfs subvol create s2 rid=$(btrfs inspect rootid s2) echo new default $rid btrfs subvol get-default . btrfs subvol set-default $rid . popd DEFAULT_SUBVOLID=`btrfs subvolume get-default btrfs_mnt | while read dummy id rest ; do echo $id ; done` NON_DEFAULT_SUBVOLID=`btrfs subvolume list btrfs_mnt | while read dummy id rest ; do if test $id = $DEFAULT_SUBVOLID ; then continue ; fi ; echo $id ; done` umount btrfs_mnt losetup /dev/loop0 $PWD/btrfs_test.img echo "/dev/loop0 $PWD/btrfs_mnt btrfs subvolid=$NON_DEFAULT_SUBVOLID 0 0" >>/etc/fstab ./mount -a ./mount -a umount btrfs_mnt sed -i "/\/dev\/loop0/d" /etc/fstab losetup -d /dev/loop0 rm btrfs_test.img rmdir btrfs_mnt Current behavior of second "mount -a": mount: /dev/loop0 is already mounted or /root/btrfs_mnt busy /dev/loop0 is already mounted on /root/btrfs_mnt Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: run btrfs subvol checks for "auto" fs typeStanislav Brabec2016-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is possible to mount btrfs using "auto" keyword in fstab. In such case, btrfs specific checks are skipped. Run them for "auto" as well. Looking at the code, it is a safe approach. In case of btrfs, it will do what is needed, in case of no btrfs, btrfs_get_default_subvol_id() will fail, and the rest of the code is skipped. How to reproduce: See reproducer in 2cd28fc and replace fstab line by echo "/dev/loop0 $PWD/btrfs_mnt btrfs auto 0 0" >>/etc/fstab Current behavior of second "mount -a": mount: /dev/loop0 is already mounted or /root/btrfs_mnt busy /dev/loop0 is already mounted on /root/btrfs_mnt Testcases for btrfs and ext4: truncate -s1G btrfs_test.img truncate -s1G ext4_test.img mkdir -p btrfs_mnt mkdir -p ext4_mnt /sbin/mkfs.btrfs -f -d single -m single ./btrfs_test.img /sbin/mkfs.ext4 ./ext4_test.img losetup /dev/loop0 $PWD/btrfs_test.img losetup /dev/loop1 $PWD/ext4_test.img echo "/dev/loop0 $PWD/btrfs_mnt auto defaults 0 0" >>/etc/fstab echo "/dev/loop1 $PWD/ext4_mnt auto defaults 0 0" >>/etc/fstab ./mount -a ./mount -a umount btrfs_mnt umount ext4_mnt sed -i "/\/dev\/loop[01]/d" /etc/fstab losetup -d /dev/loop0 losetup -d /dev/loop1 rm btrfs_test.img rm ext4_test.img rmdir btrfs_mnt rmdir ext4_mnt Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* libmount: add 'force-mountinfo' to features list, improve debugKarel Zak2016-02-012-7/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup btrfs.c headerKarel Zak2016-01-261-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: consolidate btrfs stuff, make it more portableKarel Zak2016-01-265-133/+92Star
| | | | | | | | | - add --with-btrfs (enabled by default) - check for linux/btrfs.h - add "btrfs" to libmount features list (see mount -V) - #ifdef HAVE_BTRFS_SUPPORT for all btrfs stuff in libmount Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: handle btrfs default subvolume mountStanislav Brabec2016-01-268-4/+330
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When mounting btrfs volume without subvol= and subvolid=, and the btrfs volume has default subvolume defined, mount() mounts the default subvolume and not the volume root as other filesystems do. To handle this situation correctly (for example for "mount -a"), libmount has to be capable to detect default subvolume. Add btrfs.c and btrfs.h that implement needed functions. This patch adds mnt_table_find_target_with_option() to the library API. Known problems not covered by this patch: - Use of subvolid= in fstab is not yet handled. - Use of type auto in combination with subvol= in fstab is not yet handled. - Use of btrfs in loop devices, where image file is specified in fstab is not yet handled (use of /dev/loop0 in fstab works). - If fstab uses subvol=, and subvol path changes since last "mount -a", subsequent "mount -a" will not recognize that it is already mounted, and it will attempt to mount it second time. To fix it, libmount should remember subvolid in time of mount (subvolid is unique for the subvolume, subvol is not). - mountinfo contains subvol and subvolid since kernel 4.2. Before kernel 4.2, there is no reasonable way to solve this situation. (One would create temporary mount point, mount the default, call needed ioctl() to determine what was mounted, deduce the default subvolume, compare it with subvolume of mounted volume, unmount and return result.) How to reproduce: truncate -s1G btrfs_test.img mkdir -p btrfs_mnt /sbin/mkfs.btrfs -f -d single -m single ./btrfs_test.img mount -o loop btrfs_test.img btrfs_mnt pushd . cd btrfs_mnt mkdir -p d0/dd0/ddd0 cd d0/dd0/ddd0 touch file{1..5} btrfs subvol create s1 cd s1 touch file{1..5} mkdir -p d1/dd1/ddd1 cd d1/dd1/ddd1 btrfs subvol create s2 rid=$(btrfs inspect rootid s2) echo new default $rid btrfs subvol get-default . btrfs subvol set-default $rid . popd umount btrfs_mnt losetup /dev/loop0 $PWD/btrfs_test.img echo "/dev/loop0 $PWD/btrfs_mnt btrfs defaults 0 0" >>/etc/fstab mount -a mount -a umount btrfs_mnt sed -i "/\/dev\/loop0/d" /etc/fstab losetup -d /dev/loop0 rm btrfs_test.img rmdir btrfs_mnt Current behavior: mount: /dev/loop0 is already mounted or /root/btrfs_mnt busy /dev/loop0 is already mounted on /root/btrfs_mnt Expected behavior is to ignore already mounted FS. [kzak@redhat.com: - make 'var' optional for mnt_table_find_target_with_option(), - add mnt_table_find_target_with_option() to symbols table and docs - add "btrfs" string between supported debug modes - minor coding style changes] Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Cc: David Štěrba <dsterba@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid,libmount: Do not use void* in calculations [cppcheck]Boris Egorov2016-01-191-2/+2
| | | | | | | | [libblkid/src/superblocks/zfs.c:179]: (portability) 'label' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [libblkid/src/superblocks/zfs.c:237]: (portability) 'label' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [libblkid/src/topology/topology.c:221]: (portability) 'chn.data' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [libmount/src/fs.c:153]: (portability) 'old' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [libmount/src/fs.c:154]: (portability) 'new' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.
* 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: add comment, remove TODO itemKarel Zak2015-12-101-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: use fstatat(AT_NO_AUTOMOUNT) for mountpointsKarel Zak2015-12-094-6/+16
| | | | 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: fix is-mounted check for btrfsKarel Zak2015-12-021-12/+26
| | | | | | | | | | | fstab: /dev/sdc /mnt/test btrfs subvol=/anydir /mnt/test /mnt/test2 auto bind and "mount -a" does not detect that /mnt/test2 is already mounted. Reported-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: follow docs with parse-error callback return codeKarel Zak2015-10-151-1/+1
| | | | | | The docs says that recoverable errors have rc > 0. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix uid= and gid= translationKarel Zak2015-10-121-11/+14
| | | | | | | | | | | | | | | | | | | | | | | The current libmount version returns error when no able to convert username/groupname to uid/git. # mount mount /dev/sda1 /mnt/test -o uid=ignore # mount: failed to parse mount options This is regression, the original mount(8) has ignored possible unknown user/group names and the option has been used unconverted (with the original value). For example UDF kernel driver depends on this behavior and "uid=ignore" (or "forgot") is a valid mount option. Fixed version (unit test): ./test_mount_optstr --fix uid=kzak,gid=forgot,aaa,bbb optstr: uid=kzak,gid=forgot,aaa,bbb fixed: uid=1000,gid=forgot,aaa,bbb Reported-By: Anthony DeRobertis <anthony@derobert.net> Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801527 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (monitor) remove unnecessary epoll EPOLLPRIKarel Zak2015-09-111-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (monitor) don't check for regular mtabKarel Zak2015-09-111-5/+1Star
| | | | | | | | | | | | The monitor supports utab only (as documented). It's application responsibility to use libmount in the right way. It's overkill to check for valid environment during monitor initialization. For example systemd checks for regular mtab during boot, it's better than try to be smart later in libmount monitor when system is already running. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: typo fixesKir Kolyshkin2015-09-032-2/+2
| | | | | | I was reading the code and found these mountinfo typos. Signed-off-by: Kir Kolyshkin <kir@openvz.org>
* libmount: fix compiler warning [-Wdiscarded-qualifiers]Karel Zak2015-08-311-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: handle arbitrary line length for mountsKarel Zak2015-08-271-32/+49
| | | | | | | | | | | | | | | | | | | | | | | | | Based on patch from Kees Cook, he wrote: > The kernel's maximum path length is PATH_MAX (4096). The use of BUFSIZ > (8192) would seem sufficient for reading mountinfo files, but it's > not. Paths may contain escaped characters (requiring 4x as many bytes > to read), and filesystem options are of unknown length. To avoid > mounts being either intentionally or unintentionally hidden from > libmount and its users, we must accept arbitrary length lines when > parsing. > > Long valid entries are currently ignored, with warnings like this: > mount: /proc/self/mountinfo: parse error: ignore entry at line 11. > mount: /proc/self/mountinfo: parse error: ignore entry at line 12. > > Instead of using a malloc on every line parsed from mount files, do it > once per mount file context, growing it as needed. The general case > will never grow it. I have moved the parser stuff to the new struct libmnt_parser, maybe we can move more things (e.g. libmnt_table->fmt) to this struct later. Reported-by: Kees Cook <keescook@chromium.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix shadow declarationsSami Kerola2015-08-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | sys-utils/zramctl.c: In function 'get_mm_stat': sys-utils/zramctl.c:276:58: warning: declaration of 'inbytes' shadows a global declaration [-Wshadow] static char *get_mm_stat(struct zram *z, size_t idx, int inbytes) sys-utils/zramctl.c:119:39: note: shadowed declaration is here static unsigned int raw, no_headings, inbytes; libmount/src/tab.c: In function 'mnt_table_get_fs_root': libmount/src/tab.c:1221:22: warning: declaration of 'fs' shadows a parameter [-Wshadow] struct libmnt_fs *fs = mnt_table_find_mountpoint(tb, libmount/src/tab.c:1197:24: note: shadowed declaration is here struct libmnt_fs *fs, disk-utils/fsck.minix.c: In function 'main': disk-utils/fsck.minix.c:1364:17: warning: declaration of 'i' shadows a previous local [-Wshadow] unsigned long i, free; disk-utils/fsck.minix.c:1250:6: note: shadowed declaration is here int i; Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: (monitor) fix docsKarel Zak2015-08-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* 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: fix typo in mnt_optstr_prepend_option()Karel Zak2015-08-051-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: variable dereferenced before check [smatch scan]Karel Zak2015-08-051-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>