summaryrefslogtreecommitdiffstats
path: root/ruby
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-30 19:28:54 +0100
committerRichard Jones <rjones@redhat.com>2009-04-30 19:28:54 +0100
commit62df226f26bd6ac3c481a7790eb89d760d2f0386 (patch)
tree617a5a436598902b2239d67535925520c20a6e6e /ruby
parent2a42bec2c5ee521f29179a5aab713f5a9ca2c3b8 (diff)
downloadlibguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.gz
libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.xz
libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.zip
Added 'zero' command to wipe partition tables and superblocks.
Diffstat (limited to 'ruby')
-rw-r--r--ruby/ext/guestfs/_guestfs.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index 56b3f217..1e87d043 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -2540,6 +2540,27 @@ static VALUE ruby_guestfs_fsck (VALUE gv, VALUE fstypev, VALUE devicev)
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;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
@@ -2760,4 +2781,6 @@ void Init__guestfs ()
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);
}