* 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>
Let's use standardized names for licenses. The names used by SPDX
makes things more obvious at first glance. For complete list see:
https://spdx.org/licenses/
Note, this commit does not change any license or so...
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/python/pylibmount.c:158:19: warning: cast between incompatible function types
from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’}
to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’}
[-Wcast-function-type]
This is generic problem in all Python C code and gcc v8. The another
possible (and probably more correct) way is to add unused argument to
all API functions. Unfortunately, this solution is pretty invasive. The
question is if gcc is not too paranoid in this case.
For more details see https://bugs.python.org/issue33012. It seems
Python guys also prefer CFLAGS modification for now.
Signed-off-by: Karel Zak <kzak@redhat.com>
The source of a mount in /proc/self/mountinfo can unfortunately be an
empty string. Before this patch, 'mount' and 'mountpoint' fail as
following:
$ sudo mount -t tmpfs "" /tmp/bb
$ mount
mount: /proc/self/mountinfo: parse error at line 64 -- ignored
$ mountpoint /tmp/bb
/tmp/bb is not a mountpoint
This patch fixes the parsing. It is unfortunately more complex because
sscanf() does not handle fields with empty strings easily.
Other projects have their own parser for mountinfo and have similar
issues. I know of runc and runtime-tools (I'll send a patch for those
two) but there are probably others.
Signed-off-by: Alban Crequy <alban@kinvolk.io>
The previous commit 4ebea84bb1 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>
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 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>
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>
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>
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.
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>
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>
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>
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>
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>
* 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>
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>