From: Masatake YAMATO Date: Fri, 26 Mar 2021 08:26:18 +0000 (+0900) Subject: lsfd: fill INODE field X-Git-Tag: v2.38-rc1~144^2~176 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb0cd93cead9d256f685e41e3b248b23a2825de3;p=thirdparty%2Futil-linux.git lsfd: fill INODE field --- diff --git a/misc-utils/lsfd-file.c b/misc-utils/lsfd-file.c index 3a981bf83c..8a8aec1bc0 100644 --- a/misc-utils/lsfd-file.c +++ b/misc-utils/lsfd-file.c @@ -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; diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 344cf0a4bb..cbe1f9bc78 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -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; } diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index b4e85c1955..7a679e92f7 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -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,