summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--daemon/ext2.c19
-rwxr-xr-xsrc/generator.ml20
2 files changed, 38 insertions, 1 deletions
diff --git a/daemon/ext2.c b/daemon/ext2.c
index 639ae5dd..ab03528f 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -253,3 +253,22 @@ do_resize2fs (const char *device)
free (err);
return 0;
}
+
+int
+do_e2fsck_f (const char *device)
+{
+ char *err;
+ int r;
+
+ IS_DEVICE (device, -1);
+
+ r = command (NULL, &err, "/sbin/e2fsck", "-p", "-f", device, NULL);
+ if (r == -1) {
+ reply_with_error ("e2fsck: %s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;
+}
diff --git a/src/generator.ml b/src/generator.ml
index 5eb61223..d2451f02 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -2114,6 +2114,7 @@ are activated or deactivated.");
["write_file"; "/new"; "test content"; "0"];
["umount"; "/"];
["lvresize"; "/dev/VG/LV"; "20"];
+ ["e2fsck_f"; "/dev/VG/LV"];
["resize2fs"; "/dev/VG/LV"];
["mount"; "/dev/VG/LV"; "/"];
["cat"; "/new"]], "test content")],
@@ -2128,7 +2129,13 @@ is lost.");
"resize an ext2/ext3 filesystem",
"\
This resizes an ext2 or ext3 filesystem to match the size of
-the underlying device.");
+the underlying device.
+
+I<Note:> It is sometimes required that you run C<guestfs_e2fsck_f>
+on the C<device> before calling this command. For unknown reasons
+C<resize2fs> sometimes gives an error about this and sometimes not.
+In any case, it is always safe to call C<guestfs_e2fsck_f> before
+calling this function.");
("find", (RStringList "names", [String "directory"]), 107, [],
[InitBasicFS, Always, TestOutputList (
@@ -2169,6 +2176,17 @@ an error.
The returned list is sorted.");
+ ("e2fsck_f", (RErr, [String "device"]), 108, [],
+ [], (* lvresize tests this *)
+ "check an ext2/ext3 filesystem",
+ "\
+This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
+filesystem checker on C<device>, noninteractively (C<-p>),
+even if the filesystem appears to be clean (C<-f>).
+
+This command is only needed because of C<guestfs_resize2fs>
+(q.v.). Normally you should use C<guestfs_fsck>.");
+
]
let all_functions = non_daemon_functions @ daemon_functions