History

add statmount(2) syscall

Add a way to query attributes of a single mount instead of having to parse the complete /proc/$PID/mountinfo, which might be huge. Lookup the mount 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. Design is based on a suggestion by Linus: "So I'd suggest something that is very much like "statfsat()", which gets a buffer and a length, and returns an extended "struct statfs" *AND* just a string description at the end." The interface closely mimics that of statx. Handle ASCII attributes by appending after the end of the structure (as per above suggestion). Pointers to strings are stored in u64 members to make the structure the same regardless of pointer size. Strings are nul terminated.

Miklos Szeredi committed 3 years ago

Commit 46eae991 parent 56c94c63 files · +339 −0Browse files

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

Unified · Split

include/uapi/linux/mount.h+53−0
@@ -138,4 +138,57 @@ struct mount_attr { · 137 unmodified lines
138/* List of all mount_attr versions. */138/* List of all mount_attr versions. */
139#define MOUNT_ATTR_SIZE_VER0 32 /* sizeof first published struct */139#define MOUNT_ATTR_SIZE_VER0 32 /* sizeof first published struct */
140 140
141
142/*
143 * Structure for getting mount/superblock/filesystem info with statmount(2).
144 *
145 * The interface is similar to statx(2): individual fields or groups can be
146 * selected with the @mask argument of statmount(). Kernel will set the @mask
147 * field according to the supported fields.
148 *
149 * If string fields are selected, then the caller needs to pass a buffer that
150 * has space after the fixed part of the structure. Nul terminated strings are
151 * copied there and offsets relative to @str are stored in the relevant fields.
152 * If the buffer is too small, then EOVERFLOW is returned. The actually used
153 * size is returned in @size.
154 */
155struct statmount {
156 __u32 size; /* Total size, including strings */
157 __u32 __spare1;
158 __u64 mask; /* What results were written */
159 __u32 sb_dev_major; /* Device ID */
160 __u32 sb_dev_minor;
161 __u64 sb_magic; /* ..._SUPER_MAGIC */
162 __u32 sb_flags; /* SB_{RDONLY,SYNCHRONOUS,DIRSYNC,LAZYTIME} */
163 __u32 fs_type; /* [str] Filesystem type */
164 __u64 mnt_id; /* Unique ID of mount */
165 __u64 mnt_parent_id; /* Unique ID of parent (for root == mnt_id) */
166 __u32 mnt_id_old; /* Reused IDs used in proc/.../mountinfo */
167 __u32 mnt_parent_id_old;
168 __u64 mnt_attr; /* MOUNT_ATTR_... */
169 __u64 mnt_propagation; /* MS_{SHARED,SLAVE,PRIVATE,UNBINDABLE} */
170 __u64 mnt_peer_group; /* ID of shared peer group */
171 __u64 mnt_master; /* Mount receives propagation from this ID */
172 __u64 propagate_from; /* Propagation from in current namespace */
173 __u32 mnt_root; /* [str] Root of mount relative to root of fs */
174 __u32 mnt_point; /* [str] Mountpoint relative to current root */
175 __u64 __spare2[50];
176 char str[]; /* Variable size part containing strings */
177};
178
179struct mnt_id_req {
180 __u64 mnt_id;
181 __u64 request_mask;
182};
183
184/*
185 * @mask bits for statmount(2)
186 */
187#define STATMOUNT_SB_BASIC 0x00000001U /* Want/got sb_... */
188#define STATMOUNT_MNT_BASIC 0x00000002U /* Want/got mnt_... */
189#define STATMOUNT_PROPAGATE_FROM 0x00000004U /* Want/got propagate_from */
190#define STATMOUNT_MNT_ROOT 0x00000008U /* Want/got mnt_root */
191#define STATMOUNT_MNT_POINT 0x00000010U /* Want/got mnt_point */
192#define STATMOUNT_FS_TYPE 0x00000020U /* Want/got fs_type */
193
141#endif /* _UAPI_LINUX_MOUNT_H */194#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