]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: add NLINK and DELETED columns
authorMasatake YAMATO <yamato@redhat.com>
Mon, 3 May 2021 07:22:29 +0000 (16:22 +0900)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:53 +0000 (11:01 +0200)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd-file.c
misc-utils/lsfd.c
misc-utils/lsfd.h

index dc19b8754ef77251507da4d0cbb9d51221d474f6..e350dfd5c62e5d81edd6eb5627622e941a29acbe 100644 (file)
@@ -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;
        };
index c53082aed4b1429d7a8f5ffe5d3052920be70888..0f315ce0c9bc83f039b7823247e28f0da52e9a51 100644 (file)
@@ -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,
index c156297a10ec62ff777c129f12c80f0ad029574f..17c0a377396ec8e08e19bff1e2adb5a845177e52 100644 (file)
@@ -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,