From 090b5e84b20e415ac6e00892b2a4606ee064e685 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 19 Apr 2012 14:38:53 +0200 Subject: [PATCH] findmnt: add support for PARTUUID= and PARTLABEL= Signed-off-by: Karel Zak --- misc-utils/findmnt.8 | 32 +++++++++----------------------- misc-utils/findmnt.c | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/misc-utils/findmnt.8 b/misc-utils/findmnt.8 index d5a98b4e2..0c710a80d 100644 --- a/misc-utils/findmnt.8 +++ b/misc-utils/findmnt.8 @@ -64,7 +64,7 @@ The search direction - or .IR backward . .IP "\fB\-e, \-\-evaluate\fP" -Convert all tags (LABEL or UUID) to the device names. +Convert all tags (LABEL, UUID, PARTUUID or PARTLABEL) to the device names. .IP "\fB\-F, \-\-tab\-file \fIpath\fP" Search in an alternative file, if used with \fB\-\-fstab\fP, \fB\-\-mtab\fP or \fB\-\-kernel\fP then overwrites the default paths. @@ -84,9 +84,10 @@ Do not print a header line. Do not truncate text in columns. The default is to not truncate the .BR TARGET , .BR SOURCE , -.BR UUID -and -.BR LABEL +.BR UUID , +.BR LABEL , +.BR PARTUUID , +.BR PARTLABEL columns. This option disables text truncation also in all other columns. .IP "\fB\-O, \-\-options \fIlist\fP" Limit the set of printed filesystems. More than one option @@ -102,24 +103,8 @@ at the beginning does not have global meaning. The "no" could used for individual items in the list. The "no" prefix interpratation could be disabled by "+" prefix. .IP "\fB\-o, \-\-output \fIlist\fP" -Define output columns. Currently supported are -.BR ACTION, -.BR SOURCE , -.BR TARGET , -.BR OLD-TARGET, -.BR FSTYPE , -.BR OPTIONS , -.BR OLD-OPTIONS, -.BR VFS-OPTIONS , -.BR FS-OPTIONS , -.BR SIZE , -.BR AVAIL , -.BR USED , -.BR USE% , -.BR LABEL -and -.BR UUID . -The +Define output columns. See the \fB\-\-help\fP output to get list of the +currently supported columns. The .BR TARGET column contains tree formatting if the .B \-\-list @@ -169,7 +154,8 @@ defined by options \fB\-t\fP, \fB\-O\fP, \fB\-S\fP, \fB\-T\fP and printed in tree-like order. The option enables the tree-like output format by default. This option has no effect for \fB\-\-mtab\fP or \fB\-\-fstab\fP. .IP "\fB\-S, \-\-source \fIspec\fP" -Explicitly define the mount source. Supported are \fIdevice\fR, \fILABEL=\fR and \fIUUID=\fR. +Explicitly define the mount source. Supported are \fIdevice\fR, \fILABEL=\fR, +\fIUUID=\fR, \fIPARTLABEL=\fR or \fIPARTUUID=\fR. .IP "\fB\-T, \-\-target \fIdir\fP" Explicitly define the mount target (mountpoint directory). .IP "\fB\-w, \-\-timeout \fImilliseconds\fP" diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 172f38915..cf69c429b 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -67,6 +67,8 @@ enum { COL_FS_OPTIONS, COL_LABEL, COL_UUID, + COL_PARTLABEL, + COL_PARTUUID, COL_MAJMIN, COL_ACTION, COL_OLD_TARGET, @@ -104,6 +106,8 @@ static struct colinfo infos[FINDMNT_NCOLUMNS] = { [COL_FS_OPTIONS] = { "FS-OPTIONS", 0.10, TT_FL_TRUNC, N_("FS specific mount options") }, [COL_LABEL] = { "LABEL", 0.10, 0, N_("filesystem label") }, [COL_UUID] = { "UUID", 36, 0, N_("filesystem UUID") }, + [COL_PARTLABEL] = { "PARTLABEL", 0.10, 0, N_("partition label") }, + [COL_PARTUUID] = { "PARTUUID", 36, 0, N_("partition UUID") }, [COL_MAJMIN] = { "MAJ:MIN", 6, 0, N_("major:minor device number") }, [COL_ACTION] = { "ACTION", 10, TT_FL_STRICTWIDTH, N_("action detected by --poll") }, [COL_OLD_OPTIONS] = { "OLD-OPTIONS", 0.10, TT_FL_TRUNC, N_("old mount options saved by --poll") }, @@ -378,9 +382,16 @@ static const char *get_data(struct libmnt_fs *fs, int num) case COL_UUID: str = get_tag(fs, "UUID"); break; + case COL_PARTUUID: + str = get_tag(fs, "PARTUUID"); + break; case COL_LABEL: str = get_tag(fs, "LABEL"); break; + case COL_PARTLABEL: + str = get_tag(fs, "PARTLABEL"); + break; + case COL_MAJMIN: { dev_t devno = mnt_fs_get_devno(fs); @@ -902,7 +913,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) " -c, --canonicalize canonicalize printed paths\n" " -D, --df imitate the output of df(1)\n" " -d, --direction direction of search, 'forward' or 'backward'\n" - " -e, --evaluate convert tags (LABEL/UUID) to device names\n" + " -e, --evaluate convert tags (LABEL/UUID,PARTUUID,PARTLABEL) to device names\n" " -F, --tab-file alternative file for --fstab, --mtab or --kernel options\n" " -f, --first-only print the first found filesystem only\n")); @@ -920,7 +931,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, _( " -v, --nofsroot don't print [/dir] for bind or btrfs mounts\n" " -R, --submounts print all submounts for the matching filesystems\n" - " -S, --source the device to mount (by name, LABEL= or UUID=)\n" + " -S, --source the device to mount (by name, LABEL=, UUID=, PARTUUID=, ...)\n" " -T, --target the mountpoint to use\n")); fputs(USAGE_SEPARATOR, out); @@ -1184,7 +1195,8 @@ int main(int argc, char *argv[]) */ const char *x = get_match(COL_SOURCE); - if (!strncmp(x, "LABEL=", 6) || !strncmp(x, "UUID=", 5)) + if (!strncmp(x, "LABEL=", 6) || !strncmp(x, "UUID=", 5) || + !strncmp(x, "PARTLABEL=", 10) || !strncmp(x, "PARTUUID=", 9)) flags |= FL_NOSWAPMATCH; }