forked from util-linux/util-linux
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libmount: working on listmount test setup #3
Open
usiegl00
wants to merge
32
commits into
karelzak:PR/libmount-statmount
Choose a base branch
from
usiegl00:PR/libmount-statmount
base: PR/libmount-statmount
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
libmount: working on listmount test setup #3
usiegl00
wants to merge
32
commits into
karelzak:PR/libmount-statmount
from
usiegl00:PR/libmount-statmount
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Karel Zak <kzak@redhat.com>
... keep statx stuff on one place. Signed-off-by: Karel Zak <kzak@redhat.com>
* Make the includes and ifdefs in the file more generic, to cover other interfaces besides just HAVE_MOUNTFD_API. * Add #ifdef HAVE_STATMOUNT_API to the header file. * Add fallbacks for statmount and listmount masks and flags. * Add a local definition of the structs mnt_id_req and statmount. We do not want to depend on kernel headers for now, as all of this is still under development. Installed headers may provide old versions, and a solution based on #ifdef will still require local definition of the structs. * Add wrappers for the statmount() and listmount() syscalls. * Add sys_statmount(), a wrapper for statmount() that reallocates the statmount buffer (on EOVERFLOW errno) if it is not large enough. Note that for now, we are directly using syscalls and do not require libc support for statmount() and listmount(). The kernel API is very extensible, as it is based on structs rather than syscall arguments. Therefore, I doubt we will see any libc support in the near future. The code uses the "ul_" prefix for locally defined variables and functions to prevent conflicts with kernel headers and potential future versions of libc. Signed-off-by: Karel Zak <kzak@redhat.com>
The new syscalls (statmount and fd-based mount) are already being utilized in various areas within the library. Therefore, it would be more efficient to include the syscalls header file in the private main library header file. Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This change allows propagation flags to be retained from another source, such as statmount(). Signed-off-by: Karel Zak <kzak@redhat.com>
Since the Linux kernel version 6.8, there are two types of IDs available: the "old" ID used in /proc/self/mountinfo, and a new 64-bit unique ID that is never recycled. This new ID is provided by the statx(STATX_MNT_ID_UNIQUE) and statmount() syscalls. Note that this patch only adds the API for retrieving these unique IDs, but the backing code has not been implemented yet. Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* introduce libmnt_statmnt object to store statmount mask and buffer (etc.) * add API for libmnt_fs to retrieve data from the kernel using statmount() * support on-demand statmount() from old mnt_fs_get_...() functions * allow libmnt_statmnt to be shared and reused between libmnt_fs instances * allow libmnt_statmnt to be assigned and used for filesystems in the table (assign libmnt_statmnt to the table to make it usable for all filesystems). * allow temporary disabling of fetching data from the kernel to avoid unwanted recursion in certain use-cases * support namespaces for statmount() based on the libmnt_fs namespace ID setting * allow user-defined statmount masks to overwrite the default * add a sample program Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Eliminate redundant code and define time_diff() only once. Signed-off-by: Karel Zak <kzak@redhat.com>
The new listmount() syscall returns a list of unique mount IDs (just uint64_t per node, nothing else). It makes it very fast and efficient. * libmount supports two scenarios: - fetch the whole mount table by mnt_table_fetch_listmount(); this is an alternative to mnt_table_parse_file() - on demand; this mode is an extension to the current functionality, when enabled by mnt_table_enable_listmount(), then mnt_table_next_fs() will ask the kernel for data by listmount. If mnt_table_next_fs() iterates on the mount table in reverse order (MNT_ITER_BACKWARD), then it reads mount nodes from the kernel in reverse order too. The advantage of the on-demand mode is that on machines with a huge mount table (thousands of nodes), we can work with only a subset of the table (usually the last few nodes with the most recently mounted filesystems), and the kernel does not have to compose a complete huge table. This should be an improvement over the mountinfo file. The default is to read 512 nodes (IDs) by one listmount() call. This size can be altered by mnt_table_listmount_set_stepsiz(). The default size should be large enough for usual Linux machines. It's also possible to set a sub-tree by mnt_table_listmount_set_id() and a namespace by mnt_table_listmount_set_ns(). If libmnt_statmnt (on-demand statmount()) is assigned to the table, then all filesystems in the table are automatically assigned to this statmount() setup too. This allows for a completely on-demand scenario. tb = mnt_new_table(); sm = mnt_new_statmnt(); mnt_table_refer_statmnt(tb, sm); /* enable statmount() */ mnt_table_enable_listmount(tb, 1); /* enable listmount() */ while (mnt_table_next_fs(tb, itr, &fs) == 0) { if (strcmp("vfat", mnt_fs_get_fstype(fs)) == 0) print("%s", mnt_fs_get_fs_options(fs)); } In this example, mnt_table_next_fs() serves as the frontend for listmount() and mnt_fs_get_...() serves as the frontend for statmount(). The fs-options are read from kernel only for "vfat" filesystems. Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* introduce mnt_fs_try_statmount() macro to simplify mnt_fs_fetch_statmount() calls * define dummy API functions when HAVE_STATMOUNT_API undefined Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
We use uintX_t in many places in the library, and it seems useful to include inttypes.h and stdint.h to have access to the PRI* macros everywhere. Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The number of methods for reading mount nodes from the kernel is increasing. We need a way to specify the method on the findmnt(1) command line. Currently, findmnt only supports the "mountinfo" method. Another method will be added in a separate commit. Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* add missing STATMOUNT_* items * reuse merging code Signed-off-by: Karel Zak <kzak@redhat.com>
It is possible that one field in the libmnt_fs struct requires fetching multiple statmount fields using multiple STATMOUNT_* mask items. This requires changes to the way the fs->stmnt_done mask is used. Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: usiegl00 <50933431+usiegl00@users.noreply.github.com>
76376d3
to
e1190d4
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds basic tests for listmount and statmount based on the samples.