]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fill INODE field
authorMasatake YAMATO <yamato@redhat.com>
Fri, 26 Mar 2021 08:26:18 +0000 (17:26 +0900)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:53 +0000 (11:01 +0200)
misc-utils/lsfd-file.c
misc-utils/lsfd.c
misc-utils/lsfd.h

index 3a981bf83c763b420926bbb1c6a5c0973a049a50..8a8aec1bc00c069c5a44d9c84a62a9e06343e714 100644 (file)
@@ -83,6 +83,9 @@ static bool file_fill_column(struct proc *proc,
                                               (int)file->stat.st_uid)->name))
                        err(EXIT_FAILURE, _("failed to add output data"));
                return true;
+       case COL_INODE:
+               xasprintf(&str, "%llu", (unsigned long long)file->stat.st_ino);
+               break;
        case COL_PID:
                xasprintf(&str, "%d", (int)proc->pid);
                break;
index 344cf0a4bb1dafff7536173839330412c742f1f2..cbe1f9bc78927fd4af009b5f0fffaa6c431ebb36 100644 (file)
@@ -75,16 +75,16 @@ struct colinfo {
 
 /* columns descriptions */
 static struct colinfo infos[] = {
-       [COL_PID]     = { "PID",      0, SCOLS_FL_RIGHT, N_("PID of the process opening the file") },
+       [COL_COMMAND] = { "COMMAND",  0, 0,              N_("command of the process opening the file") },
        [COL_FD]      = { "FD",       0, SCOLS_FL_RIGHT, N_("file descriptor for the file") },
+       [COL_INODE]   = { "INODE",    0, SCOLS_FL_RIGHT, N_("inode number") },
        [COL_NAME]    = { "NAME",     0, 0,              N_("name of the file") },
-       [COL_COMMAND] = { "COMMAND",  0, 0,              N_("command of the process opening the file") },
+       [COL_PID]     = { "PID",      0, SCOLS_FL_RIGHT, N_("PID of the process opening the file") },
        [COL_TYPE]    = { "TYPE",     0, SCOLS_FL_RIGHT, N_("file type") },
-       [COL_USER]    = { "USER",     0, SCOLS_FL_RIGHT, N_("user of the process") },
        [COL_UID]     = { "UID",      0, SCOLS_FL_RIGHT, N_("user ID number") },
+       [COL_USER]    = { "USER",     0, SCOLS_FL_RIGHT, N_("user of the process") },
        /* DEVICE */
        /* SIZE/OFF */
-       /* NODE */
 };
 
 static int columns[ARRAY_SIZE(infos) * 2] = {-1};
@@ -473,6 +473,7 @@ int main(int argc, char *argv[])
                columns[ncolumns++] = COL_USER;
                columns[ncolumns++] = COL_FD;
                columns[ncolumns++] = COL_TYPE;
+               columns[ncolumns++] = COL_INODE;
                columns[ncolumns++] = COL_NAME;
        }
 
index b4e85c195514520d6d23d3102bcdd8e96fa381a0..7a679e92f7d82450fdae7ea1720be4ae59d311dc 100644 (file)
@@ -51,10 +51,11 @@ DIR *opendirf(const char *format, ...) __attribute__((format (printf, 1, 2)));
  * column IDs
  */
 enum {
-       COL_PID,
+       COL_COMMAND,
        COL_FD,
+       COL_INODE,
        COL_NAME,
-       COL_COMMAND,
+       COL_PID,
        COL_TYPE,
        COL_UID,
        COL_USER,