lsfd: add PARTITION column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This commit is contained in:
parent
353151b005
commit
b3a23f4d3a
4 changed files with 20 additions and 0 deletions
|
@ -40,11 +40,20 @@ static bool bdev_fill_column(struct proc *proc __attribute__((__unused__)),
|
|||
size_t column_index)
|
||||
{
|
||||
char *str = NULL;
|
||||
const char *partition;
|
||||
|
||||
switch(column_id) {
|
||||
case COL_TYPE:
|
||||
if (scols_line_set_data(ln, column_index, "BLK"))
|
||||
err(EXIT_FAILURE, _("failed to add output data"));
|
||||
return true;
|
||||
case COL_PARTITION:
|
||||
partition = get_partition(file->stat.st_rdev);
|
||||
if (partition) {
|
||||
str = strdup(partition);
|
||||
break;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case COL_DEVICE:
|
||||
xasprintf(&str, "%u:%u",
|
||||
major(file->stat.st_rdev),
|
||||
|
|
|
@ -180,6 +180,7 @@ static bool file_fill_column(struct proc *proc,
|
|||
{
|
||||
char *str = NULL;
|
||||
mode_t ftype;
|
||||
const char *partition;
|
||||
|
||||
switch(column_id) {
|
||||
case COL_COMMAND:
|
||||
|
@ -221,6 +222,13 @@ static bool file_fill_column(struct proc *proc,
|
|||
case COL_INODE:
|
||||
xasprintf(&str, "%llu", (unsigned long long)file->stat.st_ino);
|
||||
break;
|
||||
case COL_PARTITION:
|
||||
partition = get_partition(file->stat.st_dev);
|
||||
if (partition) {
|
||||
str = strdup(partition);
|
||||
break;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case COL_DEV:
|
||||
case COL_DEVICE:
|
||||
xasprintf(&str, "%u:%u",
|
||||
|
|
|
@ -115,6 +115,8 @@ static struct colinfo infos[] = {
|
|||
N_("link count") },
|
||||
[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,
|
||||
N_("block device name resolved by /proc/partition") },
|
||||
[COL_POS] = { "POS", 5, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
|
||||
N_("file position") },
|
||||
[COL_PROTONAME]={ "PROTONAME",0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING,
|
||||
|
|
|
@ -63,6 +63,7 @@ enum {
|
|||
COL_MODE,
|
||||
COL_NAME,
|
||||
COL_NLINK,
|
||||
COL_PARTITION,
|
||||
COL_PID,
|
||||
COL_POS,
|
||||
COL_PROTONAME,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue