From: Masatake YAMATO Date: Sat, 13 Apr 2024 02:32:14 +0000 (+0900) Subject: lsns: add more print-debug code X-Git-Tag: v2.42-start~426 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5eccab6361c376a3f7945098c87ea9a4c5dd92a;p=thirdparty%2Futil-linux.git lsns: add more print-debug code Signed-off-by: Masatake YAMATO --- diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 0c66d648a..2c4ec9da0 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -543,10 +543,14 @@ static int read_process(struct lsns *ls, struct path_cxt *pc) if (procfs_process_get_uid(pc, &p->uid) == 0) add_uid(uid_cache, p->uid); - if ((rc = procfs_process_get_stat(pc, buf, sizeof(buf))) < 0) + if ((rc = procfs_process_get_stat(pc, buf, sizeof(buf))) < 0) { + DBG(PROC, ul_debug("failed in procfs_process_get_stat() (rc: %d)", rc)); goto done; - if ((rc = parse_proc_stat(buf, &p->pid, &p->state, &p->ppid)) < 0) + } + if ((rc = parse_proc_stat(buf, &p->pid, &p->state, &p->ppid)) < 0) { + DBG(PROC, ul_debug("failed in parse_proc_stat() (rc: %d)", rc)); goto done; + } rc = 0; for (i = 0; i < ARRAY_SIZE(p->ns_ids); i++) { @@ -557,8 +561,10 @@ static int read_process(struct lsns *ls, struct path_cxt *pc) rc = get_ns_ino(pc, ns_names[i], &p->ns_ids[i], &p->ns_pids[i], &p->ns_oids[i]); - if (rc && rc != -EACCES && rc != -ENOENT) + if (rc && rc != -EACCES && rc != -ENOENT) { + DBG(PROC, ul_debug("failed in get_ns_ino (rc: %d)", rc)); goto done; + } if (i == LSNS_ID_NET) p->netnsid = get_netnsid(pc, p->ns_ids[i]); rc = 0; @@ -602,7 +608,7 @@ static int read_processes(struct lsns *ls) DBG(PROC, ul_debug("reading %d", (int) pid)); rc = procfs_process_init_path(pc, pid); if (rc < 0) { - DBG(PROC, ul_debug("failed in reading /proc/%d (rc: %d)", (int) pid, rc)); + DBG(PROC, ul_debug("failed in initializing path_cxt for /proc/%d (rc: %d)", (int) pid, rc)); /* This failure is acceptable. If a process ($pid) owning * a namespace is gone while running this lsns process, * procfs_process_init_path(pc, $pid) may fail. @@ -617,8 +623,10 @@ static int read_processes(struct lsns *ls) } rc = read_process(ls, pc); - if (rc && rc != -EACCES && rc != -ENOENT) + if (rc && rc != -EACCES && rc != -ENOENT) { + DBG(PROC, ul_debug("failed in read_process() (pid: %d, rc: %d)", (int) pid, rc)); break; + } rc = 0; }