Check fakechroot >= 2.9
[libguestfs.git] / ruby / ext / guestfs / _guestfs.c
index 1e87d04..f911750 100644 (file)
@@ -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);
 }