linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@mail.ru>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] Add option to vol_id to print raw partition label
Date: Sun, 21 Jan 2007 18:55:10 +0000	[thread overview]
Message-ID: <200701212155.19657.arvidjaar@mail.ru> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 674 bytes --]

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

[-- Attachment #1.1.2: vol_id-L.patch --]
[-- Type: text/x-diff, Size: 1874 bytes --]

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

From: Andrey Borzenkov <arvidjaar@mail.ru>

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.

Signed-off-by: Andrey Borzenkov <arvidjaar@mail.ru>

---

 extras/volume_id/vol_id.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c
index 0a1b756..73843ef 100644
--- a/extras/volume_id/vol_id.c
+++ b/extras/volume_id/vol_id.c
@@ -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:

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
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

[-- Attachment #3: Type: text/plain, Size: 226 bytes --]

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

             reply	other threads:[~2007-01-21 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-21 18:55 Andrey Borzenkov [this message]
2007-01-21 21:54 ` [PATCH] Add option to vol_id to print raw partition label Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200701212155.19657.arvidjaar@mail.ru \
    --to=arvidjaar@mail.ru \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).