aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasatake YAMATO <yamato@redhat.com>2024-04-14 01:40:14 +0900
committerMasatake YAMATO <yamato@redhat.com>2024-04-15 02:05:32 +0900
commitf2a8b20d9c63f771d1fddd639ea1ec3fe034dc6d (patch)
treef6a7805511a000a17e242c8214dc65d1ae65c6e6
parentc5eccab6361c376a3f7945098c87ea9a4c5dd92a (diff)
downloadutil-linux-f2a8b20d9c63f771d1fddd639ea1ec3fe034dc6d.tar.gz
lsns: tolerate lsns_ioctl(fd, NS_GET_{PARENT,USERNS}) failing with ENOSYS
With the original code, "lsns/filedesc" test case failed on "build (qemu-user, s390x)" and "build (qemu-user, riscv64)". On the platforms, lsns_ioctl(fd, NS_GET_{PARENT,USERNS}) failed with ENOSYS. The error stoped the iteration for gathering information from /proc/[0-9]+. As a result, lsns printed nothing. We don't expect this behavior. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
-rw-r--r--sys-utils/lsns.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index 2c4ec9da0e..8b70fd7cdb 100644
--- a/sys-utils/lsns.c
+++ b/sys-utils/lsns.c
@@ -319,7 +319,11 @@ static int get_ns_ino(struct path_cxt *pc, const char *nsname, ino_t *ino, ino_t
return -errno;
if (strcmp(nsname, "pid") == 0 || strcmp(nsname, "user") == 0) {
if ((pfd = lsns_ioctl(fd, NS_GET_PARENT)) < 0) {
- if (errno == EPERM)
+ if (errno == EPERM
+ /* On the test platforms, "build (qemu-user, s390x)" and
+ * "build (qemu-user, riscv64)", the ioctl reported ENOSYS.
+ */
+ || errno == ENOSYS)
goto user;
close(fd);
return -errno;
@@ -334,7 +338,11 @@ static int get_ns_ino(struct path_cxt *pc, const char *nsname, ino_t *ino, ino_t
}
user:
if ((ofd = lsns_ioctl(fd, NS_GET_USERNS)) < 0) {
- if (errno == EPERM)
+ if (errno == EPERM
+ /* On the test platforms, "build (qemu-user, s390x)" and
+ * "build (qemu-user, riscv64)", the ioctl reported ENOSYS.
+ */
+ || errno == ENOSYS)
goto out;
close(fd);
return -errno;