[Pkg-libvirt-commits] [libguestfs] 08/21: labels: move e2label to ext2.c and call it directly

Hilko Bengen bengen at moszumanska.debian.org
Sun Nov 1 17:16:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag upstream/1.29.50
in repository libguestfs.

commit d5a60f21489fd264bbcaa0f17cc7f730d08a0e61
Author: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
Date:   Wed Jul 8 17:34:42 2015 +0800

    labels: move e2label to ext2.c and call it directly
    
    ext2 should not call function in labels
    
    Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 daemon/ext2.c   | 23 +++++++++++++++++------
 daemon/labels.c | 24 +-----------------------
 2 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/daemon/ext2.c b/daemon/ext2.c
index e8d2655..ebaf0f0 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -38,6 +38,7 @@ GUESTFSD_EXT_CMD(str_resize2fs, resize2fs);
 GUESTFSD_EXT_CMD(str_mke2fs, mke2fs);
 GUESTFSD_EXT_CMD(str_lsattr, lsattr);
 GUESTFSD_EXT_CMD(str_chattr, chattr);
+GUESTFSD_EXT_CMD(str_e2label, e2label);
 
 /* https://bugzilla.redhat.com/show_bug.cgi?id=978302#c1 */
 int
@@ -125,12 +126,22 @@ do_tune2fs_l (const char *device)
 int
 do_set_e2label (const char *device, const char *label)
 {
-  const mountable_t mountable = {
-    .type = MOUNTABLE_DEVICE,
-    .device = /* not really ... */ (char *) device,
-    .volume = NULL,
-  };
-  return do_set_label (&mountable, label);
+  int r;
+  CLEANUP_FREE char *err = NULL;
+
+  if (strlen (label) > EXT2_LABEL_MAX) {
+    reply_with_error ("%s: ext2 labels are limited to %d bytes",
+                      label, EXT2_LABEL_MAX);
+    return -1;
+  }
+
+  r = command (NULL, &err, str_e2label, device, label, NULL);
+  if (r == -1) {
+    reply_with_error ("%s", err);
+    return -1;
+  }
+
+  return 0;
 }
 
 char *
diff --git a/daemon/labels.c b/daemon/labels.c
index eec5b96..e3830f9 100644
--- a/daemon/labels.c
+++ b/daemon/labels.c
@@ -28,7 +28,6 @@
 #include "optgroups.h"
 
 GUESTFSD_EXT_CMD(str_dosfslabel, dosfslabel);
-GUESTFSD_EXT_CMD(str_e2label, e2label);
 GUESTFSD_EXT_CMD(str_ntfslabel, ntfslabel);
 GUESTFSD_EXT_CMD(str_xfs_admin, xfs_admin);
 
@@ -48,27 +47,6 @@ dosfslabel (const char *device, const char *label)
 }
 
 static int
-e2label (const char *device, const char *label)
-{
-  int r;
-  CLEANUP_FREE char *err = NULL;
-
-  if (strlen (label) > EXT2_LABEL_MAX) {
-    reply_with_error ("%s: ext2 labels are limited to %d bytes",
-                      label, EXT2_LABEL_MAX);
-    return -1;
-  }
-
-  r = command (NULL, &err, str_e2label, device, label, NULL);
-  if (r == -1) {
-    reply_with_error ("%s", err);
-    return -1;
-  }
-
-  return 0;
-}
-
-static int
 ntfslabel (const char *device, const char *label)
 {
   int r;
@@ -135,7 +113,7 @@ do_set_label (const mountable_t *mountable, const char *label)
     r = dosfslabel (mountable->device, label);
 
   else if (fstype_is_extfs (vfs_type))
-    r = e2label (mountable->device, label);
+    r = do_set_e2label (mountable->device, label);
 
   else if (STREQ (vfs_type, "ntfs"))
     r = ntfslabel (mountable->device, label);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list