namespaces.7: Adjust example program to show device major and minor numbers

Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-12-12 07:11:41 +01:00
parent e0ff749f64
commit e6f1b08f55
1 changed files with 11 additions and 7 deletions

View File

@ -442,7 +442,7 @@ and show that new UTS namespace is associated with the new user namespace:
$ \fBunshare \-Uu sleep 1000 &\fP
[1] 23235
$ \fB./ns_introspect /proc/23235/ns/uts\fP
Inode number of owning user namespace is: 4026532448
Device/Inode of owning user namespace is: [0,3] / 4026532448
$ \fBreadlink /proc/23235/ns/user \fP
user:[4026532448]
.in
@ -456,7 +456,7 @@ example is the initial user namespace:
$ \fBreadlink /proc/self/ns/user\fP
user:[4026531837]
$ \fB./ns_introspect /proc/23235/ns/user\fP
Inode number of owning user namespace is: 4026531837
Device/Inode of owning user namespace is: [0,3] / 4026531837
.in
.fi
@ -480,16 +480,17 @@ The owning user namespace is outside your namespace scope
.nf
/* ns_introspect.c
Licensed under GNU General Public License v2 or later
Licensed under the GNU General Public License v2 or later.
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/sysmacros.h>
#ifndef NS_GET_USERNS
#define NSIO 0xb7
@ -542,7 +543,9 @@ main(int argc, char *argv[])
perror("fstat\-userns");
exit(EXIT_FAILURE);
}
printf("Inode number of owning user namespace is: %ld\\n",
printf("Device/Inode of owning user namespace is: "
"[%lx,%lx] / %ld\\n",
(long) major(sb.st_dev), (long) minor(sb.st_dev),
(long) sb.st_ino);
close(userns_fd);
@ -570,7 +573,8 @@ main(int argc, char *argv[])
perror("fstat\-parentns");
exit(EXIT_FAILURE);
}
printf("Inode number of parent namespace is: %ld\\n",
printf("Device/Inode of parent namespace is: [%lx,%lx] / %ld\\n",
(long) major(sb.st_dev), (long) minor(sb.st_dev),
(long) sb.st_ino);
close(parent_fd);