[Libguestfs] [PATCH 1/2] ext2: tweak the error returned message of resize2fs-M(BZ755729)

Wanlong Gao gaowanlong at cn.fujitsu.com
Fri Jan 13 06:27:49 UTC 2012


Tweak the error message "e2fsck -f" and "e2fsck -fy" to
"e2fsck-f" and "e2fsck-fy".

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 daemon/ext2.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/daemon/ext2.c b/daemon/ext2.c
index 79fd354..9fe938e 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -277,9 +277,25 @@ do_resize2fs_M (const char *device)
   if (e2prog (prog) == -1)
     return -1;
 
-  r = command (NULL, &err, prog, "-M" , device, NULL);
+  r = command (NULL, &err, prog, "-M", device, NULL);
   if (r == -1) {
-    reply_with_error ("%s", err);
+    int i = 0;
+    int len = strlen (err);
+    char *err_wrap = malloc (len + 1);
+    if (!err_wrap)
+      goto err_out;
+    char *p = strstr (err, "e2fsck -f");
+    if (p) {
+      strncpy (err_wrap, err, p - err);
+      err_wrap[p - err] = '\0';
+      sprintf(err_wrap + (p - err), "%s%s", "e2fsck-f", p + 9);
+      reply_with_error ("%s", err_wrap);
+    } else {
+      reply_with_error ("%s", err);
+    }
+
+    free (err_wrap);
+err_out:
     free (err);
     return -1;
   }
-- 
1.7.8




More information about the Libguestfs mailing list