X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ruby%2Fext%2Fguestfs%2F_guestfs.c;h=606e9a2afa3cb24c439d0339a790890bea60cedd;hp=4983932f98d3dc7c664c9e5d0d2eb7bba5f98209;hb=0884d8bbae6d76a603ec1385ada2938f88981c5c;hpb=d1a1ab972bb22f4c38a21fcc73f81650aaa03b4e diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 4983932..606e9a2 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -78,12 +78,15 @@ static VALUE ruby_guestfs_test0 (VALUE gv, VALUE strv, VALUE optstrv, VALUE strl if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0"); + Check_Type (strv, T_STRING); const char *str = StringValueCStr (strv); if (!str) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "str", "test0"); const char *optstr = !NIL_P (optstrv) ? StringValueCStr (optstrv) : NULL; - char **strlist; { + char **strlist; + Check_Type (strlistv, T_ARRAY); + { int i, len; len = RARRAY_LEN (strlistv); strlist = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -95,10 +98,12 @@ static VALUE ruby_guestfs_test0 (VALUE gv, VALUE strv, VALUE optstrv, VALUE strl } int b = RTEST (bv); int integer = NUM2INT (integerv); + Check_Type (fileinv, T_STRING); const char *filein = StringValueCStr (fileinv); if (!filein) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "filein", "test0"); + Check_Type (fileoutv, T_STRING); const char *fileout = StringValueCStr (fileoutv); if (!fileout) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -121,6 +126,7 @@ static VALUE ruby_guestfs_test0rint (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -159,6 +165,7 @@ static VALUE ruby_guestfs_test0rint64 (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint64"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -197,6 +204,7 @@ static VALUE ruby_guestfs_test0rbool (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rbool"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -235,6 +243,7 @@ static VALUE ruby_guestfs_test0rconststring (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rconststring"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -273,6 +282,7 @@ static VALUE ruby_guestfs_test0rstring (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstring"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -315,6 +325,7 @@ static VALUE ruby_guestfs_test0rstringlist (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringlist"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -369,6 +380,7 @@ static VALUE ruby_guestfs_test0rintbool (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rintbool"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -415,6 +427,7 @@ static VALUE ruby_guestfs_test0rpvlist (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rpvlist"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -495,6 +508,7 @@ static VALUE ruby_guestfs_test0rvglist (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rvglist"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -585,6 +599,7 @@ static VALUE ruby_guestfs_test0rlvlist (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rlvlist"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -669,6 +684,7 @@ static VALUE ruby_guestfs_test0rstat (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstat"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -737,6 +753,7 @@ static VALUE ruby_guestfs_test0rstatvfs (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstatvfs"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -801,6 +818,7 @@ static VALUE ruby_guestfs_test0rhashtable (VALUE gv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rhashtable"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -906,6 +924,7 @@ static VALUE ruby_guestfs_add_drive (VALUE gv, VALUE filenamev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "add_drive"); + Check_Type (filenamev, T_STRING); const char *filename = StringValueCStr (filenamev); if (!filename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -927,6 +946,7 @@ static VALUE ruby_guestfs_add_cdrom (VALUE gv, VALUE filenamev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "add_cdrom"); + Check_Type (filenamev, T_STRING); const char *filename = StringValueCStr (filenamev); if (!filename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -948,6 +968,7 @@ static VALUE ruby_guestfs_add_drive_ro (VALUE gv, VALUE filenamev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "add_drive_ro"); + Check_Type (filenamev, T_STRING); const char *filename = StringValueCStr (filenamev); if (!filename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -969,6 +990,7 @@ static VALUE ruby_guestfs_config (VALUE gv, VALUE qemuparamv, VALUE qemuvaluev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "config"); + Check_Type (qemuparamv, T_STRING); const char *qemuparam = StringValueCStr (qemuparamv); if (!qemuparam) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -991,6 +1013,7 @@ static VALUE ruby_guestfs_set_qemu (VALUE gv, VALUE qemuv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "set_qemu"); + Check_Type (qemuv, T_STRING); const char *qemu = StringValueCStr (qemuv); if (!qemu) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1029,6 +1052,7 @@ static VALUE ruby_guestfs_set_path (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "set_path"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1067,6 +1091,7 @@ static VALUE ruby_guestfs_set_append (VALUE gv, VALUE appendv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "set_append"); + Check_Type (appendv, T_STRING); const char *append = StringValueCStr (appendv); if (!append) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1304,6 +1329,41 @@ static VALUE ruby_guestfs_end_busy (VALUE gv) return Qnil; } +static VALUE ruby_guestfs_set_memsize (VALUE gv, VALUE memsizev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "set_memsize"); + + int memsize = NUM2INT (memsizev); + + int r; + + r = guestfs_set_memsize (g, memsize); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_get_memsize (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "get_memsize"); + + + int r; + + r = guestfs_get_memsize (g); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + static VALUE ruby_guestfs_mount (VALUE gv, VALUE devicev, VALUE mountpointv) { guestfs_h *g; @@ -1311,10 +1371,12 @@ static VALUE ruby_guestfs_mount (VALUE gv, VALUE devicev, VALUE mountpointv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mount"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "mount"); + Check_Type (mountpointv, T_STRING); const char *mountpoint = StringValueCStr (mountpointv); if (!mountpoint) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1353,6 +1415,7 @@ static VALUE ruby_guestfs_touch (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "touch"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1374,6 +1437,7 @@ static VALUE ruby_guestfs_cat (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "cat"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1397,6 +1461,7 @@ static VALUE ruby_guestfs_ll (VALUE gv, VALUE directoryv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "ll"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1420,6 +1485,7 @@ static VALUE ruby_guestfs_ls (VALUE gv, VALUE directoryv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "ls"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1695,6 +1761,7 @@ static VALUE ruby_guestfs_read_lines (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "read_lines"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1724,6 +1791,7 @@ static VALUE ruby_guestfs_aug_init (VALUE gv, VALUE rootv, VALUE flagsv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_init"); + Check_Type (rootv, T_STRING); const char *root = StringValueCStr (rootv); if (!root) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1763,6 +1831,7 @@ static VALUE ruby_guestfs_aug_defvar (VALUE gv, VALUE namev, VALUE exprv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_defvar"); + Check_Type (namev, T_STRING); const char *name = StringValueCStr (namev); if (!name) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1785,14 +1854,17 @@ static VALUE ruby_guestfs_aug_defnode (VALUE gv, VALUE namev, VALUE exprv, VALUE if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_defnode"); + Check_Type (namev, T_STRING); const char *name = StringValueCStr (namev); if (!name) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "name", "aug_defnode"); + Check_Type (exprv, T_STRING); const char *expr = StringValueCStr (exprv); if (!expr) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "expr", "aug_defnode"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1818,6 +1890,7 @@ static VALUE ruby_guestfs_aug_get (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_get"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1841,10 +1914,12 @@ static VALUE ruby_guestfs_aug_set (VALUE gv, VALUE pathv, VALUE valv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_set"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "path", "aug_set"); + Check_Type (valv, T_STRING); const char *val = StringValueCStr (valv); if (!val) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1866,10 +1941,12 @@ static VALUE ruby_guestfs_aug_insert (VALUE gv, VALUE pathv, VALUE labelv, VALUE if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_insert"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "path", "aug_insert"); + Check_Type (labelv, T_STRING); const char *label = StringValueCStr (labelv); if (!label) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1892,6 +1969,7 @@ static VALUE ruby_guestfs_aug_rm (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_rm"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1913,10 +1991,12 @@ static VALUE ruby_guestfs_aug_mv (VALUE gv, VALUE srcv, VALUE destv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_mv"); + Check_Type (srcv, T_STRING); const char *src = StringValueCStr (srcv); if (!src) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "src", "aug_mv"); + Check_Type (destv, T_STRING); const char *dest = StringValueCStr (destv); if (!dest) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -1938,6 +2018,7 @@ static VALUE ruby_guestfs_aug_match (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_match"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2001,6 +2082,7 @@ static VALUE ruby_guestfs_aug_ls (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "aug_ls"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2030,6 +2112,7 @@ static VALUE ruby_guestfs_rm (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "rm"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2051,6 +2134,7 @@ static VALUE ruby_guestfs_rmdir (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "rmdir"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2072,6 +2156,7 @@ static VALUE ruby_guestfs_rm_rf (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "rm_rf"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2093,6 +2178,7 @@ static VALUE ruby_guestfs_mkdir (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mkdir"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2114,6 +2200,7 @@ static VALUE ruby_guestfs_mkdir_p (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mkdir_p"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2136,6 +2223,7 @@ static VALUE ruby_guestfs_chmod (VALUE gv, VALUE modev, VALUE pathv) rb_raise (rb_eArgError, "%s: used handle after closing it", "chmod"); int mode = NUM2INT (modev); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2159,6 +2247,7 @@ static VALUE ruby_guestfs_chown (VALUE gv, VALUE ownerv, VALUE groupv, VALUE pat int owner = NUM2INT (ownerv); int group = NUM2INT (groupv); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2180,6 +2269,7 @@ static VALUE ruby_guestfs_exists (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "exists"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2201,6 +2291,7 @@ static VALUE ruby_guestfs_is_file (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "is_file"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2222,6 +2313,7 @@ static VALUE ruby_guestfs_is_dir (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "is_dir"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2243,6 +2335,7 @@ static VALUE ruby_guestfs_pvcreate (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "pvcreate"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2264,11 +2357,14 @@ static VALUE ruby_guestfs_vgcreate (VALUE gv, VALUE volgroupv, VALUE physvolsv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "vgcreate"); + Check_Type (volgroupv, T_STRING); const char *volgroup = StringValueCStr (volgroupv); if (!volgroup) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "volgroup", "vgcreate"); - char **physvols; { + char **physvols; + Check_Type (physvolsv, T_ARRAY); + { int i, len; len = RARRAY_LEN (physvolsv); physvols = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -2296,10 +2392,12 @@ static VALUE ruby_guestfs_lvcreate (VALUE gv, VALUE logvolv, VALUE volgroupv, VA if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "lvcreate"); + Check_Type (logvolv, T_STRING); const char *logvol = StringValueCStr (logvolv); if (!logvol) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "logvol", "lvcreate"); + Check_Type (volgroupv, T_STRING); const char *volgroup = StringValueCStr (volgroupv); if (!volgroup) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2322,10 +2420,12 @@ static VALUE ruby_guestfs_mkfs (VALUE gv, VALUE fstypev, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mkfs"); + Check_Type (fstypev, T_STRING); const char *fstype = StringValueCStr (fstypev); if (!fstype) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "fstype", "mkfs"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2347,6 +2447,7 @@ static VALUE ruby_guestfs_sfdisk (VALUE gv, VALUE devicev, VALUE cylsv, VALUE he if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2354,7 +2455,9 @@ static VALUE ruby_guestfs_sfdisk (VALUE gv, VALUE devicev, VALUE cylsv, VALUE he int cyls = NUM2INT (cylsv); int heads = NUM2INT (headsv); int sectors = NUM2INT (sectorsv); - char **lines; { + char **lines; + Check_Type (linesv, T_ARRAY); + { int i, len; len = RARRAY_LEN (linesv); lines = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -2382,10 +2485,12 @@ static VALUE ruby_guestfs_write_file (VALUE gv, VALUE pathv, VALUE contentv, VAL if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "write_file"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "path", "write_file"); + Check_Type (contentv, T_STRING); const char *content = StringValueCStr (contentv); if (!content) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2408,6 +2513,7 @@ static VALUE ruby_guestfs_umount (VALUE gv, VALUE pathordevicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "umount"); + Check_Type (pathordevicev, T_STRING); const char *pathordevice = StringValueCStr (pathordevicev); if (!pathordevice) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2488,6 +2594,7 @@ static VALUE ruby_guestfs_file (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "file"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2511,7 +2618,9 @@ static VALUE ruby_guestfs_command (VALUE gv, VALUE argumentsv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "command"); - char **arguments; { + char **arguments; + Check_Type (argumentsv, T_ARRAY); + { int i, len; len = RARRAY_LEN (argumentsv); arguments = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -2541,7 +2650,9 @@ static VALUE ruby_guestfs_command_lines (VALUE gv, VALUE argumentsv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "command_lines"); - char **arguments; { + char **arguments; + Check_Type (argumentsv, T_ARRAY); + { int i, len; len = RARRAY_LEN (argumentsv); arguments = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -2577,6 +2688,7 @@ static VALUE ruby_guestfs_stat (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "stat"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2613,6 +2725,7 @@ static VALUE ruby_guestfs_lstat (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "lstat"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2649,6 +2762,7 @@ static VALUE ruby_guestfs_statvfs (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "statvfs"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2683,6 +2797,7 @@ static VALUE ruby_guestfs_tune2fs_l (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "tune2fs_l"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2712,6 +2827,7 @@ static VALUE ruby_guestfs_blockdev_setro (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_setro"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2733,6 +2849,7 @@ static VALUE ruby_guestfs_blockdev_setrw (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_setrw"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2754,6 +2871,7 @@ static VALUE ruby_guestfs_blockdev_getro (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getro"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2775,6 +2893,7 @@ static VALUE ruby_guestfs_blockdev_getss (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getss"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2796,6 +2915,7 @@ static VALUE ruby_guestfs_blockdev_getbsz (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getbsz"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2817,6 +2937,7 @@ static VALUE ruby_guestfs_blockdev_setbsz (VALUE gv, VALUE devicev, VALUE blocks if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_setbsz"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2839,6 +2960,7 @@ static VALUE ruby_guestfs_blockdev_getsz (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getsz"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2860,6 +2982,7 @@ static VALUE ruby_guestfs_blockdev_getsize64 (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_getsize64"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2881,6 +3004,7 @@ static VALUE ruby_guestfs_blockdev_flushbufs (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_flushbufs"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2902,6 +3026,7 @@ static VALUE ruby_guestfs_blockdev_rereadpt (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "blockdev_rereadpt"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2923,10 +3048,12 @@ static VALUE ruby_guestfs_upload (VALUE gv, VALUE filenamev, VALUE remotefilenam if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "upload"); + Check_Type (filenamev, T_STRING); const char *filename = StringValueCStr (filenamev); if (!filename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "filename", "upload"); + Check_Type (remotefilenamev, T_STRING); const char *remotefilename = StringValueCStr (remotefilenamev); if (!remotefilename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2948,10 +3075,12 @@ static VALUE ruby_guestfs_download (VALUE gv, VALUE remotefilenamev, VALUE filen if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "download"); + Check_Type (remotefilenamev, T_STRING); const char *remotefilename = StringValueCStr (remotefilenamev); if (!remotefilename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "remotefilename", "download"); + Check_Type (filenamev, T_STRING); const char *filename = StringValueCStr (filenamev); if (!filename) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -2973,10 +3102,12 @@ static VALUE ruby_guestfs_checksum (VALUE gv, VALUE csumtypev, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "checksum"); + Check_Type (csumtypev, T_STRING); const char *csumtype = StringValueCStr (csumtypev); if (!csumtype) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "csumtype", "checksum"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3000,10 +3131,12 @@ static VALUE ruby_guestfs_tar_in (VALUE gv, VALUE tarfilev, VALUE directoryv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_in"); + Check_Type (tarfilev, T_STRING); const char *tarfile = StringValueCStr (tarfilev); if (!tarfile) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "tarfile", "tar_in"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3025,10 +3158,12 @@ static VALUE ruby_guestfs_tar_out (VALUE gv, VALUE directoryv, VALUE tarfilev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_out"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "directory", "tar_out"); + Check_Type (tarfilev, T_STRING); const char *tarfile = StringValueCStr (tarfilev); if (!tarfile) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3050,10 +3185,12 @@ static VALUE ruby_guestfs_tgz_in (VALUE gv, VALUE tarballv, VALUE directoryv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_in"); + Check_Type (tarballv, T_STRING); const char *tarball = StringValueCStr (tarballv); if (!tarball) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "tarball", "tgz_in"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3075,10 +3212,12 @@ static VALUE ruby_guestfs_tgz_out (VALUE gv, VALUE directoryv, VALUE tarballv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_out"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "directory", "tgz_out"); + Check_Type (tarballv, T_STRING); const char *tarball = StringValueCStr (tarballv); if (!tarball) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3100,10 +3239,12 @@ static VALUE ruby_guestfs_mount_ro (VALUE gv, VALUE devicev, VALUE mountpointv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_ro"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "mount_ro"); + Check_Type (mountpointv, T_STRING); const char *mountpoint = StringValueCStr (mountpointv); if (!mountpoint) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3125,14 +3266,17 @@ static VALUE ruby_guestfs_mount_options (VALUE gv, VALUE optionsv, VALUE devicev if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_options"); + Check_Type (optionsv, T_STRING); const char *options = StringValueCStr (optionsv); if (!options) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "options", "mount_options"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "mount_options"); + Check_Type (mountpointv, T_STRING); const char *mountpoint = StringValueCStr (mountpointv); if (!mountpoint) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3154,18 +3298,22 @@ static VALUE ruby_guestfs_mount_vfs (VALUE gv, VALUE optionsv, VALUE vfstypev, V if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mount_vfs"); + Check_Type (optionsv, T_STRING); const char *options = StringValueCStr (optionsv); if (!options) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "options", "mount_vfs"); + Check_Type (vfstypev, T_STRING); const char *vfstype = StringValueCStr (vfstypev); if (!vfstype) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "vfstype", "mount_vfs"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "mount_vfs"); + Check_Type (mountpointv, T_STRING); const char *mountpoint = StringValueCStr (mountpointv); if (!mountpoint) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3187,11 +3335,14 @@ static VALUE ruby_guestfs_debug (VALUE gv, VALUE subcmdv, VALUE extraargsv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "debug"); + Check_Type (subcmdv, T_STRING); const char *subcmd = StringValueCStr (subcmdv); if (!subcmd) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "subcmd", "debug"); - char **extraargs; { + char **extraargs; + Check_Type (extraargsv, T_ARRAY); + { int i, len; len = RARRAY_LEN (extraargsv); extraargs = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -3221,6 +3372,7 @@ static VALUE ruby_guestfs_lvremove (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "lvremove"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3242,6 +3394,7 @@ static VALUE ruby_guestfs_vgremove (VALUE gv, VALUE vgnamev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "vgremove"); + Check_Type (vgnamev, T_STRING); const char *vgname = StringValueCStr (vgnamev); if (!vgname) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3263,6 +3416,7 @@ static VALUE ruby_guestfs_pvremove (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "pvremove"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3284,10 +3438,12 @@ static VALUE ruby_guestfs_set_e2label (VALUE gv, VALUE devicev, VALUE labelv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "set_e2label"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "set_e2label"); + Check_Type (labelv, T_STRING); const char *label = StringValueCStr (labelv); if (!label) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3309,6 +3465,7 @@ static VALUE ruby_guestfs_get_e2label (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "get_e2label"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3332,10 +3489,12 @@ static VALUE ruby_guestfs_set_e2uuid (VALUE gv, VALUE devicev, VALUE uuidv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "set_e2uuid"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "set_e2uuid"); + Check_Type (uuidv, T_STRING); const char *uuid = StringValueCStr (uuidv); if (!uuid) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3357,6 +3516,7 @@ static VALUE ruby_guestfs_get_e2uuid (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "get_e2uuid"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3380,10 +3540,12 @@ static VALUE ruby_guestfs_fsck (VALUE gv, VALUE fstypev, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "fsck"); + Check_Type (fstypev, T_STRING); const char *fstype = StringValueCStr (fstypev); if (!fstype) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "fstype", "fsck"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3405,6 +3567,7 @@ static VALUE ruby_guestfs_zero (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "zero"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3426,10 +3589,12 @@ static VALUE ruby_guestfs_grub_install (VALUE gv, VALUE rootv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "grub_install"); + Check_Type (rootv, T_STRING); const char *root = StringValueCStr (rootv); if (!root) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "root", "grub_install"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3451,10 +3616,12 @@ static VALUE ruby_guestfs_cp (VALUE gv, VALUE srcv, VALUE destv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "cp"); + Check_Type (srcv, T_STRING); const char *src = StringValueCStr (srcv); if (!src) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "src", "cp"); + Check_Type (destv, T_STRING); const char *dest = StringValueCStr (destv); if (!dest) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3476,10 +3643,12 @@ static VALUE ruby_guestfs_cp_a (VALUE gv, VALUE srcv, VALUE destv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "cp_a"); + Check_Type (srcv, T_STRING); const char *src = StringValueCStr (srcv); if (!src) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "src", "cp_a"); + Check_Type (destv, T_STRING); const char *dest = StringValueCStr (destv); if (!dest) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3501,10 +3670,12 @@ static VALUE ruby_guestfs_mv (VALUE gv, VALUE srcv, VALUE destv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "mv"); + Check_Type (srcv, T_STRING); const char *src = StringValueCStr (srcv); if (!src) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "src", "mv"); + Check_Type (destv, T_STRING); const char *dest = StringValueCStr (destv); if (!dest) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3580,10 +3751,12 @@ static VALUE ruby_guestfs_equal (VALUE gv, VALUE file1v, VALUE file2v) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "equal"); + Check_Type (file1v, T_STRING); const char *file1 = StringValueCStr (file1v); if (!file1) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "file1", "equal"); + Check_Type (file2v, T_STRING); const char *file2 = StringValueCStr (file2v); if (!file2) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3605,6 +3778,7 @@ static VALUE ruby_guestfs_strings (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "strings"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3634,10 +3808,12 @@ static VALUE ruby_guestfs_strings_e (VALUE gv, VALUE encodingv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "strings_e"); + Check_Type (encodingv, T_STRING); const char *encoding = StringValueCStr (encodingv); if (!encoding) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "encoding", "strings_e"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3667,6 +3843,7 @@ static VALUE ruby_guestfs_hexdump (VALUE gv, VALUE pathv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "hexdump"); + Check_Type (pathv, T_STRING); const char *path = StringValueCStr (pathv); if (!path) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3690,6 +3867,7 @@ static VALUE ruby_guestfs_zerofree (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "zerofree"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3711,6 +3889,7 @@ static VALUE ruby_guestfs_pvresize (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "pvresize"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3725,21 +3904,23 @@ static VALUE ruby_guestfs_pvresize (VALUE gv, VALUE devicev) return Qnil; } -static VALUE ruby_guestfs_sfdisk_N (VALUE gv, VALUE devicev, VALUE nv, VALUE cylsv, VALUE headsv, VALUE sectorsv, VALUE linev) +static VALUE ruby_guestfs_sfdisk_N (VALUE gv, VALUE devicev, VALUE partnumv, VALUE cylsv, VALUE headsv, VALUE sectorsv, VALUE linev) { guestfs_h *g; Data_Get_Struct (gv, guestfs_h, g); if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_N"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", "device", "sfdisk_N"); - int n = NUM2INT (nv); + int partnum = NUM2INT (partnumv); int cyls = NUM2INT (cylsv); int heads = NUM2INT (headsv); int sectors = NUM2INT (sectorsv); + Check_Type (linev, T_STRING); const char *line = StringValueCStr (linev); if (!line) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3747,7 +3928,7 @@ static VALUE ruby_guestfs_sfdisk_N (VALUE gv, VALUE devicev, VALUE nv, VALUE cyl int r; - r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line); + r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line); if (r == -1) rb_raise (e_Error, "%s", guestfs_last_error (g)); @@ -3761,6 +3942,7 @@ static VALUE ruby_guestfs_sfdisk_l (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_l"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3784,6 +3966,7 @@ static VALUE ruby_guestfs_sfdisk_kernel_geometry (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_kernel_geometry"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3807,6 +3990,7 @@ static VALUE ruby_guestfs_sfdisk_disk_geometry (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "sfdisk_disk_geometry"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3849,7 +4033,9 @@ static VALUE ruby_guestfs_vg_activate (VALUE gv, VALUE activatev, VALUE volgroup rb_raise (rb_eArgError, "%s: used handle after closing it", "vg_activate"); int activate = RTEST (activatev); - char **volgroups; { + char **volgroups; + Check_Type (volgroupsv, T_ARRAY); + { int i, len; len = RARRAY_LEN (volgroupsv); volgroups = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); @@ -3877,6 +4063,7 @@ static VALUE ruby_guestfs_lvresize (VALUE gv, VALUE devicev, VALUE mbytesv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "lvresize"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3899,6 +4086,7 @@ static VALUE ruby_guestfs_resize2fs (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "resize2fs"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3920,6 +4108,7 @@ static VALUE ruby_guestfs_find (VALUE gv, VALUE directoryv) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "find"); + Check_Type (directoryv, T_STRING); const char *directory = StringValueCStr (directoryv); if (!directory) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3949,6 +4138,7 @@ static VALUE ruby_guestfs_e2fsck_f (VALUE gv, VALUE devicev) if (!g) rb_raise (rb_eArgError, "%s: used handle after closing it", "e2fsck_f"); + Check_Type (devicev, T_STRING); const char *device = StringValueCStr (devicev); if (!device) rb_raise (rb_eTypeError, "expected string for parameter %s of %s", @@ -3963,6 +4153,718 @@ static VALUE ruby_guestfs_e2fsck_f (VALUE gv, VALUE devicev) return Qnil; } +static VALUE ruby_guestfs_sleep (VALUE gv, VALUE secsv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "sleep"); + + int secs = NUM2INT (secsv); + + int r; + + r = guestfs_sleep (g, secs); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_ntfs_3g_probe (VALUE gv, VALUE rwv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "ntfs_3g_probe"); + + int rw = RTEST (rwv); + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "ntfs_3g_probe"); + + int r; + + r = guestfs_ntfs_3g_probe (g, rw, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_sh (VALUE gv, VALUE commandv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "sh"); + + Check_Type (commandv, T_STRING); + const char *command = StringValueCStr (commandv); + if (!command) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "command", "sh"); + + char *r; + + r = guestfs_sh (g, command); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_str_new2 (r); + free (r); + return rv; +} + +static VALUE ruby_guestfs_sh_lines (VALUE gv, VALUE commandv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "sh_lines"); + + Check_Type (commandv, T_STRING); + const char *command = StringValueCStr (commandv); + if (!command) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "command", "sh_lines"); + + char **r; + + r = guestfs_sh_lines (g, command); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_glob_expand (VALUE gv, VALUE patternv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "glob_expand"); + + Check_Type (patternv, T_STRING); + const char *pattern = StringValueCStr (patternv); + if (!pattern) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "pattern", "glob_expand"); + + char **r; + + r = guestfs_glob_expand (g, pattern); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_scrub_device (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", "scrub_device"); + + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "scrub_device"); + + int r; + + r = guestfs_scrub_device (g, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_scrub_file (VALUE gv, VALUE filev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "scrub_file"); + + Check_Type (filev, T_STRING); + const char *file = StringValueCStr (filev); + if (!file) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "file", "scrub_file"); + + int r; + + r = guestfs_scrub_file (g, file); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_scrub_freespace (VALUE gv, VALUE dirv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "scrub_freespace"); + + Check_Type (dirv, T_STRING); + const char *dir = StringValueCStr (dirv); + if (!dir) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "dir", "scrub_freespace"); + + int r; + + r = guestfs_scrub_freespace (g, dir); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkdtemp (VALUE gv, VALUE templatev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkdtemp"); + + Check_Type (templatev, T_STRING); + const char *template = StringValueCStr (templatev); + if (!template) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "template", "mkdtemp"); + + char *r; + + r = guestfs_mkdtemp (g, template); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_str_new2 (r); + free (r); + return rv; +} + +static VALUE ruby_guestfs_wc_l (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "wc_l"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "wc_l"); + + int r; + + r = guestfs_wc_l (g, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_wc_w (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "wc_w"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "wc_w"); + + int r; + + r = guestfs_wc_w (g, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_wc_c (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "wc_c"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "wc_c"); + + int r; + + r = guestfs_wc_c (g, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_head (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "head"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "head"); + + char **r; + + r = guestfs_head (g, path); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_head_n (VALUE gv, VALUE nrlinesv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "head_n"); + + int nrlines = NUM2INT (nrlinesv); + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "head_n"); + + char **r; + + r = guestfs_head_n (g, nrlines, path); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_tail (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tail"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "tail"); + + char **r; + + r = guestfs_tail (g, path); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_tail_n (VALUE gv, VALUE nrlinesv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tail_n"); + + int nrlines = NUM2INT (nrlinesv); + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "tail_n"); + + char **r; + + r = guestfs_tail_n (g, nrlines, path); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_df (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "df"); + + + char *r; + + r = guestfs_df (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_str_new2 (r); + free (r); + return rv; +} + +static VALUE ruby_guestfs_df_h (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "df_h"); + + + char *r; + + r = guestfs_df_h (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_str_new2 (r); + free (r); + return rv; +} + +static VALUE ruby_guestfs_du (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "du"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "du"); + + int64_t r; + + r = guestfs_du (g, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return ULL2NUM (r); +} + +static VALUE ruby_guestfs_initrd_list (VALUE gv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "initrd_list"); + + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "initrd_list"); + + char **r; + + r = guestfs_initrd_list (g, path); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + int i, len = 0; + for (i = 0; r[i] != NULL; ++i) len++; + VALUE rv = rb_ary_new2 (len); + for (i = 0; r[i] != NULL; ++i) { + rb_ary_push (rv, rb_str_new2 (r[i])); + free (r[i]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_mount_loop (VALUE gv, VALUE filev, 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_loop"); + + Check_Type (filev, T_STRING); + const char *file = StringValueCStr (filev); + if (!file) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "file", "mount_loop"); + Check_Type (mountpointv, T_STRING); + const char *mountpoint = StringValueCStr (mountpointv); + if (!mountpoint) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "mountpoint", "mount_loop"); + + int r; + + r = guestfs_mount_loop (g, file, mountpoint); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkswap (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", "mkswap"); + + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mkswap"); + + int r; + + r = guestfs_mkswap (g, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkswap_L (VALUE gv, VALUE labelv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap_L"); + + Check_Type (labelv, T_STRING); + const char *label = StringValueCStr (labelv); + if (!label) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "label", "mkswap_L"); + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mkswap_L"); + + int r; + + r = guestfs_mkswap_L (g, label, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkswap_U (VALUE gv, VALUE uuidv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap_U"); + + Check_Type (uuidv, T_STRING); + const char *uuid = StringValueCStr (uuidv); + if (!uuid) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "uuid", "mkswap_U"); + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mkswap_U"); + + int r; + + r = guestfs_mkswap_U (g, uuid, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mknod (VALUE gv, VALUE modev, VALUE devmajorv, VALUE devminorv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mknod"); + + int mode = NUM2INT (modev); + int devmajor = NUM2INT (devmajorv); + int devminor = NUM2INT (devminorv); + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "mknod"); + + int r; + + r = guestfs_mknod (g, mode, devmajor, devminor, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkfifo (VALUE gv, VALUE modev, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkfifo"); + + int mode = NUM2INT (modev); + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "mkfifo"); + + int r; + + r = guestfs_mkfifo (g, mode, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mknod_b (VALUE gv, VALUE modev, VALUE devmajorv, VALUE devminorv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mknod_b"); + + int mode = NUM2INT (modev); + int devmajor = NUM2INT (devmajorv); + int devminor = NUM2INT (devminorv); + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "mknod_b"); + + int r; + + r = guestfs_mknod_b (g, mode, devmajor, devminor, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mknod_c (VALUE gv, VALUE modev, VALUE devmajorv, VALUE devminorv, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mknod_c"); + + int mode = NUM2INT (modev); + int devmajor = NUM2INT (devmajorv); + int devminor = NUM2INT (devminorv); + Check_Type (pathv, T_STRING); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "mknod_c"); + + int r; + + r = guestfs_mknod_c (g, mode, devmajor, devminor, path); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_umask (VALUE gv, VALUE maskv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "umask"); + + int mask = NUM2INT (maskv); + + int r; + + r = guestfs_umask (g, mask); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + /* Initialize the module. */ void Init__guestfs () { @@ -4077,6 +4979,10 @@ void Init__guestfs () ruby_guestfs_set_ready, 0); rb_define_method (c_guestfs, "end_busy", ruby_guestfs_end_busy, 0); + rb_define_method (c_guestfs, "set_memsize", + ruby_guestfs_set_memsize, 1); + rb_define_method (c_guestfs, "get_memsize", + ruby_guestfs_get_memsize, 0); rb_define_method (c_guestfs, "mount", ruby_guestfs_mount, 2); rb_define_method (c_guestfs, "sync", @@ -4293,4 +5199,62 @@ void Init__guestfs () ruby_guestfs_find, 1); rb_define_method (c_guestfs, "e2fsck_f", ruby_guestfs_e2fsck_f, 1); + rb_define_method (c_guestfs, "sleep", + ruby_guestfs_sleep, 1); + rb_define_method (c_guestfs, "ntfs_3g_probe", + ruby_guestfs_ntfs_3g_probe, 2); + rb_define_method (c_guestfs, "sh", + ruby_guestfs_sh, 1); + rb_define_method (c_guestfs, "sh_lines", + ruby_guestfs_sh_lines, 1); + rb_define_method (c_guestfs, "glob_expand", + ruby_guestfs_glob_expand, 1); + rb_define_method (c_guestfs, "scrub_device", + ruby_guestfs_scrub_device, 1); + rb_define_method (c_guestfs, "scrub_file", + ruby_guestfs_scrub_file, 1); + rb_define_method (c_guestfs, "scrub_freespace", + ruby_guestfs_scrub_freespace, 1); + rb_define_method (c_guestfs, "mkdtemp", + ruby_guestfs_mkdtemp, 1); + rb_define_method (c_guestfs, "wc_l", + ruby_guestfs_wc_l, 1); + rb_define_method (c_guestfs, "wc_w", + ruby_guestfs_wc_w, 1); + rb_define_method (c_guestfs, "wc_c", + ruby_guestfs_wc_c, 1); + rb_define_method (c_guestfs, "head", + ruby_guestfs_head, 1); + rb_define_method (c_guestfs, "head_n", + ruby_guestfs_head_n, 2); + rb_define_method (c_guestfs, "tail", + ruby_guestfs_tail, 1); + rb_define_method (c_guestfs, "tail_n", + ruby_guestfs_tail_n, 2); + rb_define_method (c_guestfs, "df", + ruby_guestfs_df, 0); + rb_define_method (c_guestfs, "df_h", + ruby_guestfs_df_h, 0); + rb_define_method (c_guestfs, "du", + ruby_guestfs_du, 1); + rb_define_method (c_guestfs, "initrd_list", + ruby_guestfs_initrd_list, 1); + rb_define_method (c_guestfs, "mount_loop", + ruby_guestfs_mount_loop, 2); + rb_define_method (c_guestfs, "mkswap", + ruby_guestfs_mkswap, 1); + rb_define_method (c_guestfs, "mkswap_L", + ruby_guestfs_mkswap_L, 2); + rb_define_method (c_guestfs, "mkswap_U", + ruby_guestfs_mkswap_U, 2); + rb_define_method (c_guestfs, "mknod", + ruby_guestfs_mknod, 4); + rb_define_method (c_guestfs, "mkfifo", + ruby_guestfs_mkfifo, 2); + rb_define_method (c_guestfs, "mknod_b", + ruby_guestfs_mknod_b, 4); + rb_define_method (c_guestfs, "mknod_c", + ruby_guestfs_mknod_c, 4); + rb_define_method (c_guestfs, "umask", + ruby_guestfs_umask, 1); }