]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fill ASSOC field
authorMasatake YAMATO <yamato@redhat.com>
Sat, 27 Mar 2021 21:23:24 +0000 (06:23 +0900)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:53 +0000 (11:01 +0200)
misc-utils/lsfd-fd-file.c
misc-utils/lsfd.c
misc-utils/lsfd.h

index 6a53b0d30633bd2d073ffaaac33bef55be3b81c9..eee0ffd6c586b665d5e41eb6909fc04ee1689fc5 100644 (file)
@@ -36,15 +36,19 @@ static bool fd_file_fill_column(struct proc *proc __attribute__((__unused__)),
 
        switch(column_id) {
        case COL_FD:
+       case COL_ASSOC:
                xasprintf(&str, "%d", fd_file->fd);
-               if (!str)
-                       err(EXIT_FAILURE, _("failed to add output data"));
-               if (scols_line_refer_data(ln, column_index, str))
-                       err(EXIT_FAILURE, _("failed to add output data"));
-               return true;
+               break;
+       default:
+               return false;
        };
 
-       return false;
+       if (!str)
+               err(EXIT_FAILURE, _("failed to add output data"));
+       if (scols_line_refer_data(ln, column_index, str))
+               err(EXIT_FAILURE, _("failed to add output data"));
+
+       return true;
 }
 
 const struct file_class fd_file_class = {
index a577845c284a29d4a5770e749e539a76a6a44087..c37de3dc6a5e884b0f836ade13f9e8614e1f346f 100644 (file)
@@ -75,6 +75,7 @@ struct colinfo {
 
 /* columns descriptions */
 static struct colinfo infos[] = {
+       [COL_ASSOC]   = { "ASSOC",    0, SCOLS_FL_RIGHT, N_("association between file and process") },
        [COL_COMMAND] = { "COMMAND",  0, 0,              N_("command of the process opening the file") },
        [COL_DEVICE]  = { "DEVICE",   0, SCOLS_FL_RIGHT, N_("device major and minor number") },
        [COL_FD]      = { "FD",       0, SCOLS_FL_RIGHT, N_("file descriptor for the file") },
@@ -476,7 +477,7 @@ int main(int argc, char *argv[])
                columns[ncolumns++] = COL_COMMAND;
                columns[ncolumns++] = COL_PID;
                columns[ncolumns++] = COL_USER;
-               columns[ncolumns++] = COL_FD;
+               columns[ncolumns++] = COL_ASSOC;
                columns[ncolumns++] = COL_TYPE;
                columns[ncolumns++] = COL_DEVICE;
                columns[ncolumns++] = COL_INODE;
@@ -520,6 +521,7 @@ int main(int argc, char *argv[])
                        case COL_NAME:
                        case COL_TYPE:
                        case COL_USER:
+                       case COL_ASSOC:
                                scols_column_set_json_type(cl, SCOLS_JSON_STRING);
                                break;
                        case COL_FD:
index 24c5fe8dcf2968337e57c326c15ce0d5735ad21c..77363b73f88100296c756b9d38525222c79009d7 100644 (file)
@@ -51,6 +51,7 @@ DIR *opendirf(const char *format, ...) __attribute__((format (printf, 1, 2)));
  * column IDs
  */
 enum {
+       COL_ASSOC,
        COL_COMMAND,
        COL_DEVICE,
        COL_FD,