diff options
author | Karel Zak | 2012-06-28 13:51:34 +0200 |
---|---|---|
committer | Karel Zak | 2012-06-28 13:51:34 +0200 |
commit | c7fcc8307d46c37f8cd67b2ef903d305e8b257c0 (patch) | |
tree | 6cb558589b0e940b1f0c05e5d72da3c11c0228b5 /misc-utils/findmnt.c | |
parent | findmnt: don't use tree-like output if more -F options specified (diff) | |
download | kernel-qcow2-util-linux-c7fcc8307d46c37f8cd67b2ef903d305e8b257c0.tar.gz kernel-qcow2-util-linux-c7fcc8307d46c37f8cd67b2ef903d305e8b257c0.tar.xz kernel-qcow2-util-linux-c7fcc8307d46c37f8cd67b2ef903d305e8b257c0.zip |
findmnt: add --task <tid> option
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/findmnt.c')
-rw-r--r-- | misc-utils/findmnt.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 75f7eb761..1ef812cee 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -629,6 +629,14 @@ static char **append_tabfile(char **files, int *nfiles, char *filename) return files; } +static char **append_pid_tabfile(char **files, int *nfiles, pid_t pid) +{ + char *path = NULL; + + xasprintf(&path, "/proc/%d/mountinfo", (int) pid); + return append_tabfile(files, nfiles, path); +} + /* calls libmount fstab/mtab/mountinfo parser */ static struct libmnt_table *parse_tabfiles(char **files, int nfiles, @@ -987,6 +995,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, _( " -i, --invert invert the sense of matching\n" " -l, --list use list format output\n" + " -N, --task <tid> use alternative namespace (/proc/<tid>/mountinfo file)\n" " -n, --noheadings don't print column headings\n" " -u, --notruncate don't truncate text in columns\n")); fprintf(out, _( @@ -1030,12 +1039,14 @@ int main(int argc, char *argv[]) EXCL_FSTAB, EXCL_KERNEL, EXCL_MTAB, + EXCL_TASK, EXCL_RAW, EXCL_LIST, EXCL_PAIRS }; int excl_fmk = EXCL_NONE; + int excl_fmN = EXCL_NONE; int excl_rlP = EXCL_NONE; /* table.h */ @@ -1067,6 +1078,7 @@ int main(int argc, char *argv[]) { "submounts", 0, 0, 'R' }, { "source", 1, 0, 'S' }, { "tab-file", 1, 0, 'F' }, + { "task", 1, 0, 'N' }, { "target", 1, 0, 'T' }, { "timeout", 1, 0, 'w' }, { "version", 0, 0, 'V' }, @@ -1085,7 +1097,7 @@ int main(int argc, char *argv[]) tt_flags |= TT_FL_TREE; while ((c = getopt_long(argc, argv, - "AacDd:ehifF:o:O:p::Pklmnrst:uvRS:T:w:V", + "AacDd:ehifF:o:O:p::PklmnN:rst:uvRS:T:w:V", longopts, NULL)) != -1) { switch(c) { case 'A': @@ -1156,11 +1168,13 @@ int main(int argc, char *argv[]) break; case 'm': /* mtab */ exclusive_option(&excl_fmk, EXCL_MTAB, "--{fstab,mtab,kernel}"); + exclusive_option(&excl_fmN, EXCL_MTAB, "--{fstab,mtab,task}"); tabtype = TABTYPE_MTAB; tt_flags &= ~TT_FL_TREE; break; case 's': /* fstab */ exclusive_option(&excl_fmk, EXCL_FSTAB, "--{fstab,mtab,kernel}"); + exclusive_option(&excl_fmN, EXCL_FSTAB, "--{fstab,mtab,task}"); tabtype = TABTYPE_FSTAB; tt_flags &= ~TT_FL_TREE; break; @@ -1183,6 +1197,13 @@ int main(int argc, char *argv[]) case 'n': tt_flags |= TT_FL_NOHEADINGS; break; + case 'N': + exclusive_option(&excl_fmN, EXCL_KERNEL, "--{fstab,mtab,task}"); + tabtype = TABTYPE_KERNEL; + tabfiles = append_pid_tabfile(tabfiles, &ntabfiles, + strtou32_or_err(optarg, + _("invalid TID argument"))); + break; case 'v': flags |= FL_NOFSROOT; break; |