From: Masatake YAMATO Date: Thu, 16 Sep 2021 15:22:14 +0000 (+0900) Subject: lsfd: add DEVTYPE column X-Git-Tag: v2.38-rc1~144^2~91 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7591516d0ea433a95e46e60a10d9e0625f3b6f99;p=thirdparty%2Futil-linux.git lsfd: add DEVTYPE column Reflecting the review comment: add DEVTYPE for blk, char, and nodev Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd-bdev.c b/misc-utils/lsfd-bdev.c index 928b1e3bda..156bb9420c 100644 --- a/misc-utils/lsfd-bdev.c +++ b/misc-utils/lsfd-bdev.c @@ -47,6 +47,11 @@ static bool bdev_fill_column(struct proc *proc __attribute__((__unused__)), if (scols_line_set_data(ln, column_index, "BLK")) err(EXIT_FAILURE, _("failed to add output data")); return true; + case COL_DEVTYPE: + if (scols_line_set_data(ln, column_index, + "blk")) + err(EXIT_FAILURE, _("failed to add output data")); + return true; case COL_DEVNAME: case COL_PARTITION: partition = get_partition(file->stat.st_rdev); diff --git a/misc-utils/lsfd-cdev.c b/misc-utils/lsfd-cdev.c index 5344c29892..c65cfff6c2 100644 --- a/misc-utils/lsfd-cdev.c +++ b/misc-utils/lsfd-cdev.c @@ -67,6 +67,11 @@ static bool cdev_fill_column(struct proc *proc __attribute__((__unused__)), break; } return true; + case COL_DEVTYPE: + if (scols_line_set_data(ln, column_index, + "char")) + err(EXIT_FAILURE, _("failed to add output data")); + return true; case COL_CHRDRV: chrdrv = get_chrdrv(major(file->stat.st_rdev)); if (chrdrv) diff --git a/misc-utils/lsfd-file.c b/misc-utils/lsfd-file.c index d9a7a19001..0c88c8569d 100644 --- a/misc-utils/lsfd-file.c +++ b/misc-utils/lsfd-file.c @@ -207,6 +207,11 @@ static bool file_fill_column(struct proc *proc, (int)proc->uid)->name)) err(EXIT_FAILURE, _("failed to add output data")); return true; + case COL_DEVTYPE: + if (scols_line_set_data(ln, column_index, + "nodev")) + err(EXIT_FAILURE, _("failed to add output data")); + return true; case COL_FD: if (file->association < 0) return false; diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 3a7f5c89b2..1e877963cd 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -109,6 +109,8 @@ static struct colinfo infos[] = { N_("ID of device containing file") }, [COL_DEVNAME] = { "DEVNAME", 0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING, N_("device name, decoded version of DEVICE") }, + [COL_DEVTYPE] = { "DEVTYPE", 0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING, + N_("device type (blk, char, or nodev") }, [COL_FLAGS] = { "FLAGS", 0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING, N_("flags specified when opening the file") }, [COL_FD] = { "FD", 0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER, diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index 1fc6b7e03c..fa077ee1c5 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -46,6 +46,7 @@ enum { COL_DELETED, COL_DEV, COL_DEVNAME, + COL_DEVTYPE, COL_FD, COL_FLAGS, COL_INODE,