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
|
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH listmount 2 2025-09-06 "Linux man-pages (unreleased)"
.SH NAME
listmount
\-
get a list of mount ID's
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.BR "#include <linux/mount.h>" " /* Definition of struct mnt_id_req constants */"
.B #include <unistd.h>
.P
.BR "int syscall(" "size_t n;"
.BI " SYS_listmount, struct mnt_id_req *" req ,
.BI " uint64_t " mnt_ids [ n "], size_t " n ,
.BI " unsigned long " flags );
.P
.B #include <linux/mount.h>
.P
.B struct mnt_id_req {
.BR " __u32 size;" " /* sizeof(struct mnt_id_req) */"
.BR " __u64 mnt_id;" " /* The parent mnt_id being searched */"
.BR " __u64 param;" " /* The next mnt_id we want to find */"
.B };
.fi
.P
.IR Note :
glibc provides no wrapper for
.BR listmount (),
necessitating the use of
.BR syscall (2).
.SH DESCRIPTION
To access the mounts in your namespace,
you must have CAP_SYS_ADMIN in the user namespace.
.P
This function returns a list of mount IDs under the
.BR req.mnt_id .
This is meant to be used in conjuction with
.BR statmount (2)
in order to provide a way to iterate and discover mounted file systems.
.SS The mnt_id_req structure
.I req.size
is used by the kernel to determine which struct
.I mnt_id_req
is being passed in,
it should always be set to
.IR \%sizeof(struct\~mnt_id_req) .
.P
.I req.mnt_id
is the parent mnt_id that we will list from,
which can either be
.B LSMT_ROOT
which means the root mount of the current mount namespace,
or a mount ID obtained from either
.BR statx (2)
using
.B STATX_MNT_ID_UNIQUE
or from
.BR listmount (2) .
.P
.I req.param
is used to tell the kernel what mount ID to start the list from.
This is useful if multiple calls to
.BR listmount (2)
are required.
This can be set to the last mount ID returned in order to
resume from a previous spot in the list.
.SH RETURN VALUE
On success, the number of entries filled into
.I mnt_ids
is returned;
0 if there are no more mounts left.
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EPERM
The caller does not have
.B CAP_SYS_ADMIN
in the user namespace.
.TP
.B EFAULT
.I req
or
.I mnt_ids
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,
the limit is the architectures page size.
.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 statmount (2),
.BR statx (2)
|