1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
'\" t
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH statmount 2 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
statmount \- get a mount status
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.BR "#include <linux/mount.h>" " /* Definition of STATMOUNT_* constants */"
.B #include <unistd.h>
.P
.BI "int syscall(SYS_statmount, struct mnt_id_req *" req ,
.BI " struct statmount *" smbuf ", size_t " bufsize ,
.BI " unsigned long " flags );
.P
.B #include <linux/mount.h>
.fi
.P
.EX
.B struct mnt_id_req {
.BR " __u32 size;" " /* sizeof(struct mnt_id_req) */"
.BR " __u64 mnt_id;" " /* The mnt_id being queried */"
.BR " __u64 param;" " /* An ORed combination of the STATMOUNT_ constants */"
.B };
.P
.B struct statmount {
.B " __u32 size;"
.B " __u64 mask;"
.B " __u32 sb_dev_major;"
.B " __u32 sb_dev_minor;"
.B " __u64 sb_magic;"
.B " __u32 sb_flags;"
.B " __u32 fs_type;"
.B " __u64 mnt_id;"
.B " __u64 mnt_parent_id;"
.B " __u32 mnt_id_old;"
.B " __u32 mnt_parent_id_old;"
.B " __u64 mnt_attr;"
.B " __u64 mnt_propagation;"
.B " __u64 mnt_peer_group;"
.B " __u64 mnt_master;"
.B " __u64 propagate_from;"
.B " __u32 mnt_root;"
.B " __u32 mnt_point;"
.B " char str[];"
.B };
.EE
.P
.IR Note :
glibc provides no wrapper for
.BR statmount (),
necessitating the use of
.BR syscall (2).
.SH DESCRIPTION
To access a mount's status,
the caller must have CAP_SYS_ADMIN in the user namespace.
.P
This function returns information about a mount,
storing it in the buffer pointed to by
.IR smbuf .
The returned buffer is a
.I struct statmount
which is of size
.I bufsize
with the fields filled in as described below.
.P
(Note that reserved space and padding is omitted.)
.SS The mnt_id_req structure
.I req.size
is used by the kernel to determine which
.I struct\~mnt_id_req
is being passed in;
it should always be set to
.IR sizeof(struct\~mnt_id_req) .
.P
.I req.mnt_id
can be obtained from either
.BR statx (2)
using
.B STATX_MNT_ID_UNIQUE
or from
.BR listmount (2)
and is used as the identifier to query the status of the desired mount point.
.P
.I req.param
is used to tell the kernel which fields the caller is interested in.
It is an ORed combination of the following constants
.P
.in +4n
.TS
lB l.
STATMOUNT_SB_BASIC /* Want/got sb_* */
STATMOUNT_MNT_BASIC /* Want/got mnt_* */
STATMOUNT_PROPAGATE_FROM /* Want/got propagate_from */
STATMOUNT_MNT_ROOT /* Want/got mnt_root */
STATMOUNT_MNT_POINT /* Want/got mnt_point */
STATMOUNT_FS_TYPE /* Want/got fs_type */
.TE
.in
.P
In general,
the kernel does
.I not
reject values in
.I req.param
other than the above.
(For an exception,
see
.B EINVAL
in errors.)
Instead,
it simply informs the caller which values are supported
by this kernel and filesystem via the
.I statmount.mask
field.
Therefore,
.I do not
simply set
.I req.param
to
.B UINT_MAX
(all bits set),
as one or more bits may,
in the future,
be used to specify an extension to the buffer.
.SS The returned information
The status information for the target mount is returned in the
.I statmount
structure pointed to by
.IR smbuf .
.P
The fields in the
.I statmount
structure are:
.TP
.I smbuf.size
The size of the returned
.I smbuf
structure,
including any of the strings fields that were filled.
.TP
.I smbuf.mask
The ORed combination of
.BI STATMOUNT_ *
flags indicating which fields were filled in and thus valid.
The kernel may return fields that weren't requested,
and may fail to return fields that were requested,
depending on what the backing file system and kernel supports.
In either case,
.I req.param
will not be equal to
.IR mask .
.TP
.I smbuf.sb_dev_major
.TQ
.I smbuf.sb_dev_minor
The device that is mounted at this mount point.
.TP
.I smbuf.sb_magic
The file system specific super block magic.
.TP
.I smbuf.sb_flags
The flags that are set on the super block,
an ORed combination of
.BR SB_RDONLY ,
.BR SB_SYNCHRONOUS ,
.BR SB_DIRSYNC ,
.BR SB_LAZYTIME .
.TP
.I smbuf.fs_type
The offset to the location in the
.I smbuf.str
buffer that contains the string representation of the mounted file system.
It is a null-terminated string.
.TP
.I smbuf.mnt_id
The unique mount ID of the mount.
.TP
.I smbuf.mnt_parent_id
The unique mount ID of the parent mount point of this mount.
If this is the root mount point then
.IR smbuf.mnt_id\~==\~smbuf.parent_mount_id .
.TP
.I smbuf.mnt_id_old
This corresponds to the mount ID that is exported by
.IR /proc/ pid /mountinfo .
.TP
.I smbuf.mnt_parent_id_old
This corresponds to the parent mount ID that is exported by
.IR /proc/ pid /mountinfo .
.TP
.I smbuf.mnt_attr
The
.BI MOUNT_ATTR_ *
flags set on this mount point.
.TP
.I smbuf.mnt_propagation
The mount propagation flags,
which can be one of
.BR MS_SHARED ,
.BR MS_SLAVE ,
.BR MS_PRIVATE ,
.BR MS_UNBINDABLE .
.TP
.I smbuf.mnt_peer_group
The ID of the shared peer group.
.TP
.I smbuf.mnt_master
The mount point receives its propagation from this mount ID.
.TP
.I smbuf.propagate_from
The ID from the namespace we propagated from.
.TP
.I smbuf.mnt_root
The offset to the location in the
.I smbuf.str
buffer that contains the string representation of the mount
relative to the root of the file system.
It is a null-terminated string.
.TP
.I smbuf.mnt_point
The offset to the location in the
.I smbuf.str
buffer that contains the string representation of the mount
relative to the current root (ie if you are in a
.BR chroot ).
It is a null-terminated string.
.SH RETURN VALUE
On success, zero is returned.
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EPERM
Permission is denied for accessing this mount.
.TP
.B EFAULT
.I req
or
.I smbuf
points to a location outside the process's accessible
address space.
.TP
.B EINVAL
Invalid flag specified in
.IR flags .
.TP
.B EINVAL
.I req
is of insufficient size to be utilized.
.TP
.B E2BIG
.I req
is too large.
.TP
.B EOVERFLOW
The size of
.I smbuf
is too small to contain either the
.IR smbuf.fs_type ,
.IR smbuf.mnt_root ,
or
.IR smbuf.mnt_point .
Allocate a larger buffer and retry the call.
.TP
.B ENOENT
The specified
.I req.mnt_id
doesn't exist.
.TP
.B ENOMEM
Out of memory (i.e., kernel memory).
.SH STANDARDS
Linux.
.SH SEE ALSO
.BR listmount (2),
.BR statx (2)
|