X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=ruby%2Fext%2Fguestfs%2F_guestfs.c;h=f911750629a052fa87fcfeffabb418bf97a3aeac;hb=65f77271f290eca1d8b91d16fc6e123037f86229;hp=e6c42365e586c33c126824c8f4cde02d1937554e;hpb=ab0397017cc26833c09946cca19d86b907822a94;p=libguestfs.git diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index e6c4236..f911750 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -2515,6 +2515,77 @@ static VALUE ruby_guestfs_get_e2uuid (VALUE gv, VALUE devicev) return rv; } +static VALUE ruby_guestfs_fsck (VALUE gv, VALUE fstypev, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "fsck"); + + const char *fstype = StringValueCStr (fstypev); + if (!fstype) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "fstype", "fsck"); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "fsck"); + + int r; + + r = guestfs_fsck (g, fstype, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_zero (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", "zero"); + + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "zero"); + + int r; + + r = guestfs_zero (g, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + 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 () { @@ -2733,4 +2804,10 @@ void Init__guestfs () ruby_guestfs_set_e2uuid, 2); rb_define_method (c_guestfs, "get_e2uuid", ruby_guestfs_get_e2uuid, 1); + rb_define_method (c_guestfs, "fsck", + 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); }