Generated code for e2fsck-f command.
authorRichard Jones <rjones@redhat.com>
Thu, 21 May 2009 15:18:16 +0000 (16:18 +0100)
committerRichard Jones <rjones@redhat.com>
Thu, 21 May 2009 15:18:16 +0000 (16:18 +0100)
23 files changed:
daemon/actions.h
daemon/stubs.c
fish/cmds.c
fish/completion.c
guestfish-actions.pod
guestfs-actions.pod
haskell/Guestfs.hs
java/com/redhat/et/libguestfs/GuestFS.java
java/com_redhat_et_libguestfs_GuestFS.c
ocaml/guestfs.ml
ocaml/guestfs.mli
ocaml/guestfs_c_actions.c
perl/Guestfs.xs
perl/lib/Sys/Guestfs.pm
python/guestfs-py.c
python/guestfs.py
ruby/ext/guestfs/_guestfs.c
src/guestfs-actions.c
src/guestfs-actions.h
src/guestfs_protocol.c
src/guestfs_protocol.h
src/guestfs_protocol.x
tests.c

index 8aed57c..1615cfb 100644 (file)
@@ -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_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);
index 2df8bba..51a7562 100644 (file)
@@ -2695,6 +2695,30 @@ done:
   xdr_free ((xdrproc_t) xdr_guestfs_find_args, (char *) &args);
 }
 
   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) {
 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_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);
   }
     default:
       reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
   }
index 0f5b65d..d200acf 100644 (file)
@@ -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", "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");
   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 ("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
   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);
 }
 
     display_builtin_command (cmd);
 }
 
@@ -2662,6 +2666,20 @@ static int run_find (const char *cmd, int argc, char *argv[])
   return 0;
 }
 
   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)
 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, "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;
     {
       fprintf (stderr, "%s: unknown command\n", cmd);
       return -1;
index d0e8050..ec58296 100644 (file)
@@ -76,6 +76,7 @@ static const char *const commands[] = {
   "dmesg",
   "download",
   "drop-caches",
   "dmesg",
   "download",
   "drop-caches",
+  "e2fsck-f",
   "equal",
   "exists",
   "file",
   "equal",
   "exists",
   "file",
index ee8e824..fa82ef1 100644 (file)
@@ -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.
 
 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
 =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.
 
 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
 =head2 rm
 
  rm path
index 0d5efb4..0b06470 100644 (file)
@@ -624,6 +624,20 @@ so that the maximum guest memory is freed.
 
 This function returns 0 on success or -1 on error.
 
 
 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);
 =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.
 
 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
 This function returns 0 on success or -1 on error.
 
 =head2 guestfs_rm
index 8f90ee8..ee7dabd 100644 (file)
@@ -81,7 +81,8 @@ module Guestfs (
   ping_daemon,
   zerofree,
   pvresize,
   ping_daemon,
   zerofree,
   pvresize,
-  resize2fs
+  resize2fs,
+  e2fsck_f
   ) where
 import Foreign
 import Foreign.C
   ) where
 import Foreign
 import Foreign.C
@@ -827,3 +828,15 @@ resize2fs h device = do
       fail err
     else return ()
 
       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 ()
+
index f4cec79..6e2304e 100644 (file)
@@ -2939,6 +2939,13 @@ public class GuestFS {
    * This resizes an ext2 or ext3 filesystem to match the
    * size of the underlying device.
    * 
    * 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)
    * @throws LibGuestFSException
    */
   public void resize2fs (String device)
@@ -2992,4 +2999,26 @@ public class GuestFS {
   private native String[] _find (long g, String directory)
     throws LibGuestFSException;
 
   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;
+
 }
 }
index 1e7f9de..dea916e 100644 (file)
@@ -2963,3 +2963,20 @@ Java_com_redhat_et_libguestfs_GuestFS__1find
   return jr;
 }
 
   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 ;
+  }
+}
+
index 0fe2d82..48dae20 100644 (file)
@@ -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 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"
index f758552..e115a79 100644 (file)
@@ -517,3 +517,6 @@ val resize2fs : t -> string -> unit
 val find : t -> string -> string array
 (** find all files and directories *)
 
 val find : t -> string -> string array
 (** find all files and directories *)
 
+val e2fsck_f : t -> string -> unit
+(** check an ext2/ext3 filesystem *)
+
index 0dcaf3f..795a0f3 100644 (file)
@@ -3452,3 +3452,26 @@ ocaml_guestfs_find (value gv, value directoryv)
   CAMLreturn (rv);
 }
 
   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);
+}
+
index 0cc124c..66eeb29 100644 (file)
@@ -1936,3 +1936,14 @@ PREINIT:
       }
       free (names);
 
       }
       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));
+
index e7f8924..cba0032 100644 (file)
@@ -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.
 
 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
 =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.
 
 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>.
 =item $h->rm ($path);
 
 Remove the single file C<path>.
index bb64104..4461462 100644 (file)
@@ -3688,6 +3688,31 @@ py_guestfs_find (PyObject *self, PyObject *args)
   return py_r;
 }
 
   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 },
 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 *) "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 }
 };
 
   { NULL, NULL, 0, NULL }
 };
 
index 237e62d..a82c8cb 100644 (file)
@@ -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.
     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)
 
         """
         return libguestfsmod.resize2fs (self._o, device)
 
@@ -1467,3 +1474,13 @@ class GuestFS:
         """
         return libguestfsmod.find (self._o, directory)
 
         """
         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)
+
index 2deda5d..8b554bb 100644 (file)
@@ -3144,6 +3144,27 @@ static VALUE ruby_guestfs_find (VALUE gv, VALUE directoryv)
   return rv;
 }
 
   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 ()
 {
 /* 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);
         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);
 }
 }
index 0f603d6..dfca204 100644 (file)
@@ -9806,3 +9806,90 @@ char **guestfs_find (guestfs_h *g,
   return ctx.ret.names.names_val;
 }
 
   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;
+}
+
index 76472e8..b51071b 100644 (file)
@@ -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_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);
index c2e96da..2838d95 100644 (file)
@@ -1829,6 +1829,16 @@ xdr_guestfs_find_ret (XDR *xdrs, guestfs_find_ret *objp)
 }
 
 bool_t
 }
 
 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;
 xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
 {
        register int32_t *buf;
index aef554b..dd5da00 100644 (file)
@@ -925,6 +925,11 @@ struct guestfs_find_ret {
 };
 typedef struct guestfs_find_ret 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,
 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_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
 };
 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_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*);
 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_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 ();
 extern bool_t xdr_guestfs_procedure ();
 extern bool_t xdr_guestfs_message_direction ();
 extern bool_t xdr_guestfs_message_status ();
index 6c1f84e..b2baab5 100644 (file)
@@ -715,6 +715,10 @@ struct guestfs_find_ret {
   str names<>;
 };
 
   str names<>;
 };
 
+struct guestfs_e2fsck_f_args {
+  string device<>;
+};
+
 enum guestfs_procedure {
   GUESTFS_PROC_MOUNT = 1,
   GUESTFS_PROC_SYNC = 2,
 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_LVRESIZE = 105,
   GUESTFS_PROC_RESIZE2FS = 106,
   GUESTFS_PROC_FIND = 107,
+  GUESTFS_PROC_E2FSCK_F = 108,
   GUESTFS_PROC_NR_PROCS
 };
 
   GUESTFS_PROC_NR_PROCS
 };
 
diff --git a/tests.c b/tests.c
index 547575c..5997952 100644 (file)
--- 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_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)
 }
 
 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;
     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;
     r = guestfs_resize2fs (g, device);
     if (r == -1)
       return -1;