From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Borzenkov Date: Sun, 21 Jan 2007 18:55:10 +0000 Subject: [PATCH] Add option to vol_id to print raw partition label Message-Id: <200701212155.19657.arvidjaar@mail.ru> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============0275368654==" List-Id: To: linux-hotplug@vger.kernel.org --===============0275368654== Content-Type: multipart/signed; boundary="nextPart1679374.nyiLDax8hJ"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1679374.nyiLDax8hJ Content-Type: multipart/mixed; boundary="Boundary-01=_Sc7sFQJ88CEntLY" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_Sc7sFQJ88CEntLY Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline vol_id is apparently the only portable (and sometimes simply the only) way = to=20 get partition label (and UUID). This patch adds option to print raw label a= s=20 opposed to safe one. I found myself needing raw label in quite a few cases= =20 recently (adding support for LABEL=3D mounts and swaps to various places) a= nd=20 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=3Dfilesystem ID_FS_TYPE=3Dreiserfs ID_FS_VERSION=3D3.6 ID_FS_UUID=3D72973377-c299-4ca6-ae94-2022b7dca58f ID_FS_LABEL=3D/ ID_FS_LABEL_SAFE=3D Notice that safe label is empty. The manual page follows if patch is acceptable. Regards =2Dandrey --Boundary-01=_Sc7sFQJ88CEntLY Content-Type: text/x-diff; charset="us-ascii"; name="vol_id-L.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="vol_id-L.patch" Subject: [PATCH] Add option to vol_id to print raw partition label =46rom: Andrey Borzenkov This adds option -L to vol_id that prints raw label as opposed to =2Dl 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 =2D-- 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 =2D-- 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 =3D PRINT_EXPORT; struct volume_id *vid =3D NULL; static char name[VOLUME_ID_LABEL_SIZE]; @@ -153,6 +155,8 @@ int main(int argc, char *argv[]) print =3D PRINT_LABEL; } else if (strcmp(arg, "-u") =3D=3D 0) { print =3D PRINT_UUID; + } else if (strcmp(arg, "-L") =3D=3D 0) { + print =3D PRINT_RAW_LABEL; } else if (strcmp(arg, "--skip-raid") =3D=3D 0) { skip_raid =3D 1; } else if (strcmp(arg, "--probe-all") =3D=3D 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] =3D=3D '\0' || vid->usage_id =3D=3D VOLUME_ID_RAID) { + rc =3D 3; + goto exit; + } + printf("%s\n", vid->label); + break; } =20 exit: --Boundary-01=_Sc7sFQJ88CEntLY-- --nextPart1679374.nyiLDax8hJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQBFs7cXR6LMutpd94wRAlb3AJ9WN1VPp3O86+CSo9GP50+3wNKkBwCfYMyp PiqGlJXmS0M2rQCkwpmnHqo= =nY8Q -----END PGP SIGNATURE----- --nextPart1679374.nyiLDax8hJ-- --===============0275368654== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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 --===============0275368654== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============0275368654==--