From e118c14b9552de311cbc1734e03a3226b484c1e8 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 30 Apr 2009 23:10:22 +0100 Subject: [PATCH] Generated code for grub-install command. --- daemon/actions.h | 1 + daemon/stubs.c | 29 ++++++++++ fish/cmds.c | 23 ++++++++ fish/completion.c | 1 + guestfish-actions.pod | 7 +++ guestfs-actions.pod | 11 ++++ java/com/redhat/et/libguestfs/GuestFS.java | 19 +++++++ java/com_redhat_et_libguestfs_GuestFS.c | 20 +++++++ ocaml/guestfs.ml | 1 + ocaml/guestfs.mli | 3 + ocaml/guestfs_c_actions.c | 24 ++++++++ perl/Guestfs.xs | 12 ++++ perl/lib/Sys/Guestfs.pm | 5 ++ python/guestfs-py.c | 27 +++++++++ python/guestfs.py | 7 +++ ruby/ext/guestfs/_guestfs.c | 27 +++++++++ src/guestfs-actions.c | 88 ++++++++++++++++++++++++++++++ src/guestfs-actions.h | 1 + src/guestfs_protocol.c | 12 ++++ src/guestfs_protocol.h | 11 +++- src/guestfs_protocol.x | 6 ++ tests.c | 72 +++++++++++++++++++++++- 22 files changed, 405 insertions(+), 2 deletions(-) diff --git a/daemon/actions.h b/daemon/actions.h index 501e337..5e2fb41 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -106,3 +106,4 @@ extern int do_set_e2uuid (const char *device, const char *uuid); extern char *do_get_e2uuid (const char *device); extern int do_fsck (const char *fstype, const char *device); extern int do_zero (const char *device); +extern int do_grub_install (const char *root, const char *device); diff --git a/daemon/stubs.c b/daemon/stubs.c index 937913f..ee27997 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -2127,6 +2127,32 @@ done: xdr_free ((xdrproc_t) xdr_guestfs_zero_args, (char *) &args); } +static void grub_install_stub (XDR *xdr_in) +{ + int r; + struct guestfs_grub_install_args args; + const char *root; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_grub_install_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "grub_install"); + return; + } + root = args.root; + device = args.device; + + r = do_grub_install (root, device); + if (r == -1) + /* do_grub_install has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args); +} + void dispatch_incoming_message (XDR *xdr_in) { switch (proc_nr) { @@ -2385,6 +2411,9 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_ZERO: zero_stub (xdr_in); break; + case GUESTFS_PROC_GRUB_INSTALL: + grub_install_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 142b595..8506044 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -75,6 +75,7 @@ void list_commands (void) printf ("%-20s %s\n", "get-qemu", "get the qemu binary"); printf ("%-20s %s\n", "get-state", "get the current state"); printf ("%-20s %s\n", "get-verbose", "get verbose mode"); + printf ("%-20s %s\n", "grub-install", "install GRUB"); printf ("%-20s %s\n", "is-busy", "is busy processing a command"); printf ("%-20s %s\n", "is-config", "is in configuration state"); printf ("%-20s %s\n", "is-dir", "test if file exists"); @@ -448,6 +449,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "zero") == 0) pod2text ("zero - write zeroes to the device", " zero \n\nThis command writes zeroes over the first few blocks of C.\n\nHow many blocks are zeroed isn't specified (but it's I enough\nto securely wipe the device). It should be sufficient to remove\nany partition tables, filesystem superblocks and so on."); else + if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0) + pod2text ("grub-install - install GRUB", " grub-install \n\nThis command installs GRUB (the Grand Unified Bootloader) on\nC, with the root directory being C."); + else display_builtin_command (cmd); } @@ -2182,6 +2186,22 @@ static int run_zero (const char *cmd, int argc, char *argv[]) return r; } +static int run_grub_install (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *root; + const char *device; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + root = argv[0]; + device = argv[1]; + r = guestfs_grub_install (g, root, device); + return r; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -2493,6 +2513,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "zero") == 0) return run_zero (cmd, argc, argv); else + if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0) + return run_grub_install (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/fish/completion.c b/fish/completion.c index cc9991f..665abd2 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -81,6 +81,7 @@ static const char *const commands[] = { "get-qemu", "get-state", "get-verbose", + "grub-install", "is-busy", "is-config", "is-dir", diff --git a/guestfish-actions.pod b/guestfish-actions.pod index 44d86f2..74242e3 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -534,6 +534,13 @@ For more information on states, see L. This returns the verbose messages flag. +=head2 grub-install + + grub-install root device + +This command installs GRUB (the Grand Unified Bootloader) on +C, with the root directory being C. + =head2 is-busy is-busy diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 6fc51f0..a05436c 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -691,6 +691,17 @@ This returns the verbose messages flag. This function returns a C truth value on success or -1 on error. +=head2 guestfs_grub_install + + int guestfs_grub_install (guestfs_h *handle, + const char *root, + const char *device); + +This command installs GRUB (the Grand Unified Bootloader) on +C, with the root directory being C. + +This function returns 0 on success or -1 on error. + =head2 guestfs_is_busy int guestfs_is_busy (guestfs_h *handle); diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index 5b81623..dc414d6 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -2414,4 +2414,23 @@ public class GuestFS { private native void _zero (long g, String device) throws LibGuestFSException; + /** + * install GRUB + * + * This command installs GRUB (the Grand Unified + * Bootloader) on "device", with the root directory being + * "root". + * + * @throws LibGuestFSException + */ + public void grub_install (String root, String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("grub_install: handle is closed"); + _grub_install (g, root, device); + } + private native void _grub_install (long g, String root, String device) + throws LibGuestFSException; + } diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c index 466ced8..d70f88a 100644 --- a/java/com_redhat_et_libguestfs_GuestFS.c +++ b/java/com_redhat_et_libguestfs_GuestFS.c @@ -2437,3 +2437,23 @@ Java_com_redhat_et_libguestfs_GuestFS__1zero } } +JNIEXPORT void JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1grub_1install + (JNIEnv *env, jobject obj, jlong jg, jstring jroot, jstring jdevice) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *root; + const char *device; + + root = (*env)->GetStringUTFChars (env, jroot, NULL); + device = (*env)->GetStringUTFChars (env, jdevice, NULL); + r = guestfs_grub_install (g, root, device); + (*env)->ReleaseStringUTFChars (env, jroot, root); + (*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 0d60bcc..b61931e 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -221,3 +221,4 @@ external set_e2uuid : t -> string -> string -> unit = "ocaml_guestfs_set_e2uuid" external get_e2uuid : t -> string -> string = "ocaml_guestfs_get_e2uuid" external fsck : t -> string -> string -> int = "ocaml_guestfs_fsck" external zero : t -> string -> unit = "ocaml_guestfs_zero" +external grub_install : t -> string -> string -> unit = "ocaml_guestfs_grub_install" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 259c8f3..c8b6795 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -442,3 +442,6 @@ val fsck : t -> string -> string -> int val zero : t -> string -> unit (** write zeroes to the device *) +val grub_install : t -> string -> string -> unit +(** install GRUB *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 458d7a7..0656e72 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -2846,3 +2846,27 @@ ocaml_guestfs_zero (value gv, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_grub_install (value gv, value rootv, value devicev) +{ + CAMLparam3 (gv, rootv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("grub_install: used handle after closing it"); + + const char *root = String_val (rootv); + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_grub_install (g, root, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "grub_install"); + + rv = Val_unit; + CAMLreturn (rv); +} + diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index 651e7a2..f19b9d0 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -1599,3 +1599,15 @@ PREINIT: if (r == -1) croak ("zero: %s", guestfs_last_error (g)); +void +grub_install (g, root, device) + guestfs_h *g; + char *root; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_grub_install (g, root, device); + if (r == -1) + croak ("grub_install: %s", guestfs_last_error (g)); + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index bab7887..3f00394 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -537,6 +537,11 @@ For more information on states, see L. This returns the verbose messages flag. +=item $h->grub_install ($root, $device); + +This command installs GRUB (the Grand Unified Bootloader) on +C, with the root directory being C. + =item $busy = $h->is_busy (); This returns true iff this handle is busy processing a command diff --git a/python/guestfs-py.c b/python/guestfs-py.c index a1cfb09..5afcee3 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -3052,6 +3052,32 @@ py_guestfs_zero (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_grub_install (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *root; + const char *device; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_grub_install", + &py_g, &root, &device)) + return NULL; + g = get_handle (py_g); + + r = guestfs_grub_install (g, root, 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 }, @@ -3161,6 +3187,7 @@ static PyMethodDef methods[] = { { (char *) "get_e2uuid", py_guestfs_get_e2uuid, METH_VARARGS, NULL }, { (char *) "fsck", py_guestfs_fsck, METH_VARARGS, NULL }, { (char *) "zero", py_guestfs_zero, METH_VARARGS, NULL }, + { (char *) "grub_install", py_guestfs_grub_install, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 022150b..4a23cdb 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -1183,3 +1183,10 @@ class GuestFS: """ return libguestfsmod.zero (self._o, device) + def grub_install (self, root, device): + u"""This command installs GRUB (the Grand Unified + Bootloader) on "device", with the root directory being + "root". + """ + return libguestfsmod.grub_install (self._o, root, device) + diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 1e87d04..f911750 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -2561,6 +2561,31 @@ static VALUE ruby_guestfs_zero (VALUE gv, VALUE devicev) return Qnil; } +static VALUE ruby_guestfs_grub_install (VALUE gv, VALUE rootv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "grub_install"); + + const char *root = StringValueCStr (rootv); + if (!root) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "root", "grub_install"); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "grub_install"); + + int r; + + r = guestfs_grub_install (g, root, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + /* Initialize the module. */ void Init__guestfs () { @@ -2783,4 +2808,6 @@ void Init__guestfs () ruby_guestfs_fsck, 2); rb_define_method (c_guestfs, "zero", ruby_guestfs_zero, 1); + rb_define_method (c_guestfs, "grub_install", + ruby_guestfs_grub_install, 2); } diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c index e2da1c3..c20301b 100644 --- a/src/guestfs-actions.c +++ b/src/guestfs-actions.c @@ -7728,3 +7728,91 @@ int guestfs_zero (guestfs_h *g, return 0; } +struct grub_install_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 grub_install_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct grub_install_ctx *ctx = (struct grub_install_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_grub_install"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_grub_install"); + 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_grub_install"); + return; + } + goto done; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_grub_install (guestfs_h *g, + const char *root, + const char *device) +{ + struct guestfs_grub_install_args args; + struct grub_install_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_grub_install") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.root = (char *) root; + args.device = (char *) device; + serial = guestfs__send_sync (g, GUESTFS_PROC_GRUB_INSTALL, + (xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args); + if (serial == -1) { + guestfs_set_ready (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, grub_install_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_grub_install"); + guestfs_set_ready (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GRUB_INSTALL, serial) == -1) { + guestfs_set_ready (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + guestfs_set_ready (g); + return -1; + } + + guestfs_set_ready (g); + return 0; +} + diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index 0fc62a1..843968c 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -125,3 +125,4 @@ extern int guestfs_set_e2uuid (guestfs_h *handle, const char *device, const char extern char *guestfs_get_e2uuid (guestfs_h *handle, const char *device); extern int guestfs_fsck (guestfs_h *handle, const char *fstype, const char *device); extern int guestfs_zero (guestfs_h *handle, const char *device); +extern int guestfs_grub_install (guestfs_h *handle, const char *root, const char *device); diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c index b12133a..2f08afd 100644 --- a/src/guestfs_protocol.c +++ b/src/guestfs_protocol.c @@ -1460,6 +1460,18 @@ xdr_guestfs_zero_args (XDR *xdrs, guestfs_zero_args *objp) } bool_t +xdr_guestfs_grub_install_args (XDR *xdrs, guestfs_grub_install_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->root, ~0)) + return FALSE; + 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 2e79669..69ae268 100644 --- a/src/guestfs_protocol.h +++ b/src/guestfs_protocol.h @@ -755,6 +755,12 @@ struct guestfs_zero_args { }; typedef struct guestfs_zero_args guestfs_zero_args; +struct guestfs_grub_install_args { + char *root; + char *device; +}; +typedef struct guestfs_grub_install_args guestfs_grub_install_args; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -841,7 +847,8 @@ enum guestfs_procedure { GUESTFS_PROC_GET_E2UUID = 83, GUESTFS_PROC_FSCK = 84, GUESTFS_PROC_ZERO = 85, - GUESTFS_PROC_NR_PROCS = 85 + 1, + GUESTFS_PROC_GRUB_INSTALL = 86, + GUESTFS_PROC_NR_PROCS = 86 + 1, }; typedef enum guestfs_procedure guestfs_procedure; #define GUESTFS_MESSAGE_MAX 4194304 @@ -1009,6 +1016,7 @@ extern bool_t xdr_guestfs_get_e2uuid_ret (XDR *, guestfs_get_e2uuid_ret*); extern bool_t xdr_guestfs_fsck_args (XDR *, guestfs_fsck_args*); extern bool_t xdr_guestfs_fsck_ret (XDR *, guestfs_fsck_ret*); extern bool_t xdr_guestfs_zero_args (XDR *, guestfs_zero_args*); +extern bool_t xdr_guestfs_grub_install_args (XDR *, guestfs_grub_install_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*); @@ -1135,6 +1143,7 @@ extern bool_t xdr_guestfs_get_e2uuid_ret (); extern bool_t xdr_guestfs_fsck_args (); extern bool_t xdr_guestfs_fsck_ret (); extern bool_t xdr_guestfs_zero_args (); +extern bool_t xdr_guestfs_grub_install_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 c940bf4..8183330 100644 --- a/src/guestfs_protocol.x +++ b/src/guestfs_protocol.x @@ -586,6 +586,11 @@ struct guestfs_zero_args { string device<>; }; +struct guestfs_grub_install_args { + string root<>; + string device<>; +}; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -672,6 +677,7 @@ enum guestfs_procedure { GUESTFS_PROC_GET_E2UUID = 83, GUESTFS_PROC_FSCK = 84, GUESTFS_PROC_ZERO = 85, + GUESTFS_PROC_GRUB_INSTALL = 86, GUESTFS_PROC_NR_PROCS }; diff --git a/tests.c b/tests.c index 5cf8ddc..49c62df 100644 --- a/tests.c +++ b/tests.c @@ -112,6 +112,70 @@ static void no_test_warnings (void) fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n"); } +static int test_grub_install_0 (void) +{ + /* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */ + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char *lines[] = { + ",", + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mkfs (g, "ext2", "/dev/sda1"); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mount (g, "/dev/sda1", "/"); + if (r == -1) + return -1; + } + /* TestOutputTrue for grub_install (0) */ + { + int r; + suppress_error = 0; + r = guestfs_grub_install (g, "/", "/dev/sda1"); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_is_dir (g, "/boot"); + if (r == -1) + return -1; + if (!r) { + fprintf (stderr, "test_grub_install_0: expected true, got false\n"); + return -1; + } + } + return 0; +} + static int test_zero_0 (void) { /* InitBasicFS for zero (0): create ext2 on /dev/sda1 */ @@ -6720,9 +6784,15 @@ int main (int argc, char *argv[]) exit (1); } - nr_tests = 94; + nr_tests = 95; test_num++; + printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests); + if (test_grub_install_0 () == -1) { + printf ("test_grub_install_0 FAILED\n"); + failed++; + } + test_num++; printf ("%3d/%3d test_zero_0\n", test_num, nr_tests); if (test_zero_0 () == -1) { printf ("test_zero_0 FAILED\n"); -- 1.8.3.1