We use
mnt_optstr_append_option(&o, mnt_fs_get_vfs_options(fs), NULL);
in mount.nfs, unfortunately mnt_optstr_append_option() has been marked
ass nonnull(1, 2). That's wrong because append and prepend should
robust enough to accept NULL as option name.
The patch also removes almost all __attribute__((nonnull). It seems
better to rely on assert() to have usable feedback. In many cases
(nonnull) is premature optimization for the library. This attribute
makes sense for things like strlen() or so...
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=948274
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab.c:990:34: warning: symbol 'fs' shadows an earlier one
libmount/src/tab.c:970:26: originally declared here
misc-utils/findmnt.c:492:30: warning: symbol 'tmp' shadows an earlier one
misc-utils/findmnt.c:473:14: originally declared here
fdisks/fdiskdoslabel.c:211:36: warning: symbol 'pe' shadows an earlier one
fdisks/fdiskdoslabel.c:180:20: originally declared here
fdisks/fdiskdoslabel.c:639:34: warning: symbol 'i' shadows an earlier one
fdisks/fdiskdoslabel.c:578:16: originally declared here
fdisks/fdiskdoslabel.c:947:21: warning: symbol 'i' shadows an earlier one
fdisks/fdiskdoslabel.c:924:16: originally declared here
fdisks/fdiskdoslabel.c:976:29: warning: symbol 'i' shadows an earlier one
fdisks/fdiskdoslabel.c:924:16: originally declared here
fdisks/fdiskdoslabel.c:984:29: warning: symbol 'i' shadows an earlier one
fdisks/fdiskdoslabel.c:924:16: originally declared here
[kzak@redhat.com: - don't use local 'tmp' in findmnt.c]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Append options like "exec" "suid" and "dev" to mount.<type> helpers
command line if the options are in fstab. This is relevant for root
user who calls mount(8) for fstab entries with "user,exec" etc.
Signed-off-by: Karel Zak <kzak@redhat.com>
This is more robust implementation of mnt_get_mountpoint() that does
not ignore bind mountpoints (mount --bind /mnt /mnt) as it does not
depend on st_dev numbers.
Signed-off-by: Karel Zak <kzak@redhat.com>
The function with nonnull attribute are silently optimized by gcc so
all "if (foo)" are removed if the "foo" is expected as non-null. It
make the code less usable and robust in some situations.
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't teach people C by header files, so use warn_unused_result
attribute only on places where we return allocated memory (to avoid
leaks in applications).
* merge multiple function attributes to the one list to make it
usable with gtk-doc
Signed-off-by: Karel Zak <kzak@redhat.com>
For example
mount /srv/www /mnt -o rw,group=woven,dev,suid
the group= should not be interpreted as userspace mount option, because
umount(8) expects 'group' (without =<value>).
Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Sorry, the last commit into libmount has been incomplete.
Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount ignores "ambivalent probing result" from libblkid and tries
filesystems /etc/filesystems. This is incorrect behavior.
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Linux kernel does not allow to change more than one propagation flag
by one mount(2) syscall. The flags also cannot be mixed with another
mount options. It means that the propagation flags cannot be stored in
/etc/fstab, manual "mount --make-* <mountpoint>" is always necessary
after successful mount. Painful...
This patch implements additional mount(2) after previous successful
mount(2) (or exec /sbin/mount.<type>).
For example:
mount /dev/sda1 /A -o private,unbindable,ro
or fstab entry:
/dev/sda1 /A auto ro,private,unbindable
is implemented by three mount(2) calls:
- 1st mounts /dev/sda1 with MS_RDONLY
- 2nd sets MS_PRIVATE flag
- 3rd sets MS_UNBINDABLE flag.
It's the same as as to manually call:
mount /dev/sda1 /A -o ro
mount --make-private /A
mount --make-unbindable /A
This solution is not atomic, and umount(2) is not called if
propagation flags are not successfully applied, only error is
returned.
This change does not affect libmount API, so one beautiful day when
mount(2) syscall will be improved we can drop this nasty patch.
Signed-off-by: Karel Zak <kzak@redhat.com>
[kzak@redhat.com: - rename struct member and functions from
"propagation" to "optional fields"
- split the original patch
- fix parser]
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
If the target directory (mountpoint) does not exist then mount(8) will create
it before mount.<type> is executed or mount(2) syscall is called.
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The above function infloops when the name to search for can only
be found at the beginning of /proc/cmdline but doesn't match,
e.g. when searching for "ro" in "root=/dev/sda1 quiet vga=0x31a".
* libmount/src/utils.c (mnt_get_kernel_cmdline_option): Replace
while by for loop to ensure the pointer p is incremented.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
- use __attribute__((nonnull) for functions where we not able to
return an return code ("is", "has" and some "get" functions).
- use __attribute__((nonnull) for small functions where we
always modify any of the function argument (some mnt_optstr_* functions)
Signed-off-by: Karel Zak <kzak@redhat.com>
[kzak@redhat.com: - use __ul prefix in public API,
- define minimal requirement gcc 3.4]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
- single line with '*' in /etc/filesystems means that libmount has to
read /proc/filesystems, otherwise /proc/filesystems has to be ignored
- mount(2) ENODEV is no reason to break the do_mount_by_pattern()
loop when trying to mount by /{etc,proc}/filesystems
Reported-by: NeilBrown <neilb@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
In the umount --recursive we follow entries from mountinfo, but the
entries maybe already obsolete. Especially if the hierarchy of the
mountpoints contains shared subtrees and umount(2) for one entry may
generate umount for some other entry too.
Signed-off-by: Karel Zak <kzak@redhat.com>