]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsns: fill the netsid member of lsns_process with reliable value
authorMasatake YAMATO <yamato@redhat.com>
Sat, 13 Apr 2024 17:05:10 +0000 (02:05 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 14 Apr 2024 17:06:53 +0000 (02:06 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
sys-utils/lsns.c

index 8b70fd7cdb470f4e7c005121b17c88416e211ac8..0ab5e26a3079f743c5f2cc4474e95eb48ad2b85b 100644 (file)
@@ -305,6 +305,7 @@ static int get_ns_ino(struct path_cxt *pc, const char *nsname, ino_t *ino, ino_t
 
        snprintf(path, sizeof(path), "ns/%s", nsname);
 
+       *ino = 0;
        if (ul_path_stat(pc, &st, 0, path) != 0)
                return -errno;
        *ino = st.st_ino;
@@ -573,7 +574,7 @@ static int read_process(struct lsns *ls, struct path_cxt *pc)
                        DBG(PROC, ul_debug("failed in get_ns_ino (rc: %d)", rc));
                        goto done;
                }
-               if (i == LSNS_ID_NET)
+               if (p->ns_ids[i] && i == LSNS_ID_NET)
                        p->netnsid = get_netnsid(pc, p->ns_ids[i]);
                rc = 0;
        }