[Libguestfs] [PATCH 3/4] New APIs: vfs-label and vfs-uuid return label and uuid for many fs types.
Richard W.M. Jones
rjones at redhat.com
Tue Jun 1 14:37:46 UTC 2010
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From 27b730a6820b80a49a4da1af9f4c8e8a952f735e Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Tue, 1 Jun 2010 13:57:12 +0100
Subject: [PATCH 3/4] New APIs: vfs-label and vfs-uuid return label and uuid for many fs types.
These APIs generalize the existing 'get-e2label' and 'get-e2uuid'
calls, to provide calls which should be able to get the label
and UUID for most filesystem types. These use 'blkid' to do the
work.
I have tested that the blkid commands themselves work on RHEL 5.
(Suggested by Yufang Zhang).
---
daemon/blkid.c | 12 ++++++++++++
src/MAX_PROC_NR | 2 +-
src/generator.ml | 23 +++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/daemon/blkid.c b/daemon/blkid.c
index a619730..108eee6 100644
--- a/daemon/blkid.c
+++ b/daemon/blkid.c
@@ -64,3 +64,15 @@ do_vfs_type (const char *device)
{
return get_blkid_tag (device, "TYPE");
}
+
+char *
+do_vfs_label (const char *device)
+{
+ return get_blkid_tag (device, "LABEL");
+}
+
+char *
+do_vfs_uuid (const char *device)
+{
+ return get_blkid_tag (device, "UUID");
+}
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 2197544..f1aaa90 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-252
+254
diff --git a/src/generator.ml b/src/generator.ml
index 58eaee4..85a867e 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -4754,6 +4754,29 @@ Do not confuse this with the guestfish-specific
C<alloc> and C<sparse> commands which create
a file in the host and attach it as a device.");
+ ("vfs_label", (RString "label", [Device "device"]), 253, [],
+ [InitBasicFS, Always, TestOutput (
+ [["set_e2label"; "/dev/sda1"; "LTEST"];
+ ["vfs_label"; "/dev/sda1"]], "LTEST")],
+ "get the filesystem label",
+ "\
+This returns the filesystem label of the filesystem on
+C<device>.
+
+If the filesystem is unlabeled, this returns the empty string.");
+
+ ("vfs_uuid", (RString "uuid", [Device "device"]), 254, [],
+ (let uuid = uuidgen () in
+ [InitBasicFS, Always, TestOutput (
+ [["set_e2uuid"; "/dev/sda1"; uuid];
+ ["vfs_uuid"; "/dev/sda1"]], uuid)]),
+ "get the filesystem UUID",
+ "\
+This returns the filesystem UUID of the filesystem on
+C<device>.
+
+If the filesystem does not have a UUID, this returns the empty string.");
+
]
let all_functions = non_daemon_functions @ daemon_functions
--
1.6.6.1
More information about the Libguestfs
mailing list