X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ruby%2Fext%2Fguestfs%2F_guestfs.c;h=89eb6afd4781cf207561e1fdbc343ef89f09609c;hp=4e1a2d40be432a92b43db20bdcd94eef85477f90;hb=79cdf81e2fb717ea4372a55170d16800cdbddf23;hpb=43db06ea892cc157324a6b837ca430607441c509 diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 4e1a2d4..89eb6af 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -2231,6 +2231,93 @@ static VALUE ruby_guestfs_tgz_out (VALUE gv, VALUE directoryv, VALUE tarballv) return Qnil; } +static VALUE ruby_guestfs_mount_ro (VALUE gv, VALUE devicev, VALUE mountpointv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_ro"); + + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mount_ro"); + const char *mountpoint = StringValueCStr (mountpointv); + if (!mountpoint) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "mountpoint", "mount_ro"); + + int r; + + r = guestfs_mount_ro (g, device, mountpoint); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mount_options (VALUE gv, VALUE optionsv, VALUE devicev, VALUE mountpointv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_options"); + + const char *options = StringValueCStr (optionsv); + if (!options) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "options", "mount_options"); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mount_options"); + const char *mountpoint = StringValueCStr (mountpointv); + if (!mountpoint) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "mountpoint", "mount_options"); + + int r; + + r = guestfs_mount_options (g, options, device, mountpoint); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mount_vfs (VALUE gv, VALUE optionsv, VALUE vfstypev, VALUE devicev, VALUE mountpointv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_vfs"); + + const char *options = StringValueCStr (optionsv); + if (!options) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "options", "mount_vfs"); + const char *vfstype = StringValueCStr (vfstypev); + if (!vfstype) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "vfstype", "mount_vfs"); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mount_vfs"); + const char *mountpoint = StringValueCStr (mountpointv); + if (!mountpoint) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "mountpoint", "mount_vfs"); + + int r; + + r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + /* Initialize the module. */ void Init__guestfs () { @@ -2427,4 +2514,10 @@ void Init__guestfs () ruby_guestfs_tgz_in, 2); rb_define_method (c_guestfs, "tgz_out", ruby_guestfs_tgz_out, 2); + rb_define_method (c_guestfs, "mount_ro", + ruby_guestfs_mount_ro, 2); + rb_define_method (c_guestfs, "mount_options", + ruby_guestfs_mount_options, 3); + rb_define_method (c_guestfs, "mount_vfs", + ruby_guestfs_mount_vfs, 4); }