From: Masatake YAMATO Date: Mon, 3 May 2021 07:22:29 +0000 (+0900) Subject: lsfd: add NLINK and DELETED columns X-Git-Tag: v2.38-rc1~144^2~163 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fab1215879143f1d9f1be7615cfff23a0bf1d9a;p=thirdparty%2Futil-linux.git lsfd: add NLINK and DELETED columns Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd-file.c b/misc-utils/lsfd-file.c index dc19b8754e..e350dfd5c6 100644 --- a/misc-utils/lsfd-file.c +++ b/misc-utils/lsfd-file.c @@ -139,6 +139,12 @@ static bool file_fill_column(struct proc *proc, case COL_SIZE: xasprintf(&str, "%ju", file->stat.st_size); break; + case COL_NLINK: + xasprintf(&str, "%ju", (unsigned long int)file->stat.st_nlink); + break; + case COL_DELETED: + xasprintf(&str, "%d", file->stat.st_nlink == 0); + break; default: return false; }; diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index c53082aed4..0f315ce0c9 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -80,6 +80,8 @@ static struct colinfo infos[] = { N_("association between file and process") }, [COL_COMMAND] = { "COMMAND", 15, 0, SCOLS_JSON_STRING, N_("command of the process opening the file") }, + [COL_DELETED] = { "DELETED", 0, SCOLS_FL_RIGHT, SCOLS_JSON_BOOLEAN, + N_("reachability from the file system") }, [COL_DEV] = { "DEV", 0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING, N_("ID of device containing file") }, [COL_DEVICE] = { "DEVICE", 0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING, @@ -90,6 +92,8 @@ static struct colinfo infos[] = { N_("inode number") }, [COL_NAME] = { "NAME", 45, 0, SCOLS_JSON_STRING, N_("name of the file") }, + [COL_NLINK] = { "NLINK", 0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER, + N_("link count") }, [COL_PID] = { "PID", 5, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER, N_("PID of the process opening the file") }, [COL_RDEV] = { "RDEV", 0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING, diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index c156297a10..17c0a37739 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -53,11 +53,13 @@ DIR *opendirf(const char *format, ...) __attribute__((format (printf, 1, 2))); enum { COL_ASSOC, COL_COMMAND, + COL_DELETED, COL_DEVICE, COL_DEV, COL_FD, COL_INODE, COL_NAME, + COL_NLINK, COL_PID, COL_RDEV, COL_SIZE,