Add a new api e2fsck-fy for resize2fs.
Sometimes e2fsck-f is not enough.
If resiz2fs return the message says: " Please use e2fsck-fy first",
we just haven't such a command, it's so awkward.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/ext2.c | 21 +++++++++++++++++++++
generator/generator_actions.ml | 15 +++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/daemon/ext2.c b/daemon/ext2.c
index 9fe938e..4f3710d 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -333,6 +333,27 @@ do_e2fsck_f (const char *device)
}
int
+do_e2fsck_fy (const char *device)
+{
+ char *err;
+ int r;
+
+ char prog[] = "e2fsck";
+ if (e2prog (prog) == -1)
+ return -1;
+
+ r = commandr (NULL, &err, prog, "-f", "-y", device, NULL);
+ if (r == -1 || r >= 2) {
+ reply_with_error ("%s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;
+}
+
+int
do_mke2journal (int blocksize, const char *device)
{
char *err;
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index fb82bb6..fc3193a 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -3454,6 +3454,7 @@ are activated or deactivated.");
["umount"; "/"];
["lvresize"; "/dev/VG/LV"; "20"];
["e2fsck_f"; "/dev/VG/LV"];
+ ["e2fsck_fy"; "/dev/VG/LV"];
["resize2fs"; "/dev/VG/LV"];
["mount_options"; ""; "/dev/VG/LV"; "/"];
["cat"; "/new"]], "test content");
@@ -6597,6 +6598,20 @@ The usage of this device, for example C<filesystem> or
C<raid>.
=back");
+ ("e2fsck_fy", (RErr, [Device "device"], []), 304, [],
+ [], (* lvresize tests this *)
+ "check an ext2/ext3 filesystem",
+ "\
+This force to check the filesystem even it appears to be clean,
+and assume an answer of 'yes' to all questions, allows e2fsck
+to be used no-interactively.
+
+This command is only needed when C<guestfs_e2fsck_f> even can't do
+things for C<guestfs_resize2fs> (q.v.). Normally you should use
+C<guestfs_fsck>.
+
+When using this, you should know clearly what are you doing now.");
+
]
let all_functions = non_daemon_functions @ daemon_functions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 8160622..873b744 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-303
+304
--
1.7.8