Commit Graph

665 Commits

Author SHA1 Message Date
Darsey Litzenberger e7305e4ea3 libmount: Recognize more FUSE pseudofs (avfsd, lxcfs, vmware-vmblock)
General info about these filesystems:

* fuse.avfsd: https://sourceforge.net/projects/avf/
* fuse.lxcfs: https://linuxcontainers.org/lxcfs/
* fuse.vmware-vmblock: https://github.com/vmware/open-vm-tools

Signed-off-by: Darsey Litzenberger <dlitz@dlitz.net>
2019-10-02 17:29:05 -07:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak bc747dfccf libmount: fix free() call on error
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-21 11:16:34 +02:00
Karel Zak 026f7d3020 libmount: use fmemopen() in more robust way [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 13:00:19 +02:00
Karel Zak 987ec2a696 libmount: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 16:18:48 +02:00
Karel Zak ee551c909f libmount; fix and improve read+poll mountinfo
* fix read() buffer size (stupid bug...)

* split read() EINTR and poll() based attempts

* use 100 attempts

* wait 10000 usec between attempts, but first 10 attempts are without
  this delay. It makes the function usable for usual use-cases as well
  as on very busy systems (successfully tested with 300 concurrent
  mount/umount processes)

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-29 15:50:58 +02:00
Karel Zak e4925f591c libmount: improve mountinfo reliability
The standard way how we read mount table is not reliable because
during the read() syscalls the table may be modified by some another
process. The changes in the table is possible to detect by poll()
event, and in this case it seems better to lseek to the begin of the file
and read it again. It's expensive, but better than races...

This patch does not modify mountinfo parser, but it reads all file to
memory (by read()+poll()) and than it creates memory stream
from the buffer and use it rather than a regular file stream.

It means the parser is still possible to use for normal files
(e.g. fstab) as well as for mountinfo and it's also portable to
systems where for some reason is no fmemopen().

Note that re-read after poll() event is limited to 5 attempts (but
successful read() without event zeroize the counter). It's because we
do not want to wait for consistent mountinfo for ever. It seems better
to use old (less reliable) way than hang up in read()+poll()
loop.

Addresses: https://github.com/systemd/systemd/issues/10872
Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-29 14:27:11 +02:00
Patrick Steinhardt ad167a9023 libmount: fix comment referring to passno field
There's an obvious copy-paste error in `mnt_parse_table_line` when
referring to the 6th field of the fstab format, where it says "freq"
instead of "passno". This has probably been copied from the 5th field,
which is in fact correctly labelled as "freq".

Fix the mistake by changing the comment to say "passno" instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-08-20 14:04:33 +02:00
Kevin Hao 042057d802 libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()
The "umount -f -a -r" get stuck in a endless loop when run with a
mountinfo like below:
  15 0 179:2 / / ro,relatime - ext4 /dev/root ro
  16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755
  17 15 0:4 / /proc rw,relatime - proc proc rw
  18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
  19 15 0:16 / /sys rw,relatime - sysfs sysfs rw
  20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
  21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755
  22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw
  23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
  24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
  25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k

The reason is that the two same mnt entry "/mnt/.psplash" will cause
the dst->tab set to NULL when umount this mnt entry the second time.
This will trigger an endless loop in mnt_reset_table() because that
mnt entry is linked on the libmnt_table but its .tab is set to NULL.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
2019-08-19 14:36:55 +02:00
Sami Kerola 371be858d7
libmount: fix potential null pointer dereference
This is false positive warning, but lets silence it so that if and when
warnings crop up they are easy to notice and take seriously.

libmount/src/optstr.c:354:29: warning: potential null pointer dereference
[-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-12 22:09:31 +01:00
Karel Zak 369e4c53a8 libmount: fix docs typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-13 13:45:39 +02:00
Karel Zak 2089538adb libmount: (docs) add reference to v2.33 and v2.34
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-07 12:37:28 +02:00
Karel Zak 9db442e954 libmount: add selinuxfs between pseudo filesystems
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-29 18:04:57 +02:00
Karel Zak 0e36d7c271 libmount: add bpf between pseudo filesystems
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-29 18:01:04 +02:00
Sami Kerola cbcedf6ba8
libmount: avoid possible null pointer dereference [cppcheck]
[libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:17:10 +01:00
Karel Zak cb400752a4 libmount: fix memory leak on error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 17:25:04 +02:00
Austin English 9d71482941 libmount: fix "maybe be" duplication
Signed-off-by: Austin English <austinenglish@gmail.com>
2019-05-15 13:48:47 +02:00
Karel Zak cb055909c3 libmount: return errno on failed fstab stat()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-09 10:09:34 +02:00
Karel Zak 2e5ff9db30 libmount: fix compiler warning [-Wsometimes-uninitialized]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-15 13:35:21 +02:00
Karel Zak 82e39473a5 libmount: fix memleak on parse errors
Addresses: https://github.com/systemd/systemd/pull/12252
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-15 12:55:46 +02:00
Karel Zak 6c9ab254ae libmount: don't use sscanf() for swaps parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 15:16:23 +02:00
Karel Zak 86673b3a46 libmount: don't use sscanf() for mountinfo parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 14:45:56 +02:00
Karel Zak 36fcefa651 libmount: don't use sscanf() for fstab parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 13:34:47 +02:00
Tim Hildering 9d5eb4c464 libmount: improve fs referencing in tables
* Added member 'struct libmnt_table *tab' to libmnt_fs structure.
* Added 'mnt_fs_get_table()'.
* Removed overhead from 'mnt_table_{insert,move,remove}_fs().
* Added check to 'mnt_table_set_iter()' that entry is member of table.

[kzak@redhat.com: - add to libmount.sys
                  - add to docs
                  - cleanup commit message
                  - set fs->tab = NULL before mnt_unref_fs() in mnt_table_remove_fs()]

Signed-off-by: Tim Hildering <hilderingt@posteo.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-08 11:40:20 +01:00
Stanislav Brabec 89342e0406 libmount: Recognize more fuse filesystems as pseudofs and netfs
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>
2019-03-04 11:38:28 +01:00
Karel Zak 911e694528 libmount: add mnt_table_{find,insert,move}_fs()
Add functions to insert FS into table to specified position and to
move FS between two tables.

Co-Author: Tim Hildering <hilderingt@posteo.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-21 13:49:39 +01:00
Sami Kerola 110260830d docs: fix typos [codespell]
Reference: https://github.com/codespell-project/codespell
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:22:43 +01:00
Karel Zak a57c9865f8 libmount: (tabdiff) use list_add_tail() in more robust way
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 12:35:51 +01:00
Tim Hildering beb60dbd6f libmount: check table membership before adding entry
Added validation to function 'mnt_table_add_fs()' to check that added @fs
is not already a member of another table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 11:50:52 +01:00
Karel Zak 189a1bf3b3 libmount: add support for MS_REMOUNT on --all
This patch add to support for remount-all operation to
libmount and mount(8).

For example:
	mount --all -o remount,ro -t vfat

to remount read-only all VFAT filesystems.

Addresses: https://github.com/karelzak/util-linux/issues/589
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-16 15:00:07 +01:00
Karel Zak 2859592ecb libmount: (umount) make mnt_stat_mountpoin() usable for relative paths
# 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>
2018-12-10 16:25:08 +01:00
Karel Zak 1dae161c83 libmount: export mnt_guess_system_root() by API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-10 11:39:08 +01:00
Karel Zak df61216c67 libmount: (fuse) follow only user_id= on umount
The option user= is already handled by evaluate_permissions() and by
classic mount and umount usermount support. It seems we do not need
to duplicate support for user= in is_fuse_usermount().

The option user_id= is fuse specific and it's maintained by
libfuse/kernel in /proc/self/mountinfo. This is feature we need to
support in umount(8).

Addresses: https://github.com/karelzak/util-linux/pull/705
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-30 10:25:04 +01:00
Rian Hunter 5fea669e9e libmount: Support unmount FUSE mounts
FUSE mounts don't need an fstab entry to be unmounted.
This checks if a mount is a FUSE mount before checking for
the fstab entry, and if so returns success.

[kzak@redhat.com: - use libmount tools for mount options
                  - use namespace switches
                  - cleanup code

 The requirement is user=<username> or user_id=<uid> in /proc/self/mountinfo
 for fuse filesystem. The logic is the same as for user= mount options, but in
 this case it is not maintained by libmount in userspace, but by fuse FS in kernel.]

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-30 10:25:04 +01:00
Karel Zak 4f7acf32b5 libmount: keep namespaces support optional
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-05 11:35:45 +02:00
Karel Zak 71c7d37bc4 docs: fix gtkdoc warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-24 11:21:09 +02:00
Karel Zak 2c37ca7c4b libmount: cleanup licenses sections in the files
* 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>
2018-08-16 15:43:53 +02:00
Karel Zak 4189907e6c docs: use SPDX license names
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>
2018-08-16 14:47:21 +02:00
Karel Zak 51d5109782 libmount: report context paths on debug
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-14 21:03:42 +02:00
Karel Zak 9c566fce79 libmount: (utils) fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:58:57 +02:00
Karel Zak b00dd55ac8 libmount: fix compiler warning [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:33:13 +02:00
Karel Zak 78c66fc61d lib/mangle: const quialifier cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 15:31:42 +02:00
Karel Zak ea927bde6b libmount: cleanup const in umount code
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 14:15:42 +02:00
Karel Zak a679b0823f libmount: add missing const
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:51:52 +02:00
Karel Zak 0d1e744c20 libmount: use const char in swaps parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:49:08 +02:00
Karel Zak 4e4c9629e6 libmount: use const char in mountinfo parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:48:09 +02:00
Karel Zak 4ccc64c4ca libmount: use const char in fstab parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:44:53 +02:00
Karel Zak fae8328928 libmount: add since tag for new functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-19 11:38:48 +02:00
Karel Zak 4f9d999a97 build-sys: add -Wno-cast-function-type for python
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>
2018-07-18 10:23:51 +02:00
Frank Schaefer 8a12ab5775 * break up large strings for PySys_WriteStdout() 2018-07-10 20:21:02 -05:00