Skip to contentSkip to conversation

Add option to vol_id to print raw partition label

PATCH Applied Andrey Borzenkov 2 participants 2 messages Jan 21, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add option to vol_id to print raw partition label

vol_id is apparently the only portable (and sometimes simply the only) way to get partition label (and UUID). This patch adds option to print raw label as opposed to safe one. I found myself needing raw label in quite a few cases recently (adding support for LABEL= mounts and swaps to various places) and eval'ing vol_id -x is a bit clumsy.

To illustrate what I mean:

{pts/1}% sudo vol_id -x /dev/sda2
ID_FS_USAGE=filesystem
ID_FS_TYPE=reiserfs
ID_FS_VERSION=3.6
ID_FS_UUID=72973377-c299-4ca6-ae94-2022b7dca58f
ID_FS_LABEL=/
ID_FS_LABEL_SAFE=

Notice that safe label is empty.

The manual page follows if patch is acceptable.

Regards

-andrey

Subject: [PATCH] Add option to vol_id to print raw partition label

From: Andrey Borzenkov <[email protected]>

This adds option -L to vol_id that prints raw label as opposed to -l that prints safe version (that may be reduced to empty one). This provides convinient and portable way to get label of partition.

---

 extras/volume_id/vol_id.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
extras/volume_id/vol_id.c +11 -0
index 0a1b756..73843ef 100644
@@ -116,6 +116,7 @@ int main(int argc, char *argv[])
 			    "  -t             filesystem type\n"
 			    "  -l             filesystem label\n"
 			    "  -u             filesystem uuid\n"
+			    "  -L             raw label\n"
 			    " --skip-raid     don't probe for raid\n"
 			    " --probe-all     find possibly conflicting signatures\n"
 			    " --help\n"
@@ -125,6 +126,7 @@ int main(int argc, char *argv[])
 		PRINT_TYPE,
 		PRINT_LABEL,
 		PRINT_UUID,
+		PRINT_RAW_LABEL,
 	} print = PRINT_EXPORT;
 	struct volume_id *vid = NULL;
 	static char name[VOLUME_ID_LABEL_SIZE];
@@ -153,6 +155,8 @@ int main(int argc, char *argv[])
 			print = PRINT_LABEL;
 		} else if (strcmp(arg, "-u") == 0) {
 			print = PRINT_UUID;
+		} else if (strcmp(arg, "-L") == 0) {
+			print = PRINT_RAW_LABEL;
 		} else if (strcmp(arg, "--skip-raid") == 0) {
 			skip_raid = 1;
 		} else if (strcmp(arg, "--probe-all") == 0) {
@@ -306,6 +310,13 @@ int main(int argc, char *argv[])
 		}
 		printf("%s\n", vid->uuid);
 		break;
+	case PRINT_RAW_LABEL:
+		if (vid->label[0] == '\0' || vid->usage_id == VOLUME_ID_RAID) {
+			rc = 3;
+			goto exit;
+		}
+		printf("%s\n", vid->label);
+		break;
 	}
 
 exit:

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

Applied
#1 lore raw
Quoted 3 lines · Andrey Borzenkov

vol_id is apparently the only portable (and sometimes simply the only) way to get partition label (and UUID). This patch adds option to print raw label as opposed to safe one.

Applied.

Thanks,
Kay

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel