From: Karel Zak Date: Thu, 28 Jun 2012 13:42:06 +0000 (+0200) Subject: findmnt: add TID column X-Git-Tag: v2.22-rc1~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d8f4e0c4ba9b1feed4e0eadd17dd709ad45c838;p=thirdparty%2Futil-linux.git findmnt: add TID column just in case we read from more mountinfo files. For example get mountpoint from the current namespace which is invisible for initd (PID=1): # unsahre -m bash # mount /dev/sdb /mnt/test # echo $$ 30070 # findmnt -n -o TARGET,TID,SOURCE --task 1 --task $$ | \ sort -u --key=1,1 | awk ' ($2 != 1) { print $0 }' /mnt/test 30070 /dev/sdb Signed-off-by: Karel Zak --- diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 1ef812cee0..094734d72d 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -79,6 +79,7 @@ enum { COL_USED, COL_USEPERC, COL_FSROOT, + COL_TID, FINDMNT_NCOLUMNS }; @@ -120,6 +121,7 @@ static struct colinfo infos[FINDMNT_NCOLUMNS] = { [COL_USED] = { "USED", 5, TT_FL_RIGHT, N_("filesystem size used") }, [COL_USEPERC] = { "USE%", 3, TT_FL_RIGHT, N_("filesystem use percentage") }, [COL_FSROOT] = { "FSROOT", 0.25, TT_FL_NOEXTREMES, N_("filesystem root") }, + [COL_TID] = { "TID", 4, TT_FL_RIGHT, N_("task ID") }, }; /* global flags */ @@ -475,6 +477,13 @@ static const char *get_data(struct libmnt_fs *fs, int num) case COL_FSROOT: str = mnt_fs_get_root(fs); break; + case COL_TID: + if (mnt_fs_get_tid(fs)) { + char *tmp; + if (xasprintf(&tmp, "%d", mnt_fs_get_tid(fs)) > 0) + str = tmp; + } + break; default: break; }