Commit Graph

14173 Commits

Author SHA1 Message Date
Ian Kent 117a4baffd libmount: get all mount ids at once 2020-07-21 15:19:04 +02:00
Ian Kent 7003b502b6 libmount: add function mnt_fsinfo_get_mounts()
Add a function that gets all mounts at once using FSINFO_ATTR_MOUNT_ALL.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-07-21 15:19:04 +02:00
Ian Kent e523affd6f libmount: fix vfs_options handling
The vfs_options handling isn't mapping the options properly for
libmount and the previous change I did for MS_RELATIME simply
doesn't work either.

So add an options mapping table to deal withi this.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-07-21 15:19:04 +02:00
Ian Kent c791058243 libmount: fix mnt_has_fsinfo()
When USE_LIBMOUNT_SUPPORT_FSINFO is set function mnt_has_fsinfo() doesn't
set have_fsinfo to other than -1 so the fsinfo() system call is made
on every invocation and -1 is always returned.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-07-21 15:19:04 +02:00
Karel Zak bf715d42af libmount: add watch-queue sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-22 17:03:58 +02:00
Karel Zak 7baaf3c251 libmount: (kernelwatch) fix and extend ID use
We need to differentiate between ID (of the node) which triggered
the event and child which is affected by the change.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-22 17:01:53 +02:00
Karel Zak 522d134700 libmount: (monitor) print FS target in test
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-22 15:57:40 +02:00
Karel Zak 5a9a9ab7ad libmount: add mnt_fs_set_id()
This function is necessary to force fsinfo stuff follow specific FS (id).

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-22 15:56:13 +02:00
Karel Zak f3d523724b libmount: add kernelwatch API
This is very simple interface to hide linux/watch_queue.h details when
we use data from notification read(). The interface is independent on
libmnt_monitor.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-22 15:45:19 +02:00
Karel Zak dbf6243597 libmount: (monitor) add "kernelwatch" monitor type
This monitor uses watch_mount() kernel API to get details about
modified VFS nodes. The patch implements only very basic
functionality. In the next commits we need  to support watch_sb() and
connect all with libmount fsinfo stuff to hid all details.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-19 14:08:56 +02:00
Karel Zak 386d42fa5d libmount: (monitor) add functions to return event data
* mnt_monitor_keep_data() to enable this feture
* mnt_monitor_event_data() to return data after a change

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-19 09:19:07 +02:00
Karel Zak e1f7681834 libmount: (monitor) fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-17 18:15:21 +02:00
Karel Zak 98fd10f63f libmount: (monitor) don't repeat inotify_rm_watch() call
The directory /run/mount watch generates more vents, call
inotify_rm_watch() only first time for the directory watch.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-17 18:08:56 +02:00
Karel Zak cb201c9c8b libmount: (monitor) cleanup debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-17 18:00:53 +02:00
Karel Zak 8386d586b4 libmount: move notification buffer to monitor entry
Don't keep the buffer as local variable for read() operation, but keep
it in memory for later use. We will use it for mount-watch-queue
later.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-10 16:15:16 +02:00
Karel Zak b372c1b637 libmount: fix compiler warning [-Wunused-function]
libmount/src/tab_parse.c:715:12: warning: ‘parse_fsinfo_init_fs’ defined but not used [-Wunused-function]

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-10 16:09:48 +02:00
Karel Zak c0cffb7c0f libmount: don't use eplty strings from fsinfo
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 16:26:50 +02:00
Karel Zak d15875e29c libmount: mnt_table_parse_fsinfo() refactoring
- add root FS
- reuse FS initialization code

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 16:15:09 +02:00
Karel Zak 783d41e43d libmount: cleanup dbg messages and tree functions
- don't use mnt_fs_get_root() (mnt_fs_get_id() is cheaper)
- don't use in DBG() stuff which triggers fsinfo()

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 16:13:20 +02:00
Karel Zak 25f56a9455 libmount: be more verbose about fsinfo rc
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 16:12:29 +02:00
Karel Zak abd584bee0 findmnt: use ID to detect tree-ability
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 16:11:44 +02:00
Karel Zak 4b5ec23c5a libmount: optimize kernel_fs_postparse use
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 15:01:39 +02:00
Karel Zak b8ed57bdf3 libmount: don't trigger fsinfo() by debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 15:01:05 +02:00
Karel Zak 1728c6238d libmount: create optstr on-demand 2020-04-24 15:00:26 +02:00
Karel Zak 1cdddcfa32 findmnt: fix cache read for fsinfo()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 14:58:48 +02:00
Karel Zak 464ee2c8fe libmount: read tid only once
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 13:00:23 +02:00
Karel Zak aa312e00ae findmnt: add --fsinfo
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 12:59:46 +02:00
Ian Kent a31dcde3f9 libmount: add mnt_table_parse_fsinfo()
The new public API function to read complete mount table by fsinfo().
For tests use:

	$ make test_mount_tab
	$ ./test_mount_tab --fsinfo

[kzak@redhat.com: - add commit message, cleanup function names, etc.]

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-24 12:19:50 +02:00
Karel Zak 0f728eee37 libmount: fix fs->fsinfo_done use
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-23 16:15:44 +02:00
Karel Zak 446c847415 libmount: add mnt_has_fsinfo()
* add mnt_has_fsinfo()
* cleanup stuff around fs->fsinfo_enabled
* probe for fsinfo() in umount in effective way

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-23 15:37:13 +02:00
Karel Zak 7ecabf3a9c libmount: implement on-demand fsinfo() call for libmnt_fs
Use mnt_fs_enable_fsinfo() to enable fsinfo() calls.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-23 11:26:22 +02:00
Karel Zak bb881ebf61 libmount: make fsinfo optional
* add USE_LIBMOUNT_SUPPORT_FSINFO to build-system with dependence on linux/fsinfo.h
* use #ifdefs to enable fsinfo code only if possible
* add "fsinfo" to mount --version output

* for non-distro kernel headers use:

   CFLAGS="-I /usr/src/$(uname -r)/usr/include" ./configure

 and see ./configure script output and config.h for more details.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-20 18:06:02 +02:00
Karel Zak 3fd6302906 libmount: move fsinfo calls to separate file
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-20 17:37:59 +02:00
Ian Kent a41fc98ad0 libmount: dont use fd in mnt_fs_fetch_fsinfo()
Using open(2) will trigger autofs direct and offset mounts so it
shouldn't be used in mnt_fs_fetch_fsinfo().

The mount id is a better choice here.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-04-20 16:19:36 +02:00
Ian Kent e6a848597c libmount: fix fsinfo_buf2fs() compile warning
The fsinfo_buf2fs() bufsz parameter isn't used and generates a compile
warning.

But the following len parameter has already been checked to enusre it's
smaller that the buf size so remove the unused parameter.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-04-20 16:19:36 +02:00
Ian Kent 3708880a48 libmount: fix merge of options in fsinfo_buf2fs()
The mount attribute MOUNT_ATTR_RELATIME is defined as 0 in the fsinfo()
header files.

The vfs option relatime is included in the vfs options proc string only
if noatime and strictatime are not set so this option gets ommitted when
using fsinfo().

This maybe should be fixed in mnt_optstr_apply_flags() but it's a special
case that may cause side effects for non fsinfo() use. Or perhaps fsinfo()
should set the flag to its MS_* counterpart similar to the other MOUNT_ATTR_*
flags, not sure?

In any case I needed this set so added this hack.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-04-20 16:19:36 +02:00
Ian Kent de1aa60bdb libmount: fix incorrect error check in mnt_fs_fetch_fsinfo()
Umm ... looks wrong and causes false -ENAMETOOLONG error returns.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-04-20 16:19:36 +02:00
Ian Kent 27c6c71003 libmount-fix-type-mismatch-in-mnt_fs_fetch_fsinfo
Using ARRAY_SIZE() causes a sign comparision warning, change the
counter to an unsigned int.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-04-20 16:19:36 +02:00
Ian Kent 5fe931f872 libmount: update fsinfo includes
After a make in the kernel source tree all that's needed to build against
a kernel with fsinfo() is:
CFLAGS="-I <kernel source base>/usr/include"

Also, using the above include path will define __NR_fsinfo so checking
if it's defined and seting it to -1 is enough to handle kernels without
fsinfo().

And move the include directives to the top of fs.c.

Signed-off-by: Ian Kent <raven@themaw.net>
2020-04-20 16:19:36 +02:00
Karel Zak f6e42e342d libmount: (experimental) add fsinfo() support for umount
This patch allows to replace mountinfo parsing by fsinfo() call, it
means we do not have to parse all irrelevant content in mountinfo, but
get information about desired mountpoint.

Use (for example):

 CFLAGS=-I/usr/src/kernels/5.6.0-0.rc6.git0.1.fsinfo.fc33.x86_64/include/uapi/ \
        -I/usr/src/kernels/5.6.0-0.rc6.git0.1.fsinfo.fc33.x86_64/include \
        ./configure

to point to your experimental kernel headers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-03 12:44:19 +02:00
Karel Zak 3ee27dc5b3 libmount: initialize utab path only once
The function mnt_context_utab_writable() initializes paths in the
context and then we can use it on many places.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-03 12:42:38 +02:00
Karel Zak 01aede7316 libmount: use separate function to search in utab
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-02 14:08:09 +02:00
Karel Zak 2bf3ef7666 libmount: move utab merge code to mnt_fs_merge_utab()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-02 12:40:52 +02:00
Karel Zak 8aa73754e0 libmount: keep propagation as flag in libmnt_fs
Let's generate the flag when parse mountinfo rather than later in
mnt_fs_get_propagation(). It's more efficient (we parse the optimal
mountinfo field only once) and it allows to set propagation from
another source in future.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-02 11:28:05 +02:00
Karel Zak a971746370 libmount: make mnt_context_find_umount_fs() more extendable
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-27 11:34:12 +01:00
Karel Zak 4ce77c625a libmount: (umount) FS lookup refactoring
Let's split lookup to more function to make it easy to add another
lookup method.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-27 11:10:26 +01:00
Damien Le Moal 46cf662532 blkzone: ioctl related code refactoring
[kzak@redhat.com: - generate patch from Damien's v3
                  - make commands[] initialization more robust]

Signed-off-by: Aravind Ramesh <Aravind.Ramesh@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-26 11:27:50 +01:00
Aravind Ramesh 0cecae9c03 blkzone: add open/close/finish commands
Introduce blkzone open, close and finish commands, issuing BLKOPENZONE,
BLKCLOSEZONE and BLKFINISHZONE ioctl commands to open, close or finish
a range of zones of a zoned block device.

Since these three commands are similar to the existing zone reset
command, the existing zone reset command implementation is changed into
the generic blkzone_action() internal handler function for processing
all zone actions.

The BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl commands codes are
defined in linux/blkzoned.h starting with kernel version 5.5. To ensure
that the blkzone utility compiles even with older blkzoned.h kernel
header versions, these ioctl commands are internally defined if the
blkzoned.h header definition is not present. Execution of these commands
on kernels older than 5.5 will result in a -ENOTTY error (missing
ioctl).

Signed-off-by: Aravind Ramesh <Aravind.Ramesh@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Tested-by: Hans Holmberg <Hans.Holmberg@wdc.com>
Reviewed-by: Hans Holmberg <Hans.Holmberg@wdc.com>
2020-03-25 12:27:13 +01:00
Karel Zak e7db499f1c tests: cleanup fdisk based stuff
* use fdisk --noauto-pt to avoid re-creation of the default architecture specific PT
* use more verbose "Created a new" messages in the output

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 14:30:16 +01:00
Karel Zak 53a808562d fdisk: make sure label defined for some menu entries
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 12:00:28 +01:00