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 = StringValueCStr (optstrv);
- char **strlist; {
+ const char *optstr = !NIL_P (optstrv) ? StringValueCStr (optstrv) : NULL;
+ char **strlist;
+ Check_Type (strlistv, T_ARRAY);
+ {
int i, len;
len = RARRAY_LEN (strlistv);
strlist = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
}
strlist[len] = NULL;
}
- int b = NUM2INT (bv);
+ 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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
return Qnil;
}
+static VALUE ruby_guestfs_add_drive_ro (VALUE gv, VALUE filenamev)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ 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",
+ "filename", "add_drive_ro");
+
+ int r;
+
+ r = guestfs_add_drive_ro (g, filename);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
static VALUE ruby_guestfs_config (VALUE gv, VALUE qemuparamv, VALUE qemuvaluev)
{
guestfs_h *g;
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",
"qemuparam", "config");
- const char *qemuvalue = StringValueCStr (qemuvaluev);
+ const char *qemuvalue = !NIL_P (qemuvaluev) ? StringValueCStr (qemuvaluev) : NULL;
int r;
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",
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",
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",
if (!g)
rb_raise (rb_eArgError, "%s: used handle after closing it", "set_autosync");
- int autosync = NUM2INT (autosyncv);
+ int autosync = RTEST (autosyncv);
int r;
if (!g)
rb_raise (rb_eArgError, "%s: used handle after closing it", "set_verbose");
- int verbose = NUM2INT (verbosev);
+ int verbose = RTEST (verbosev);
int r;
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",
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",
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",
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",
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",
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",
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",
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",
"name", "aug_defvar");
- const char *expr = StringValueCStr (exprv);
+ const char *expr = !NIL_P (exprv) ? StringValueCStr (exprv) : NULL;
int r;
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",
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",
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",
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",
"label", "aug_insert");
- int before = NUM2INT (beforev);
+ int before = RTEST (beforev);
int r;
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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));
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",
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",
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",
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));
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",
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",
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",
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));
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));
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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));
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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));
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",
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",
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",
if (!g)
rb_raise (rb_eArgError, "%s: used handle after closing it", "vg_activate_all");
- int activate = NUM2INT (activatev);
+ int activate = RTEST (activatev);
int r;
if (!g)
rb_raise (rb_eArgError, "%s: used handle after closing it", "vg_activate");
- int activate = NUM2INT (activatev);
- char **volgroups; {
+ int activate = RTEST (activatev);
+ char **volgroups;
+ Check_Type (volgroupsv, T_ARRAY);
+ {
int i, len;
len = RARRAY_LEN (volgroupsv);
volgroups = guestfs_safe_malloc (g, sizeof (char *) * (len+1));
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",
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",
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",
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",
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;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
ruby_guestfs_add_drive, 1);
rb_define_method (c_guestfs, "add_cdrom",
ruby_guestfs_add_cdrom, 1);
+ rb_define_method (c_guestfs, "add_drive_ro",
+ ruby_guestfs_add_drive_ro, 1);
rb_define_method (c_guestfs, "config",
ruby_guestfs_config, 2);
rb_define_method (c_guestfs, "set_qemu",
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);
}