summaryrefslogtreecommitdiffstats
path: root/libmount
Commit message (Collapse)AuthorAgeFilesLines
...
* mount: keep MS_MOVE as flagKarel Zak2018-06-011-1/+4
| | | | | | | | The previous commit 4ebea84bb1ca6b0fa817588aba13de26c8d5e5a0 replaced all operations by strings, but it does not work for MS_MOVE as this operation is not supported in fstab by libmount. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't use MS_MGC_VAL magic in mount(2) syscallKarel Zak2018-06-013-4/+3Star
| | | | | | | | | 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-013-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | 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: include sys/mount.h on Linux onlyKarel Zak2018-05-291-1/+1
| | | | | Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=891812 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: accept another flags on MS_REMOUNT|MS_BINDKarel Zak2018-05-282-14/+11Star
| | | | | | | | | | | | | | | | | | | | | | 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: fix compiler warning [-Wunused-parameter]Karel Zak2018-05-031-4/+2Star
| | | | | Reported-by: L A Walsh <lkml@tlinx.org> 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 mnt_table_is_fs_mounted() for NFS bind mounts.NeilBrown2018-04-181-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | When you bind-mount a subdirectory of a local filesystem, the path to that subdirectory appears as the fourth field in mountinfo. For nfs mounts, the fourth field is always "/", and the subdirectory part is appended to the "special" (aka "device") field. This is consistent with historical NFS usage which always includes a path in the fs_spec field. libmount needs to know about this when "mount -a" checks to see if a filesystem is already mounted. Without this fix, fstab lines like: server::/path /dir nfs defaults 0 0 /dir/subdir /mnt/test none bind 0 0 result in a new mount at /mnt/test every time "mount -a" is run. [kzak@redhat.com: - use strappend() rather than asprintf()] Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* bugfix: fix possible segfault during umount -aRichard Fuchs2018-04-171-1/+2
| | | | | | | mnt_context_get_mtab() doesn't set its return **tb argument on error, and so in mnt_context_next_umount() mtab will remain uninitialized on error, later resulting in cxt->mtab containing garbage, possibly resulting in segfault on exit.
* libmount: include sys/mount.h only if necessaryKarel Zak2018-03-221-1/+8
| | | | | Addresses: https://github.com/systemd/systemd/issues/8507 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (docs) update yearKarel Zak2018-03-201-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix example in docsKarel Zak2018-03-201-1/+1
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/599 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: deallocate on /proc/swaps parse errorKarel Zak2018-03-201-5/+6
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/596 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make sure we deallocate on parse errorKarel Zak2018-03-201-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make libmount.h more robustKarel Zak2018-03-201-0/+1
| | | | | | | | | | Let's include sys/mount.h to be sure that our local libmount fallbacks are not used by default to avoid possible conflicts with later included sys/mount.h. Addresses: https://github.com/systemd/systemd/pull/8452 Reported-by: Lennart Poettering <lennart@poettering.net> 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: add missing macro to docsKarel Zak2018-02-211-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typos using codespellRuediger Meier2018-02-163-7/+7
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: fix debug messageKarel Zak2018-02-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: remove %p from debug messagesKarel Zak2018-02-013-12/+6Star
| | | | | | From libs where suid program may be executed by non-root user. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: remove redundant EXTRA_DIST filesRuediger Meier2018-01-221-2/+1Star
| | | | | | | The sources of AC_CONFIG_FILES (*.in) are automatically distributed. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: avoid using prog_DEPENDENCIESRuediger Meier2018-01-221-3/+1Star
| | | | | | | Use EXTRA_prog_DEPENDENCIES to have the benefit of automake's automatic prog_DEPENDENCIES. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: remove unneeded dependencies on bla.h.inRuediger Meier2018-01-221-2/+1Star
| | | | | | | | | | We have already automakes's automatic dependencies like bla.h.in -> bla.h -> foo.o -> bar.la An explicit direct dependency bla.h.in -> bar.la is redundant and useless anyways. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: automake is able to find headers in builddir ...Ruediger Meier2018-01-221-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: remove generated headers from dist tar ballRuediger Meier2018-01-221-4/+2Star
| | | | | | | | | | | | | Headers should only be listed in either *_HEADERS or *_SOURCES, especially when we want nodist_*_HEADERS. Since all the generated headers are made by configure we don't even need to use BUILT_SOURCES or other tricks. Also see automake docs 9.4.1 Built Sources Example: case "Build bindir.h from configure" Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak2018-01-171-1/+1
| | | | | | | Let's make it possible to use debug.h without environment variables. Suggested-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: don't print pointer address for SUID programsKarel Zak2018-01-121-0/+3
| | | | | | | | | | | | | | | | * introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing * use __UL_DEBUG_FL_NOADDR when SUID * move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK to provide access to the current mask from ul_debugobj(). It's better than modify all ul_debugobj() calls and use the global mask as argument. * remove never used UL_DEBUG_DEFINE_FLAG Reported-by: halfdog <me@halfdog.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mnt_table_is_fs_mounted() for rbindKarel Zak2018-01-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no difference between "bind" and "rbind" if we want to FS root to search for the FS in mountinfo file. fstab: /dev/sdc1 /mnt/foo xfs defaults 0 0 /mnt/foo /mnt/test none rw,rbind 0 0 use -a more than once: mount -a mount -a /proc/mounts (the current result): /dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0 /dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0 /dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0 /dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0 expected (fixed version) result: /dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0 /dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1528959 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-162-9/+21
| | | | | | | | | | | | | | | 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-084-20/+42
| | | | | | | | | | | | | | | | | 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: Allow MNT_FORCE and MNT_DETACH at umountJoshua Watt2017-11-081-1/+1
| | | | | | | | | MNT_FORCE and MNT_DETACH are orthogonal in the Linux kernel, so both may be specified without any problems. Even if there were a problem with this combination, it should be up to the kernel to take the correct action or report an error. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
* libmount: check waitpid() return codeKarel Zak2017-11-062-10/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Use waitpid() when waiting for mount helper child processVratislav Podzimek2017-11-062-4/+8
| | | | | | | | | | | | | 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: 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: 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: fix Python get_propagationGiuseppe Scrivano2017-09-211-8/+5Star
| | | | | | | | The current implementation would return always 0, as it is the return code of mnt_fs_get_propagation. Change the implementation to raise an exception on an error and return the propagation flags otherwise. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* libmount: export locking errors as MNT_EX_FILEIOKarel Zak2017-09-154-10/+37
| | | | | | | | | | | | 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>
* build-sys: don't use non-existing UUID_LIBSRuediger Meier2017-07-181-1/+1
| | | | | | | We've added UUID_LIBS in f77a4d1087 but I don't see what it was good for. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: make mnt_context_is_fs_mounted work for /procIvan Delalande2017-07-181-2/+12
| | | | | | | | | | | | Assume that /proc is not mounted instead of returning an error when we are unable to open the mounts and mountinfo files in /proc. Also set cxt->mtab back to NULL so that it gets properly parsed when we check if the next filesystem is mounted. The goal is to have mount -a work when /proc is not mounted, typically with /proc on the first line of fstab. Signed-off-by: Ivan Delalande <colona@arista.com>
* libmount: use _exit() in <type> handlersKarel Zak2017-06-292-7/+7
| | | | | | | 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>
* libmount: ignore "bind" from fstab on command line "remount"Karel Zak2017-06-201-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code always apply all flags from /etc/fstab on remount. Unfortunately remount+bind has special semantic and it's impossible from command line to avoid interaction with the "bind" from fstab. Example, fstab: /dev/sda1 /bar ext4 defaults 0 1 /bar /foo none bind 0 0 Command line: # mount /foo -o remount,rw produces: mount(... MS_REMOUNT|MS_BIND ) syscall This changes the per-mountpoint (VFS) ro flag to rw, but doesn't change the filesystem itself. This patch forces libmount to ignore "bind" from fstab when "-o remount" specified on command line. If you need remount+bind semantic you have to specify the "bind" flag on command line. This allow to differentiate between # mount /foo -o remount,bind,rw --> mount(MS_REMOUNT|MS_BIND) and # mount /foo -o remount,rw --> mount(MS_REMOUNT) Suggested-by: NeilBrown <neilb@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix warning "set but not used"Ruediger Meier2017-06-151-4/+2Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: remove stray semicolonsSami Kerola2017-06-143-4/+4
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-147-10/+10
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: btrfs, remove unused setter functionsRuediger Meier2017-06-141-4/+0Star
| | | | | | | We have never used them since introduced in 2cd28fc8. clang compiler warned about it. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'pylibmount-NULL-terminate-kwlist-in-Context_init' of ↵Karel Zak2017-06-121-1/+1
|\ | | | | | | | | | | | | https://github.com/zmedico/util-linux * 'pylibmount-NULL-terminate-kwlist-in-Context_init' of https://github.com/zmedico/util-linux: pylibmount: NULL terminate kwlist in Context_init
| * pylibmount: NULL terminate kwlist in Context_initZac Medico2017-06-081-1/+1
| | | | | | | | Fixes a segfault observed with python3.6.
* | libmount: (umount) use mount table filter on -c onlyKarel Zak2017-06-071-2/+9
|/ | | | | | | The path canonicalization is the worst use-case, it's better to read all mount table than try canonicalize. Signed-off-by: Karel Zak <kzak@redhat.com>