]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: add FUID and OWNER columns
authorMasatake YAMATO <yamato@redhat.com>
Mon, 11 Oct 2021 21:42:37 +0000 (06:42 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 11 Oct 2021 22:02:05 +0000 (07:02 +0900)
UID and USER is for processes.
FUID and OWNER is for owners of files.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd-file.c
misc-utils/lsfd.1.adoc
misc-utils/lsfd.c
misc-utils/lsfd.h

index e609d670918ecf0f8b130594c2d6e25165276dc0..9b860340dcae4af09d43846ff836e7e41f0fe3c8 100644 (file)
@@ -224,6 +224,13 @@ static bool file_fill_column(struct proc *proc,
                                               (int)proc->uid)->name))
                        err(EXIT_FAILURE, _("failed to add output data"));
                return true;
+       case COL_OWNER:
+               add_uid(username_cache, (int)file->stat.st_uid);
+               if (scols_line_set_data(ln, column_index,
+                                       get_id(username_cache,
+                                              (int)file->stat.st_uid)->name))
+                       err(EXIT_FAILURE, _("failed to add output data"));
+               return true;
        case COL_DEVTYPE:
                if (scols_line_set_data(ln, column_index,
                                        "nodev"))
@@ -282,6 +289,9 @@ static bool file_fill_column(struct proc *proc,
        case COL_UID:
                xasprintf(&str, "%d", (int)proc->uid);
                break;
+       case COL_FUID:
+               xasprintf(&str, "%d", (int)file->stat.st_uid);
+               break;
        case COL_SIZE:
                xasprintf(&str, "%ju", file->stat.st_size);
                break;
index 56b8c01ffd62a4b5fa0364620e4e0c454e220765..364d2450ba2c5e80be205e90343ae4ebac43e896 100644 (file)
@@ -89,6 +89,9 @@ File descriptor for the file.
 FLAGS::
 Flags specified when opening the file.
 
+FUID::
+User ID number of the file's owner.
+
 INODE::
 Inode number.
 
@@ -113,6 +116,9 @@ Name of the file.
 NLINK::
 Link count.
 
+OWNER::
+Owner of the file.
+
 PARTITION::
 Block device name resolved by _/proc/partition_.
 
index cf2a1497db27ec0695732dca8b980c473c46c8cf..251456f9b3cad56e70b9ec1e9344bb55f8b09372 100644 (file)
@@ -104,6 +104,8 @@ static struct colinfo infos[] = {
                N_("flags specified when opening the file") },
        [COL_FD]      = { "FD",       0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
                N_("file descriptor for the file") },
+       [COL_FUID]    = { "FUID",     0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
+               N_("user ID number of the file's owner") },
        [COL_INODE]   = { "INODE",    0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
                N_("inode number") },
        [COL_MAJMIN]  = { "MAJ:MIN",  0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING,
@@ -120,6 +122,8 @@ static struct colinfo infos[] = {
                N_("name of the file") },
        [COL_NLINK]   = { "NLINK",    0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
                N_("link count") },
+       [COL_OWNER]   = { "OWNER",     0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING,
+               N_("owner of the file") },
        [COL_PID]     = { "PID",      5, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
                N_("PID of the process opening the file") },
        [COL_PARTITION]={ "PARTITION",0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING,
index 368b5be28bf667b523e9c663aa64478276c32de8..7dbc4220b48555dbb1c315f552492f4865bdfb23 100644 (file)
@@ -66,8 +66,10 @@ enum {
        COL_SOURCE,
        COL_TID,
        COL_TYPE,
-       COL_UID,
-       COL_USER,
+       COL_UID,                /* proess */
+       COL_USER,               /* process */
+       COL_FUID,               /* file */
+       COL_OWNER,              /* file */
        LSFD_N_COLS             /* This must be at last. */
 };