[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v2 3/3] e2fsck-f: change the internal to use e2fsck



From: Wanlong Gao <gaowanlong cn fujitsu com>

Since we implement the new api e2fsck, just change the
internal of e2fsck_f to use e2fsck now.
v1->v2: use optargs_bitmask

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

diff --git a/daemon/ext2.c b/daemon/ext2.c
index 5a0ac9f..802d7c3 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -327,26 +327,6 @@ do_e2fsck (const char *device,
   ADD_ARG (argv, i, NULL);
 
   r = commandv (NULL, &err, argv);
-  if (r == -1 || r >= 2) {
-    reply_with_error ("%s", err);
-    free (err);
-    return -1;
-  }
-
-  free (err);
-  return 0;
-}
-
-int
-do_e2fsck_f (const char *device)
-{
-  char *err;
-  int r;
-
-  char prog[] = "e2fsck";
-  if (e2prog (prog) == -1)
-    return -1;
-
   /* 0 = no errors, 1 = errors corrected.
    *
    * >= 4 means uncorrected or other errors.
@@ -354,7 +334,6 @@ do_e2fsck_f (const char *device)
    * 2, 3 means errors were corrected and we require a reboot.  This is
    * a difficult corner case.
    */
-  r = commandr (NULL, &err, prog, "-p", "-f", device, NULL);
   if (r == -1 || r >= 2) {
     reply_with_error ("%s", err);
     free (err);
@@ -366,6 +345,13 @@ do_e2fsck_f (const char *device)
 }
 
 int
+do_e2fsck_f (const char *device)
+{
+  optargs_bitmask = GUESTFS_E2FSCK_CORRECT_BITMASK;
+  return do_e2fsck (device, 1, 0);
+}
+
+int
 do_mke2journal (int blocksize, const char *device)
 {
   char *err;
-- 
1.7.8


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]