summaryrefslogtreecommitdiffstats
path: root/man2/ioctl_ns.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/ioctl_ns.2')
-rw-r--r--man2/ioctl_ns.248
1 files changed, 24 insertions, 24 deletions
diff --git a/man2/ioctl_ns.2 b/man2/ioctl_ns.2
index a11e54b..a21c14a 100644
--- a/man2/ioctl_ns.2
+++ b/man2/ioctl_ns.2
@@ -3,7 +3,7 @@
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\"
-.TH ioctl_ns 2 2023-05-03 "Linux man-pages 6.05.01"
+.TH ioctl_ns 2 2024-03-03 "Linux man-pages 6.7"
.SH NAME
ioctl_ns \- ioctl() operations for Linux namespaces
.SH DESCRIPTION
@@ -17,13 +17,13 @@ operations are provided to allow discovery of namespace relationships (see
and
.BR pid_namespaces (7)).
The form of the calls is:
-.PP
+.P
.in +4n
.EX
-new_fd = ioctl(fd, request);
+new_fd = ioctl(fd, op);
.EE
.in
-.PP
+.P
In each case,
.I fd
refers to a
@@ -49,7 +49,7 @@ For user namespaces,
.B NS_GET_PARENT
is synonymous with
.BR NS_GET_USERNS .
-.PP
+.P
The new file descriptor returned by these operations is opened with the
.B O_RDONLY
and
@@ -57,7 +57,7 @@ and
(close-on-exec; see
.BR fcntl (2))
flags.
-.PP
+.P
By applying
.BR fstat (2)
to the returned file descriptor, one obtains a
@@ -70,7 +70,7 @@ structure whose
This inode number can be matched with the inode number of another
.IR /proc/ pid /ns/ { pid , user }
file to determine whether that is the owning/parent namespace.
-.PP
+.P
Either of these
.BR ioctl (2)
operations can fail with the following errors:
@@ -84,7 +84,7 @@ user or PID namespace.
.TP
.B ENOTTY
The operation is not supported by this kernel version.
-.PP
+.P
Additionally, the
.B NS_GET_PARENT
operation can fail with the following error:
@@ -92,7 +92,7 @@ operation can fail with the following error:
.B EINVAL
.I fd
refers to a nonhierarchical namespace.
-.PP
+.P
See the EXAMPLES section for an example of the use of these operations.
.\" ============================================================
.\"
@@ -103,18 +103,18 @@ The
operation (available since Linux 4.11) can be used to discover
the type of namespace referred to by the file descriptor
.IR fd :
-.PP
+.P
.in +4n
.EX
nstype = ioctl(fd, NS_GET_NSTYPE);
.EE
.in
-.PP
+.P
.I fd
refers to a
.IR /proc/ pid /ns/*
file.
-.PP
+.P
The return value is one of the
.B CLONE_NEW*
values that can be specified to
@@ -132,23 +132,23 @@ operation (available since Linux 4.11) can be used to discover
the owner user ID of a user namespace (i.e., the effective user ID
of the process that created the user namespace).
The form of the call is:
-.PP
+.P
.in +4n
.EX
uid_t uid;
ioctl(fd, NS_GET_OWNER_UID, &uid);
.EE
.in
-.PP
+.P
.I fd
refers to a
.IR /proc/ pid /ns/user
file.
-.PP
+.P
The owner user ID is returned in the
.I uid_t
pointed to by the third argument.
-.PP
+.P
This operation can fail with the following error:
.TP
.B EINVAL
@@ -173,22 +173,22 @@ operations described above to perform simple
discovery of namespace relationships.
The following shell sessions show various examples of the use
of this program.
-.PP
+.P
Trying to get the parent of the initial user namespace fails,
since it has no parent:
-.PP
+.P
.in +4n
.EX
$ \fB./ns_show /proc/self/ns/user p\fP
The parent namespace is outside your namespace scope
.EE
.in
-.PP
+.P
Create a process running
.BR sleep (1)
that resides in new user and UTS namespaces,
and show that the new UTS namespace is associated with the new user namespace:
-.PP
+.P
.in +4n
.EX
$ \fBunshare \-Uu sleep 1000 &\fP
@@ -199,10 +199,10 @@ $ \fBreadlink /proc/23235/ns/user\fP
user:[4026532448]
.EE
.in
-.PP
+.P
Then show that the parent of the new user namespace in the preceding
example is the initial user namespace:
-.PP
+.P
.in +4n
.EX
$ \fBreadlink /proc/self/ns/user\fP
@@ -211,13 +211,13 @@ $ \fB./ns_show /proc/23235/ns/user p\fP
Device/Inode of parent namespace is: [0,3] / 4026531837
.EE
.in
-.PP
+.P
Start a shell in a new user namespace, and show that from within
this shell, the parent user namespace can't be discovered.
Similarly, the UTS namespace
(which is associated with the initial user namespace)
can't be discovered.
-.PP
+.P
.in +4n
.EX
$ \fBPS1="sh2$ " unshare \-U bash\fP