History

add listmount(2) syscall

Add way to query the children of a particular mount. This is a more flexible way to iterate the mount tree than having to parse /proc/self/mountinfo. Lookup the mount by the new 64bit mount ID. If a mount needs to be queried based on path, then statx(2) can be used to first query the mount ID belonging to the path. Return an array of new (64bit) mount ID's. Without privileges only mounts are listed which are reachable from the task's root. Folded into this patch are several later improvements. Keeping them separate would make the history pointlessly confusing: * Recursive listing of mounts is the default now (cf. [1]). * Remove explicit LISTMOUNT_UNREACHABLE flag (cf. [1]) and fail if mount is unreachable from current root. This also makes permission checking consistent with statmount() (cf. [3]). * Start listing mounts in unique mount ID order (cf. [2]) to allow continuing listmount() from a midpoint. * Allow to continue listmount(). The @request_mask parameter is renamed and to @param to be usable by both statmount() and listmount(). If @param is set to a mount id then listmount() will continue listing mounts from that id on. This allows listing mounts in multiple listmount invocations without having to resize the buffer. If @param is zero then the listing starts from the beginning (cf. [4]). * Don't return EOVERFLOW, instead return the buffer size which allows to detect a full buffer as well (cf. [4]).

Miklos Szeredi committed 3 years ago

Commit b4c2bea1 parent 68385d73 files · +100 −3Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/mount.h+13−1
@@ -176,9 +176,16 @@ struct statmount { · 175 unmodified lines
176176 char str[]; /* Variable size part containing strings */
177177 };
178178
179+/*
180+ * Structure for passing mount ID and miscellaneous parameters to statmount(2)
181+ * and listmount(2).
182+ *
183+ * For statmount(2) @param represents the request mask.
184+ * For listmount(2) @param represents the last listed mount id (or zero).
185+ */
179186 struct mnt_id_req {
180187 __u64 mnt_id;
181− __u64 request_mask;
188+ __u64 param;
182189 };
183190
184191 /*
@@ -191,4 +198,9 @@ struct mnt_id_req { · 6 unmodified lines
191198 #define STATMOUNT_MNT_POINT 0x00000010U /* Want/got mnt_point */
192199 #define STATMOUNT_FS_TYPE 0x00000020U /* Want/got fs_type */
193200
201+/*
202+ * Special @mnt_id values that can be passed to listmount
203+ */
204+#define LSMT_ROOT 0xffffffffffffffff /* root mount */
205+
194206 #endif /* _UAPI_LINUX_MOUNT_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t