struct file *file,
struct libscols_line *ln,
int column_id,
- size_t column_index,
- const char *uri __attribute__((__unused__)))
+ size_t column_index)
{
char *str = NULL;
struct file *file __attribute__((__unused__)),
struct libscols_line *ln,
int column_id,
- size_t column_index,
- const char *uri __attribute__((__unused__)))
+ size_t column_index)
{
char *str = NULL;
const char *ename;
struct file *file __attribute__((__unused__)),
struct libscols_line *ln __attribute__((__unused__)),
int column_id,
- size_t column_index __attribute__((__unused__)),
- const char *uri __attribute__((__unused__)))
+ size_t column_index __attribute__((__unused__)))
{
switch(column_id) {
case COL_NAME:
struct file *file,
struct libscols_line *ln,
int column_id,
- size_t column_index,
- const char *uri __attribute__((__unused__)))
+ size_t column_index)
{
char *str = NULL;
mode_t ftype;
*d = '(';
if (r)
err(EXIT_FAILURE, _("failed to add output data"));
- if (uri) {
- struct libscols_cell *ce = scols_line_get_cell(ln, column_index);
- if (ce)
- scols_cell_disable_uri(ce, 1);
- }
return true;
}
}
if (file->name
&& scols_line_set_data(ln, column_index, file->name))
err(EXIT_FAILURE, _("failed to add output data"));
-
- ftype = file->stat.st_mode & S_IFMT;
- if (uri && (!file->name || *file->name != '/'
- || (ftype != S_IFREG && ftype != S_IFDIR)
- || file->stat.st_nlink == 0)) {
- struct libscols_cell *ce = scols_line_get_cell(ln, column_index);
- if (ce)
- scols_cell_disable_uri(ce, 1);
- }
return true;
case COL_STTYPE:
case COL_TYPE:
struct file *file,
struct libscols_line *ln,
int column_id,
- size_t column_index,
- const char *uri __attribute__((__unused__)))
+ size_t column_index)
{
struct nsfs_file *nsfs_file = (struct nsfs_file *)file;
char *name = NULL;
struct file *file __attribute__((__unused__)),
struct libscols_line *ln,
int column_id,
- size_t column_index,
- const char *uri __attribute__((__unused__)))
+ size_t column_index)
{
switch (column_id) {
case COL_TYPE:
struct file *file,
struct libscols_line *ln,
int column_id,
- size_t column_index,
- const char *uri __attribute__((__unused__)))
+ size_t column_index)
{
struct pidfs_file *pidfs_file = (struct pidfs_file *)file;
char *buf = NULL;
int flags;
int json_type;
const char *help;
+ bool hyperlink;
};
/* columns descriptions */
N_("list of monitoring inodes (raw, don't decode devices)") },
[COL_KNAME] = { "KNAME",
0.4, SCOLS_FL_TRUNC, SCOLS_JSON_STRING,
- N_("name of the file (raw)") },
+ N_("name of the file (raw)"),
+ .hyperlink = true },
[COL_KTHREAD] = { "KTHREAD",
0, SCOLS_FL_RIGHT, SCOLS_JSON_BOOLEAN,
N_("opened by a kernel thread") },
N_("access mode (rwx)") },
[COL_NAME] = { "NAME",
0.4, SCOLS_FL_TRUNC, SCOLS_JSON_STRING,
- N_("name of the file (cooked)") },
+ N_("name of the file (cooked)"),
+ .hyperlink = true },
[COL_NETLINK_GROUPS] = { "NETLINK.GROUPS",
0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
N_("netlink multicast groups") },
struct filler_data {
struct proc *proc;
struct file *file;
- const char *uri;
+ bool hyperlink_enabled;
};
struct lsfd_control {
scols_column_set_safechars(cl, "\n");
}
if (!(extra & SCOLS_FL_HIDDEN) && uri &&
- (id == COL_NAME || id == COL_KNAME))
+ col->hyperlink)
scols_column_set_uri(cl, uri);
}
}
+static bool should_disable_hyperlink(const struct file * file)
+{
+ mode_t ftype = file->stat.st_mode & S_IFMT;
+
+ return (file->name == NULL
+ || file->stat.st_nlink == 0
+ || *file->name != '/'
+ || (ftype != S_IFREG && ftype != S_IFDIR));
+}
+
static void fill_column(struct proc *proc,
struct file *file,
struct libscols_line *ln,
int column_id,
size_t column_index,
- const char *uri __attribute__((__unused__)))
+ bool hyperlink_enabled)
{
const struct file_class *class = file->class;
while (class) {
if (class->fill_column
&& class->fill_column(proc, file, ln,
- column_id, column_index, uri))
+ column_id, column_index)) {
+
+ if (hyperlink_enabled
+ && infos[column_id].hyperlink
+ && should_disable_hyperlink(file)) {
+ struct libscols_cell *ce = scols_line_get_cell(ln, column_index);
+ if (ce)
+ scols_cell_disable_uri(ce, 1);
+ }
+
break;
+ }
class = class->super;
}
}
struct filler_data *fid = (struct filler_data *) userdata;
fill_column(fid->proc, fid->file, ln, get_column_id(colnum), colnum,
- fid->uri);
+ fid->hyperlink_enabled);
return 0;
}
static void convert_file(struct proc *proc,
struct file *file,
struct libscols_line *ln,
- const char *uri __attribute__((__unused__)))
+ bool hyperlink_enabled)
{
size_t i;
for (i = 0; i < ncolumns; i++) {
if (scols_line_is_filled(ln, i))
continue;
- fill_column(proc, file, ln, get_column_id(i), i, uri);
+ fill_column(proc, file, ln, get_column_id(i), i, hyperlink_enabled);
}
}
static void convert(struct list_head *procs, struct lsfd_control *ctl)
{
struct list_head *p;
+ bool hyperlink_enabled = (ctl->uri != NULL);
list_for_each (p, procs) {
struct proc *proc = list_entry(p, struct proc, procs);
struct filler_data fid = {
.proc = proc,
.file = file,
- .uri = ctl->uri,
+ .hyperlink_enabled = hyperlink_enabled,
};
scols_filter_set_filler_cb(ctl->filter,
}
}
- convert_file(proc, file, ln, ctl->uri);
+ convert_file(proc, file, ln, hyperlink_enabled);
if (!ctl->ct_filters)
continue;