dev_minor);
}
+static char *strnrstr(const char *haystack, const char *needle, size_t needle_len)
+{
+ char *last = strstr(haystack, needle);
+ if (last == NULL)
+ return NULL;
+
+ do {
+ char *current = strstr(last + needle_len, needle);
+ if (current == NULL)
+ return last;
+ last = current;
+ } while (1);
+}
+
static bool file_fill_column(struct proc *proc,
struct file *file,
struct libscols_line *ln,
&& scols_line_set_data(ln, column_index, proc->command))
err(EXIT_FAILURE, _("failed to add output data"));
return true;
- case COL_KNAME:
case COL_NAME:
+ if (file->name && file->stat.st_nlink == 0) {
+ char *d = strnrstr(file->name, "(deleted)",
+ sizeof("(deleted)") - 1);
+ if (d) {
+ int r;
+ *d = '\0';
+ r = scols_line_set_data(ln, column_index, file->name);
+ *d = '(';
+ if (r)
+ err(EXIT_FAILURE, _("failed to add output data"));
+ return true;
+ }
+ }
+ /* FALL THROUGH */
+ case COL_KNAME:
if (file->name
&& scols_line_set_data(ln, column_index, file->name))
err(EXIT_FAILURE, _("failed to add output data"));
break;
case COL_XMODE: {
char r, w, x;
+ char D = file->stat.st_nlink == 0? 'D': '-';
if (does_file_has_fdinfo_alike(file)) {
r = file->mode & S_IRUSR? 'r': '-';
w = file->mode & S_IWUSR? 'w': '-';
&& file->mode & S_IXUSR)? 'x': '-';
} else
r = w = x = '-';
- xasprintf(&str, "%c%c%c", r, w, x);
+ xasprintf(&str, "%c%c%c%c", r, w, x, D);
break;
}
case COL_POS:
NAME <``string``>::
Cooked version of KNAME. It is mostly same as KNAME.
+
+____
+Note that `(deleted)` markers are removed from this column.
+Refer to _KNAME_, _DELETED_, or _XMODE_ to know the
+readability of the file from the file system.
+____
+
+
Some files have special formats and information sources:
+
User of the process.
XMODE <``string``>::
-Extended version of _MODE_.
-Currently this column shows the same items as _MODE_.
-However, the column may grow; new letters may be added to
-_XMODE_ when *lsfd* supports a new state of file descriptors
+Extended version of _MODE_. This column may grow; new letters may be
+added to _XMODE_ when *lsfd* supports a new state of file descriptors
and/or memory mappings.
++
+[-r]:::
+opened of mapped for reading. This is also in _MODE_.
++
+[-w]:::
+opened of mapped for writing. This is also in _MODE_.
++
+[-x]:::
+mapped for executing the code. This is also in _MODE_.
++
+[-D]:::
+opened file is deleted from the file system. See also _DELETED._.
== FILTER EXPRESSION