mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone
Blob Blame History Raw
From 59652f2426cccdb04ec1ac63df8928d16816ad3b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 29 Aug 2013 11:37:06 +0100
Subject: [PATCH] virt-make-fs: Add --label option for setting filesystem
 label.

$ ./run ./tools/virt-make-fs /tmp/supermin-4.1.4.tar.gz /tmp/test.img
$ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h
Name      Type        VFS   Label  MBR  Size  Parent
/dev/sda  filesystem  ext2  -      -    3.7M  -
/dev/sda  device      -     -      -    3.7M  -

$ ./run ./tools/virt-make-fs /tmp/supermin-4.1.4.tar.gz /tmp/test.img --label=BOOT
$ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h
Name      Type        VFS   Label  MBR  Size  Parent
/dev/sda  filesystem  ext2  BOOT   -    3.7M  -
/dev/sda  device      -     -      -    3.7M  -

Thanks: Gerd Hoffmann (kraxel)
(cherry picked from commit e17cd73fb7e3d7ce5e28f51c8451033f48a39153)
---
 tools/virt-make-fs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/virt-make-fs b/tools/virt-make-fs
index d29e7df..7d94b92 100755
--- a/tools/virt-make-fs
+++ b/tools/virt-make-fs
@@ -251,6 +251,14 @@ here.
 
 =cut
 
+my $label;
+
+=item B<--label=E<lt>LABELE<gt>>
+
+Set the filesystem label.
+
+=cut
+
 my $partition;
 
 =item B<--partition>
@@ -292,6 +300,7 @@ GetOptions ("help|?" => \$help,
             "s|size=s" => \$size,
             "F|format=s" => \$format,
             "t|type=s" => \$type,
+            "label=s" => \$label,
             "partition:s" => \$partition,
     ) or pod2usage (2);
 pod2usage (1) if $help;
@@ -509,6 +518,11 @@ eval {
         $g->mkfs_btrfs ([$dev], datatype => "single", metadata => "single");
     }
 
+    # Set label.
+    if (defined $label) {
+        $g->set_label ($dev, $label);
+    }
+
     # Mount it.
 
     # For vfat, add the utf8 mount option because we want to be able
-- 
1.8.3.1