]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findmnt: add TID column
authorKarel Zak <kzak@redhat.com>
Thu, 28 Jun 2012 13:42:06 +0000 (15:42 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 28 Jun 2012 13:46:38 +0000 (15:46 +0200)
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 <kzak@redhat.com>
misc-utils/findmnt.c

index 1ef812cee0319baf4eeacd30f11062ed1035aa18..094734d72d75f4ba1c789af0fc757a58e9b8ae73 100644 (file)
@@ -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;
        }