summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-05-21 16:18:16 +0100
committerRichard Jones <rjones@redhat.com>2009-05-21 16:18:16 +0100
commit3e408f493496597dc026d20778837f421f05a9dd (patch)
tree5aee1850ae052c36ab56de764d4130789280c7a8
parent0f81d0941a2705d49bc129f69924265fa60d9677 (diff)
downloadlibguestfs-3e408f493496597dc026d20778837f421f05a9dd.tar.gz
libguestfs-3e408f493496597dc026d20778837f421f05a9dd.tar.xz
libguestfs-3e408f493496597dc026d20778837f421f05a9dd.zip
Generated code for e2fsck-f command.
-rw-r--r--daemon/actions.h1
-rw-r--r--daemon/stubs.c27
-rw-r--r--fish/cmds.c23
-rw-r--r--fish/completion.c1
-rw-r--r--guestfish-actions.pod17
-rw-r--r--guestfs-actions.pod20
-rw-r--r--haskell/Guestfs.hs15
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java29
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c17
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c23
-rw-r--r--perl/Guestfs.xs11
-rw-r--r--perl/lib/Sys/Guestfs.pm15
-rw-r--r--python/guestfs-py.c26
-rw-r--r--python/guestfs.py17
-rw-r--r--ruby/ext/guestfs/_guestfs.c23
-rw-r--r--src/guestfs-actions.c87
-rw-r--r--src/guestfs-actions.h1
-rw-r--r--src/guestfs_protocol.c10
-rw-r--r--src/guestfs_protocol.h10
-rw-r--r--src/guestfs_protocol.x5
-rw-r--r--tests.c9
23 files changed, 388 insertions, 3 deletions
diff --git a/daemon/actions.h b/daemon/actions.h
index 8aed57c1..1615cfb1 100644
--- a/daemon/actions.h
+++ b/daemon/actions.h
@@ -128,3 +128,4 @@ extern int do_vg_activate (int activate, char * const* const volgroups);
extern int do_lvresize (const char *device, int mbytes);
extern int do_resize2fs (const char *device);
extern char **do_find (const char *directory);
+extern int do_e2fsck_f (const char *device);
diff --git a/daemon/stubs.c b/daemon/stubs.c
index 2df8bbac..51a75624 100644
--- a/daemon/stubs.c
+++ b/daemon/stubs.c
@@ -2695,6 +2695,30 @@ done:
xdr_free ((xdrproc_t) xdr_guestfs_find_args, (char *) &args);
}
+static void e2fsck_f_stub (XDR *xdr_in)
+{
+ int r;
+ struct guestfs_e2fsck_f_args args;
+ const char *device;
+
+ memset (&args, 0, sizeof args);
+
+ if (!xdr_guestfs_e2fsck_f_args (xdr_in, &args)) {
+ reply_with_error ("%s: daemon failed to decode procedure arguments", "e2fsck_f");
+ return;
+ }
+ device = args.device;
+
+ r = do_e2fsck_f (device);
+ if (r == -1)
+ /* do_e2fsck_f has already called reply_with_error */
+ goto done;
+
+ reply (NULL, NULL);
+done:
+ xdr_free ((xdrproc_t) xdr_guestfs_e2fsck_f_args, (char *) &args);
+}
+
void dispatch_incoming_message (XDR *xdr_in)
{
switch (proc_nr) {
@@ -3019,6 +3043,9 @@ void dispatch_incoming_message (XDR *xdr_in)
case GUESTFS_PROC_FIND:
find_stub (xdr_in);
break;
+ case GUESTFS_PROC_E2FSCK_F:
+ e2fsck_f_stub (xdr_in);
+ break;
default:
reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
}
diff --git a/fish/cmds.c b/fish/cmds.c
index 0f5b65df..d200acfa 100644
--- a/fish/cmds.c
+++ b/fish/cmds.c
@@ -69,6 +69,7 @@ void list_commands (void)
printf ("%-20s %s\n", "dmesg", "return kernel messages");
printf ("%-20s %s\n", "download", "download a file to the local machine");
printf ("%-20s %s\n", "drop-caches", "drop kernel page cache, dentries and inodes");
+ printf ("%-20s %s\n", "e2fsck-f", "check an ext2/ext3 filesystem");
printf ("%-20s %s\n", "equal", "test if two files have equal contents");
printf ("%-20s %s\n", "exists", "test if file or directory exists");
printf ("%-20s %s\n", "file", "determine file type");
@@ -539,11 +540,14 @@ void display_command (const char *cmd)
pod2text ("lvresize - resize an LVM logical volume", " lvresize <device> <mbytes>\n\nThis resizes (expands or shrinks) an existing LVM logical\nvolume to C<mbytes>. When reducing, data in the reduced part\nis lost.");
else
if (strcasecmp (cmd, "resize2fs") == 0)
- pod2text ("resize2fs - resize an ext2/ext3 filesystem", " resize2fs <device>\n\nThis resizes an ext2 or ext3 filesystem to match the size of\nthe underlying device.");
+ pod2text ("resize2fs - resize an ext2/ext3 filesystem", " resize2fs <device>\n\nThis resizes an ext2 or ext3 filesystem to match the size of\nthe underlying device.\n\nI<Note:> It is sometimes required that you run C<e2fsck_f>\non the C<device> before calling this command. For unknown reasons\nC<resize2fs> sometimes gives an error about this and sometimes not.\nIn any case, it is always safe to call C<e2fsck_f> before\ncalling this function.");
else
if (strcasecmp (cmd, "find") == 0)
pod2text ("find - find all files and directories", " find <directory>\n\nThis command lists out all files and directories, recursively,\nstarting at C<directory>. It is essentially equivalent to\nrunning the shell command C<find directory -print> but some\npost-processing happens on the output, described below.\n\nThis returns a list of strings I<without any prefix>. Thus\nif the directory structure was:\n\n /tmp/a\n /tmp/b\n /tmp/c/d\n\nthen the returned list from C<find> C</tmp> would be\n4 elements:\n\n a\n b\n c\n c/d\n\nIf C<directory> is not a directory, then this command returns\nan error.\n\nThe returned list is sorted.");
else
+ if (strcasecmp (cmd, "e2fsck_f") == 0 || strcasecmp (cmd, "e2fsck-f") == 0)
+ pod2text ("e2fsck-f - check an ext2/ext3 filesystem", " e2fsck-f <device>\n\nThis runs C<e2fsck -p -f device>, ie. runs the ext2/ext3\nfilesystem checker on C<device>, noninteractively (C<-p>),\neven if the filesystem appears to be clean (C<-f>).\n\nThis command is only needed because of C<resize2fs>\n(q.v.). Normally you should use C<fsck>.");
+ else
display_builtin_command (cmd);
}
@@ -2662,6 +2666,20 @@ static int run_find (const char *cmd, int argc, char *argv[])
return 0;
}
+static int run_e2fsck_f (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ device = argv[0];
+ r = guestfs_e2fsck_f (g, device);
+ return r;
+}
+
int run_action (const char *cmd, int argc, char *argv[])
{
if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
@@ -3045,6 +3063,9 @@ int run_action (const char *cmd, int argc, char *argv[])
if (strcasecmp (cmd, "find") == 0)
return run_find (cmd, argc, argv);
else
+ if (strcasecmp (cmd, "e2fsck_f") == 0 || strcasecmp (cmd, "e2fsck-f") == 0)
+ return run_e2fsck_f (cmd, argc, argv);
+ else
{
fprintf (stderr, "%s: unknown command\n", cmd);
return -1;
diff --git a/fish/completion.c b/fish/completion.c
index d0e8050a..ec582963 100644
--- a/fish/completion.c
+++ b/fish/completion.c
@@ -76,6 +76,7 @@ static const char *const commands[] = {
"dmesg",
"download",
"drop-caches",
+ "e2fsck-f",
"equal",
"exists",
"file",
diff --git a/guestfish-actions.pod b/guestfish-actions.pod
index ee8e8247..fa82ef1b 100644
--- a/guestfish-actions.pod
+++ b/guestfish-actions.pod
@@ -484,6 +484,17 @@ Setting C<whattodrop> to 3 should drop everything.
This automatically calls L<sync(2)> before the operation,
so that the maximum guest memory is freed.
+=head2 e2fsck-f
+
+ e2fsck-f device
+
+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<resize2fs>
+(q.v.). Normally you should use C<fsck>.
+
=head2 equal
equal file1 file2
@@ -989,6 +1000,12 @@ function which has a more complex interface.
This resizes an ext2 or ext3 filesystem to match the size of
the underlying device.
+I<Note:> It is sometimes required that you run C<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<e2fsck-f> before
+calling this function.
+
=head2 rm
rm path
diff --git a/guestfs-actions.pod b/guestfs-actions.pod
index 0d5efb4d..0b06470d 100644
--- a/guestfs-actions.pod
+++ b/guestfs-actions.pod
@@ -624,6 +624,20 @@ so that the maximum guest memory is freed.
This function returns 0 on success or -1 on error.
+=head2 guestfs_e2fsck_f
+
+ int guestfs_e2fsck_f (guestfs_h *handle,
+ const char *device);
+
+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>.
+
+This function returns 0 on success or -1 on error.
+
=head2 guestfs_end_busy
int guestfs_end_busy (guestfs_h *handle);
@@ -1319,6 +1333,12 @@ I<The caller must free the strings and the array after use>.
This resizes an ext2 or ext3 filesystem to match the size of
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.
+
This function returns 0 on success or -1 on error.
=head2 guestfs_rm
diff --git a/haskell/Guestfs.hs b/haskell/Guestfs.hs
index 8f90ee8c..ee7dabd1 100644
--- a/haskell/Guestfs.hs
+++ b/haskell/Guestfs.hs
@@ -81,7 +81,8 @@ module Guestfs (
ping_daemon,
zerofree,
pvresize,
- resize2fs
+ resize2fs,
+ e2fsck_f
) where
import Foreign
import Foreign.C
@@ -827,3 +828,15 @@ resize2fs h device = do
fail err
else return ()
+foreign import ccall unsafe "guestfs_e2fsck_f" c_e2fsck_f
+ :: GuestfsP -> CString -> IO (CInt)
+
+e2fsck_f :: GuestfsH -> String -> IO ()
+e2fsck_f h device = do
+ r <- withCString device $ \device -> withForeignPtr h (\p -> c_e2fsck_f p device)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index f4cec79c..6e2304e6 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -2939,6 +2939,13 @@ public class GuestFS {
* This resizes an ext2 or ext3 filesystem to match the
* size of the underlying device.
*
+ * *Note:* It is sometimes required that you run
+ * "g.e2fsck_f" on the "device" before calling this
+ * command. For unknown reasons "resize2fs" sometimes gives
+ * an error about this and sometimes not. In any case, it
+ * is always safe to call "g.e2fsck_f" before calling this
+ * function.
+ *
* @throws LibGuestFSException
*/
public void resize2fs (String device)
@@ -2992,4 +2999,26 @@ public class GuestFS {
private native String[] _find (long g, String directory)
throws LibGuestFSException;
+ /**
+ * check an ext2/ext3 filesystem
+ *
+ * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
+ * filesystem checker on "device", noninteractively ("-p"),
+ * even if the filesystem appears to be clean ("-f").
+ *
+ * This command is only needed because of "g.resize2fs"
+ * (q.v.). Normally you should use "g.fsck".
+ *
+ * @throws LibGuestFSException
+ */
+ public void e2fsck_f (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("e2fsck_f: handle is closed");
+ _e2fsck_f (g, device);
+ }
+ private native void _e2fsck_f (long g, String device)
+ throws LibGuestFSException;
+
}
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index 1e7f9de5..dea916e9 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -2963,3 +2963,20 @@ Java_com_redhat_et_libguestfs_GuestFS__1find
return jr;
}
+JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1e2fsck_1f
+ (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ const char *device;
+
+ device = (*env)->GetStringUTFChars (env, jdevice, NULL);
+ r = guestfs_e2fsck_f (g, device);
+ (*env)->ReleaseStringUTFChars (env, jdevice, device);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 0fe2d821..48dae203 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -246,3 +246,4 @@ external vg_activate : t -> bool -> string array -> unit = "ocaml_guestfs_vg_act
external lvresize : t -> string -> int -> unit = "ocaml_guestfs_lvresize"
external resize2fs : t -> string -> unit = "ocaml_guestfs_resize2fs"
external find : t -> string -> string array = "ocaml_guestfs_find"
+external e2fsck_f : t -> string -> unit = "ocaml_guestfs_e2fsck_f"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index f7585527..e115a793 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -517,3 +517,6 @@ val resize2fs : t -> string -> unit
val find : t -> string -> string array
(** find all files and directories *)
+val e2fsck_f : t -> string -> unit
+(** check an ext2/ext3 filesystem *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 0dcaf3f3..795a0f36 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -3452,3 +3452,26 @@ ocaml_guestfs_find (value gv, value directoryv)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_e2fsck_f (value gv, value devicev)
+{
+ CAMLparam2 (gv, devicev);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("e2fsck_f: used handle after closing it");
+
+ const char *device = String_val (devicev);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_e2fsck_f (g, device);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "e2fsck_f");
+
+ rv = Val_unit;
+ CAMLreturn (rv);
+}
+
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index 0cc124ce..66eeb294 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -1936,3 +1936,14 @@ PREINIT:
}
free (names);
+void
+e2fsck_f (g, device)
+ guestfs_h *g;
+ char *device;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_e2fsck_f (g, device);
+ if (r == -1)
+ croak ("e2fsck_f: %s", guestfs_last_error (g));
+
diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm
index e7f89248..cba00325 100644
--- a/perl/lib/Sys/Guestfs.pm
+++ b/perl/lib/Sys/Guestfs.pm
@@ -499,6 +499,15 @@ Setting C<whattodrop> to 3 should drop everything.
This automatically calls L<sync(2)> before the operation,
so that the maximum guest memory is freed.
+=item $h->e2fsck_f ($device);
+
+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<$h-E<gt>resize2fs>
+(q.v.). Normally you should use C<$h-E<gt>fsck>.
+
=item $h->end_busy ();
This sets the state to C<READY>, or if in C<CONFIG> then it leaves the
@@ -910,6 +919,12 @@ function which has a more complex interface.
This resizes an ext2 or ext3 filesystem to match the size of
the underlying device.
+I<Note:> It is sometimes required that you run C<$h-E<gt>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<$h-E<gt>e2fsck_f> before
+calling this function.
+
=item $h->rm ($path);
Remove the single file C<path>.
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index bb641043..44614620 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -3688,6 +3688,31 @@ py_guestfs_find (PyObject *self, PyObject *args)
return py_r;
}
+static PyObject *
+py_guestfs_e2fsck_f (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ const char *device;
+
+ if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_e2fsck_f",
+ &py_g, &device))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_e2fsck_f (g, device);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ Py_INCREF (Py_None);
+ py_r = Py_None;
+ return py_r;
+}
+
static PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -3822,6 +3847,7 @@ static PyMethodDef methods[] = {
{ (char *) "lvresize", py_guestfs_lvresize, METH_VARARGS, NULL },
{ (char *) "resize2fs", py_guestfs_resize2fs, METH_VARARGS, NULL },
{ (char *) "find", py_guestfs_find, METH_VARARGS, NULL },
+ { (char *) "e2fsck_f", py_guestfs_e2fsck_f, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
diff --git a/python/guestfs.py b/python/guestfs.py
index 237e62d4..a82c8cba 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -1433,6 +1433,13 @@ class GuestFS:
def resize2fs (self, device):
u"""This resizes an ext2 or ext3 filesystem to match the
size of the underlying device.
+
+ *Note:* It is sometimes required that you run
+ "g.e2fsck_f" on the "device" before calling this
+ command. For unknown reasons "resize2fs" sometimes gives
+ an error about this and sometimes not. In any case, it
+ is always safe to call "g.e2fsck_f" before calling this
+ function.
"""
return libguestfsmod.resize2fs (self._o, device)
@@ -1467,3 +1474,13 @@ class GuestFS:
"""
return libguestfsmod.find (self._o, directory)
+ def e2fsck_f (self, device):
+ u"""This runs "e2fsck -p -f device", ie. runs the ext2/ext3
+ filesystem checker on "device", noninteractively ("-p"),
+ even if the filesystem appears to be clean ("-f").
+
+ This command is only needed because of "g.resize2fs"
+ (q.v.). Normally you should use "g.fsck".
+ """
+ return libguestfsmod.e2fsck_f (self._o, device)
+
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index 2deda5d4..8b554bbe 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -3144,6 +3144,27 @@ static VALUE ruby_guestfs_find (VALUE gv, VALUE directoryv)
return rv;
}
+static VALUE ruby_guestfs_e2fsck_f (VALUE gv, VALUE devicev)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "e2fsck_f");
+
+ const char *device = StringValueCStr (devicev);
+ if (!device)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "device", "e2fsck_f");
+
+ int r;
+
+ r = guestfs_e2fsck_f (g, device);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
@@ -3416,4 +3437,6 @@ void Init__guestfs ()
ruby_guestfs_resize2fs, 1);
rb_define_method (c_guestfs, "find",
ruby_guestfs_find, 1);
+ rb_define_method (c_guestfs, "e2fsck_f",
+ ruby_guestfs_e2fsck_f, 1);
}
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
index 0f603d62..dfca2048 100644
--- a/src/guestfs-actions.c
+++ b/src/guestfs-actions.c
@@ -9806,3 +9806,90 @@ char **guestfs_find (guestfs_h *g,
return ctx.ret.names.names_val;
}
+struct e2fsck_f_ctx {
+ /* This flag is set by the callbacks, so we know we've done
+ * the callbacks as expected, and in the right sequence.
+ * 0 = not called, 1 = reply_cb called.
+ */
+ int cb_sequence;
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+};
+
+static void e2fsck_f_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct e2fsck_f_ctx *ctx = (struct e2fsck_f_ctx *) data;
+
+ /* This should definitely not happen. */
+ if (ctx->cb_sequence != 0) {
+ ctx->cb_sequence = 9999;
+ error (g, "%s: internal error: reply callback called twice", "guestfs_e2fsck_f");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_e2fsck_f");
+ return;
+ }
+ if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+ error (g, "%s: failed to parse reply error", "guestfs_e2fsck_f");
+ return;
+ }
+ goto done;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_e2fsck_f (guestfs_h *g,
+ const char *device)
+{
+ struct guestfs_e2fsck_f_args args;
+ struct e2fsck_f_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_e2fsck_f") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.device = (char *) device;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_E2FSCK_F,
+ (xdrproc_t) xdr_guestfs_e2fsck_f_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, e2fsck_f_reply_cb, &ctx);
+ (void) ml->main_loop_run (ml, g);
+ guestfs_set_reply_callback (g, NULL, NULL);
+ if (ctx.cb_sequence != 1) {
+ error (g, "%s reply failed, see earlier error messages", "guestfs_e2fsck_f");
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_E2FSCK_F, serial) == -1) {
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ free (ctx.err.error_message);
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ guestfs_end_busy (g);
+ return 0;
+}
+
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
index 76472e8f..b51071ba 100644
--- a/src/guestfs-actions.h
+++ b/src/guestfs-actions.h
@@ -150,3 +150,4 @@ extern int guestfs_vg_activate (guestfs_h *handle, int activate, char * const* c
extern int guestfs_lvresize (guestfs_h *handle, const char *device, int mbytes);
extern int guestfs_resize2fs (guestfs_h *handle, const char *device);
extern char **guestfs_find (guestfs_h *handle, const char *directory);
+extern int guestfs_e2fsck_f (guestfs_h *handle, const char *device);
diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c
index c2e96da3..2838d95c 100644
--- a/src/guestfs_protocol.c
+++ b/src/guestfs_protocol.c
@@ -1829,6 +1829,16 @@ xdr_guestfs_find_ret (XDR *xdrs, guestfs_find_ret *objp)
}
bool_t
+xdr_guestfs_e2fsck_f_args (XDR *xdrs, guestfs_e2fsck_f_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_string (xdrs, &objp->device, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
{
register int32_t *buf;
diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h
index aef554bf..dd5da006 100644
--- a/src/guestfs_protocol.h
+++ b/src/guestfs_protocol.h
@@ -925,6 +925,11 @@ struct guestfs_find_ret {
};
typedef struct guestfs_find_ret guestfs_find_ret;
+struct guestfs_e2fsck_f_args {
+ char *device;
+};
+typedef struct guestfs_e2fsck_f_args guestfs_e2fsck_f_args;
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -1033,7 +1038,8 @@ enum guestfs_procedure {
GUESTFS_PROC_LVRESIZE = 105,
GUESTFS_PROC_RESIZE2FS = 106,
GUESTFS_PROC_FIND = 107,
- GUESTFS_PROC_NR_PROCS = 107 + 1,
+ GUESTFS_PROC_E2FSCK_F = 108,
+ GUESTFS_PROC_NR_PROCS = 108 + 1,
};
typedef enum guestfs_procedure guestfs_procedure;
#define GUESTFS_MESSAGE_MAX 4194304
@@ -1230,6 +1236,7 @@ extern bool_t xdr_guestfs_lvresize_args (XDR *, guestfs_lvresize_args*);
extern bool_t xdr_guestfs_resize2fs_args (XDR *, guestfs_resize2fs_args*);
extern bool_t xdr_guestfs_find_args (XDR *, guestfs_find_args*);
extern bool_t xdr_guestfs_find_ret (XDR *, guestfs_find_ret*);
+extern bool_t xdr_guestfs_e2fsck_f_args (XDR *, guestfs_e2fsck_f_args*);
extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
@@ -1385,6 +1392,7 @@ extern bool_t xdr_guestfs_lvresize_args ();
extern bool_t xdr_guestfs_resize2fs_args ();
extern bool_t xdr_guestfs_find_args ();
extern bool_t xdr_guestfs_find_ret ();
+extern bool_t xdr_guestfs_e2fsck_f_args ();
extern bool_t xdr_guestfs_procedure ();
extern bool_t xdr_guestfs_message_direction ();
extern bool_t xdr_guestfs_message_status ();
diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x
index 6c1f84e7..b2baab52 100644
--- a/src/guestfs_protocol.x
+++ b/src/guestfs_protocol.x
@@ -715,6 +715,10 @@ struct guestfs_find_ret {
str names<>;
};
+struct guestfs_e2fsck_f_args {
+ string device<>;
+};
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -823,6 +827,7 @@ enum guestfs_procedure {
GUESTFS_PROC_LVRESIZE = 105,
GUESTFS_PROC_RESIZE2FS = 106,
GUESTFS_PROC_FIND = 107,
+ GUESTFS_PROC_E2FSCK_F = 108,
GUESTFS_PROC_NR_PROCS
};
diff --git a/tests.c b/tests.c
index 547575cd..59979526 100644
--- a/tests.c
+++ b/tests.c
@@ -124,6 +124,7 @@ static void no_test_warnings (void)
fprintf (stderr, "warning: \"guestfs_vg_activate_all\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_vg_activate\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_resize2fs\" has no tests\n");
+ fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
}
static int test_find_0 (void)
@@ -614,6 +615,14 @@ static int test_lvresize_0 (void)
char device[] = "/dev/VG/LV";
int r;
suppress_error = 0;
+ r = guestfs_e2fsck_f (g, device);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char device[] = "/dev/VG/LV";
+ int r;
+ suppress_error = 0;
r = guestfs_resize2fs (g, device);
if (r == -1)
return -1;