Commit Graph

62 Commits

Author SHA1 Message Date
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
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
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
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 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
Vaclav Dolezal 4917d842ea libmount: add support for switching namespaces
[kzak@redhat.com: - cosmetic changes, add some comments]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 15:49:48 +02:00
Karel Zak 1b692a26f7 libmount: (docs) update year
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-20 18:56:06 +01:00
Karel Zak ebb079266d libmount: add missing macro to docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 11:43:21 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Karel Zak a81b1946a1 libmount: (docs) add missing 'since' tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 13:32:45 +02:00
Karel Zak 7b53418bf0 libmount: (docs) add unused declarations
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:17:50 +02:00
Karel Zak ea848180dd libmount: add mnt_context_get_excode()
It's pretty complex task to make mount(8) and umount(8) return code
and generate error message. It seems better to do that in the libmount
rather than force all library users to duplicate mount(8) mk_exit_code()
functions. It also means that all the messages will be translated only
once. Changes:

* all error messages are printed by warn()
* no more multi-line messages
* all messages prefixed by mount target (mountpoint)
* library provides mount(8) compatible MNT_EX_* codes

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1429531
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:10:23 +02:00
Karel Zak 6dede2f2f7 libmount: support MS_RDONLY on write-protected devices
This feature is supported by mount(8) only. It seems better move
this code to libmount. The results is more simple mount(8) and the
feature is accessible for all libmount users.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-26 17:27:02 +02:00
Karel Zak db17f201b8 libmount: reimplement mnt_match_options()
Let's use optstr.c functions to parse pattern and options strings.
It's more robust that the old original mount(8) code and it supports
quotes in the options strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-20 15:35:50 +01:00
Sébastien Helleu d673b74e9d docs: replace FTP by HTTPS in kernel.org URLs
The links to ftp://ftp.kernel.org/ are replaced by
https://www.kernel.org/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 11:22:26 +01:00
Karel Zak 81b176c4da docs: some random fixes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-27 12:52:47 +02:00
Ruediger Meier 48df5980b4 libmount: add mnt_fs_set_priority()
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>
2016-02-23 01:19:49 +01:00
Stanislav Brabec 2cd28fc82d libmount: handle btrfs default subvolume mount
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>
2016-01-26 11:14:25 +01:00
Karel Zak d5dbd57b22 docs: fix gtk-docs related warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:28:23 +02:00
Karel Zak 3df1a79ad5 libmount: add options map to docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-26 12:25:40 +01:00
Karel Zak 2b6c532e17 docs: update API docs years
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 12:03:17 +01:00
Karel Zak 0cf8312703 libmount: cleanup gtk-docs warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 11:57:15 +01:00
Karel Zak 8f52496d8e linmount: (monitor) refresh docs, headers and symbols table
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 16:19:02 +01:00
Karel Zak 9b4fc141d4 libmount: (monitor) cleanup wait/verify stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 16:19:02 +01:00
Karel Zak fc79d3ab44 libmount: split monitor initialization
The patch introduces mnt_monitor_enable_*() functions (now for
userspace only) to make the API easy to use for high-level purpose.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 16:19:02 +01:00
Karel Zak 372112e908 libmount: add new libmnt_monitor API
It's usually enough to us [e]poll() to monitor kernel mount table, but
there is no way how to monitor changes in userspace mount options
(e.g. _netdev). The management of these mount options is completely
hidden in libmount and /rub/mount/utab is private libmount file.

This patch introduces new libmnt_mount API to monitor also userspace
mount table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-05 15:30:04 +01:00
Karel Zak 7a1c36ab38 docs: rename libs xml/version.xml to xml/version-utils.xml
It seems that gtk-docs stuff is confused when we use version.xml
(package version) and xml/version.xml (library version functions).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-03 12:37:33 +02:00
Sami Kerola cc93d115de build-sys: sort gitignore files
Use 'LC_ALL=C sort -fu' order for all lists.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-12 12:06:37 +01:00
Karel Zak 51fffa7be0 libmount: add mnt_table_uniq_fs()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-11 16:59:57 +01:00
Karel Zak a53cc4e0cb libmount: add mnt_tag_is_valid()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-19 17:41:28 +01:00
Karel Zak 47cca89934 libmount: update docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-27 10:38:39 +02:00
Karel Zak c9f1585e67 libmount: add reference counter to libmnt_table
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 16:07:25 +02:00
Karel Zak 0105691d54 libmount: add reference counting to libmnt_cache
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 14:37:55 +02:00
Karel Zak 26d0c0aefd libmount: add reference counting to libmount_fs
* mnt_new_fs() returns object with refcount=1
 * mnt_free_fs() does not care about reference counter

 * new functions mnt_ref_fs() and mnt_unref_fs()

 * mnt_table_add_fs() and mnt_table_rem_fs() uses reference counter

 * libmmnt_context uses reference counter for internal FS (as it could be
   shared outside the context)

 * backwardly incompatible change:

	- FS could be deallocated after mnt_table_remove_fs()

 * it's recommended to use mnt_unref_fs() after mnt_table_add_fs()

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 12:48:42 +02:00
Karel Zak 32953aebdd libmount: add function for context userdata
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 10:01:23 +02:00
Karel Zak a2f17bb24e libmount: add mnt_table_is_empty(), improve table list usage
Currently you have to use mnt_table_remove_fs() + mnt_free_fs() to
destroy the list in the table. This is complicated in same situations.
This patch allows to use mnt_free_fs() only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20 14:35:13 +02:00
Karel Zak 686a64670e libmount: add mnt_table_{first,last}_fs()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20 13:48:43 +02:00
Karel Zak f8271ff872 libmount: add new function to docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20 12:41:53 +02:00
Ondrej Oprala 7b1333fa6a libmount: add missing declarations to libmount.h.in and documentation
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-08-01 11:23:02 +02:00
Karel Zak dcc15ce5af libmount: add mnt_table_find_mountpoint()
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>
2013-03-25 13:56:31 +01:00
Karel Zak 2029dbd9b1 docs: update year
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-15 15:18:22 +01:00
Karel Zak a3bb7e65c4 libmount: clean up header file
* 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>
2013-03-15 14:59:22 +01:00
Karel Zak 4b9d67a23d libmount: add mnt_fs_get_propagation()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 15:58:52 +01:00
Ondrej Oprala e47a19312f libmount: read optional mountinfo fields
[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>
2013-01-10 14:52:24 +01:00
Karel Zak 6870636c7f libmount: add mnt_optstr_deduplicate_option()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-01 17:51:43 +02:00
Karel Zak e39cbb7603 libmount: allow to disable swap between source and target
In some cases (for example if only one mount argument is given) may be
mount request ambivalent:

	# mount /foo

and fstab:

	/dev/sda5	/foo	rw	0	0
	/foo		/bar	bind	0	0

The libmount allows to swap between source and target (if
source is not LABEL or UUID) by default. The new function

	mnt_context_disable_swapmatch()

allows to disable this feature.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-17 21:57:22 +02:00
Karel Zak b11c9b7ee3 libmount: rename mnt_context_fstab_applied to mnt_context_tab_applied
The function is also usable in umount to detect is mtab has been
applied.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-12 17:43:34 +02:00
Karel Zak 31a938ac38 build-sys: enable libmount and libblkid docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:54 +02:00
Karel Zak 677ff053f6 libmount: add mnt_table_find_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-25 09:49:50 +02:00
Karel Zak 5d451abbbf libmount: add mnt_context_get_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 10:06:35 +02:00