X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=perl%2FGuestfs.xs;h=93abd9ec0612005df49f98f7e8f658e2159d0ca9;hp=2d564f417a419ddb70f0149e2e6e1df9caae7723;hb=ad5abc8d367c9c410051062cae066b1b141b4c76;hpb=5365ebd501850ea10d9a5b28fc6480ea34dbe16d diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index 2d564f4..93abd9e 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -185,9 +185,8 @@ PREINIT: const char *path; CODE: path = guestfs_get_path (g); - if (path == NULL) { + if (path == NULL) croak ("get_path: %s", guestfs_last_error (g)); - } RETVAL = newSVpv (path, 0); OUTPUT: RETVAL @@ -210,9 +209,8 @@ PREINIT: int autosync; CODE: autosync = guestfs_get_autosync (g); - if (autosync == -1) { + if (autosync == -1) croak ("get_autosync: %s", guestfs_last_error (g)); - } RETVAL = newSViv (autosync); OUTPUT: RETVAL @@ -235,9 +233,8 @@ PREINIT: int verbose; CODE: verbose = guestfs_get_verbose (g); - if (verbose == -1) { + if (verbose == -1) croak ("get_verbose: %s", guestfs_last_error (g)); - } RETVAL = newSViv (verbose); OUTPUT: RETVAL @@ -283,9 +280,8 @@ PREINIT: char *content; CODE: content = guestfs_cat (g, path); - if (content == NULL) { + if (content == NULL) croak ("cat: %s", guestfs_last_error (g)); - } RETVAL = newSVpv (content, 0); free (content); OUTPUT: @@ -299,9 +295,8 @@ PREINIT: char *listing; CODE: listing = guestfs_ll (g, directory); - if (listing == NULL) { + if (listing == NULL) croak ("ll: %s", guestfs_last_error (g)); - } RETVAL = newSVpv (listing, 0); free (listing); OUTPUT: @@ -316,9 +311,8 @@ PREINIT: int i, n; PPCODE: listing = guestfs_ls (g, directory); - if (listing == NULL) { + if (listing == NULL) croak ("ls: %s", guestfs_last_error (g)); - } for (n = 0; listing[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -335,9 +329,8 @@ PREINIT: int i, n; PPCODE: devices = guestfs_list_devices (g); - if (devices == NULL) { + if (devices == NULL) croak ("list_devices: %s", guestfs_last_error (g)); - } for (n = 0; devices[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -354,9 +347,8 @@ PREINIT: int i, n; PPCODE: partitions = guestfs_list_partitions (g); - if (partitions == NULL) { + if (partitions == NULL) croak ("list_partitions: %s", guestfs_last_error (g)); - } for (n = 0; partitions[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -373,9 +365,8 @@ PREINIT: int i, n; PPCODE: physvols = guestfs_pvs (g); - if (physvols == NULL) { + if (physvols == NULL) croak ("pvs: %s", guestfs_last_error (g)); - } for (n = 0; physvols[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -392,9 +383,8 @@ PREINIT: int i, n; PPCODE: volgroups = guestfs_vgs (g); - if (volgroups == NULL) { + if (volgroups == NULL) croak ("vgs: %s", guestfs_last_error (g)); - } for (n = 0; volgroups[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -411,9 +401,8 @@ PREINIT: int i, n; PPCODE: logvols = guestfs_lvs (g); - if (logvols == NULL) { + if (logvols == NULL) croak ("lvs: %s", guestfs_last_error (g)); - } for (n = 0; logvols[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -431,9 +420,8 @@ PREINIT: HV *hv; PPCODE: physvols = guestfs_pvs_full (g); - if (physvols == NULL) { + if (physvols == NULL) croak ("pvs_full: %s", guestfs_last_error (g)); - } EXTEND (SP, physvols->len); for (i = 0; i < physvols->len; ++i) { hv = newHV (); @@ -464,9 +452,8 @@ PREINIT: HV *hv; PPCODE: volgroups = guestfs_vgs_full (g); - if (volgroups == NULL) { + if (volgroups == NULL) croak ("vgs_full: %s", guestfs_last_error (g)); - } EXTEND (SP, volgroups->len); for (i = 0; i < volgroups->len; ++i) { hv = newHV (); @@ -502,9 +489,8 @@ PREINIT: HV *hv; PPCODE: logvols = guestfs_lvs_full (g); - if (logvols == NULL) { + if (logvols == NULL) croak ("lvs_full: %s", guestfs_last_error (g)); - } EXTEND (SP, logvols->len); for (i = 0; i < logvols->len; ++i) { hv = newHV (); @@ -537,9 +523,8 @@ PREINIT: int i, n; PPCODE: lines = guestfs_read_lines (g, path); - if (lines == NULL) { + if (lines == NULL) croak ("read_lines: %s", guestfs_last_error (g)); - } for (n = 0; lines[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -579,9 +564,8 @@ PREINIT: int nrnodes; CODE: nrnodes = guestfs_aug_defvar (g, name, expr); - if (nrnodes == -1) { + if (nrnodes == -1) croak ("aug_defvar: %s", guestfs_last_error (g)); - } RETVAL = newSViv (nrnodes); OUTPUT: RETVAL @@ -596,9 +580,8 @@ PREINIT: struct guestfs_int_bool *r; PPCODE: r = guestfs_aug_defnode (g, name, expr, val); - if (r == NULL) { + if (r == NULL) croak ("aug_defnode: %s", guestfs_last_error (g)); - } EXTEND (SP, 2); PUSHs (sv_2mortal (newSViv (r->i))); PUSHs (sv_2mortal (newSViv (r->b))); @@ -612,9 +595,8 @@ PREINIT: char *val; CODE: val = guestfs_aug_get (g, path); - if (val == NULL) { + if (val == NULL) croak ("aug_get: %s", guestfs_last_error (g)); - } RETVAL = newSVpv (val, 0); free (val); OUTPUT: @@ -653,9 +635,8 @@ PREINIT: int nrnodes; CODE: nrnodes = guestfs_aug_rm (g, path); - if (nrnodes == -1) { + if (nrnodes == -1) croak ("aug_rm: %s", guestfs_last_error (g)); - } RETVAL = newSViv (nrnodes); OUTPUT: RETVAL @@ -681,9 +662,8 @@ PREINIT: int i, n; PPCODE: matches = guestfs_aug_match (g, path); - if (matches == NULL) { + if (matches == NULL) croak ("aug_match: %s", guestfs_last_error (g)); - } for (n = 0; matches[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -721,9 +701,8 @@ PREINIT: int i, n; PPCODE: matches = guestfs_aug_ls (g, path); - if (matches == NULL) { + if (matches == NULL) croak ("aug_ls: %s", guestfs_last_error (g)); - } for (n = 0; matches[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -820,9 +799,8 @@ PREINIT: int existsflag; CODE: existsflag = guestfs_exists (g, path); - if (existsflag == -1) { + if (existsflag == -1) croak ("exists: %s", guestfs_last_error (g)); - } RETVAL = newSViv (existsflag); OUTPUT: RETVAL @@ -835,9 +813,8 @@ PREINIT: int fileflag; CODE: fileflag = guestfs_is_file (g, path); - if (fileflag == -1) { + if (fileflag == -1) croak ("is_file: %s", guestfs_last_error (g)); - } RETVAL = newSViv (fileflag); OUTPUT: RETVAL @@ -850,9 +827,8 @@ PREINIT: int dirflag; CODE: dirflag = guestfs_is_dir (g, path); - if (dirflag == -1) { + if (dirflag == -1) croak ("is_dir: %s", guestfs_last_error (g)); - } RETVAL = newSViv (dirflag); OUTPUT: RETVAL @@ -954,9 +930,8 @@ PREINIT: int i, n; PPCODE: devices = guestfs_mounts (g); - if (devices == NULL) { + if (devices == NULL) croak ("mounts: %s", guestfs_last_error (g)); - } for (n = 0; devices[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -993,9 +968,8 @@ PREINIT: char *description; CODE: description = guestfs_file (g, path); - if (description == NULL) { + if (description == NULL) croak ("file: %s", guestfs_last_error (g)); - } RETVAL = newSVpv (description, 0); free (description); OUTPUT: @@ -1010,9 +984,8 @@ PREINIT: CODE: output = guestfs_command (g, arguments); free (arguments); - if (output == NULL) { + if (output == NULL) croak ("command: %s", guestfs_last_error (g)); - } RETVAL = newSVpv (output, 0); free (output); OUTPUT: @@ -1028,9 +1001,8 @@ PREINIT: PPCODE: lines = guestfs_command_lines (g, arguments); free (arguments); - if (lines == NULL) { + if (lines == NULL) croak ("command_lines: %s", guestfs_last_error (g)); - } for (n = 0; lines[n] != NULL; ++n) /**/; EXTEND (SP, n); for (i = 0; i < n; ++i) { @@ -1039,3 +1011,98 @@ PREINIT: } free (lines); +void +stat (g, path) + guestfs_h *g; + char *path; +PREINIT: + struct guestfs_stat *statbuf; + PPCODE: + statbuf = guestfs_stat (g, path); + if (statbuf == NULL) + croak ("stat: %s", guestfs_last_error (g)); + EXTEND (SP, 13); + PUSHs (sv_2mortal (my_newSVll (statbuf->dev))); + PUSHs (sv_2mortal (my_newSVll (statbuf->ino))); + PUSHs (sv_2mortal (my_newSVll (statbuf->mode))); + PUSHs (sv_2mortal (my_newSVll (statbuf->nlink))); + PUSHs (sv_2mortal (my_newSVll (statbuf->uid))); + PUSHs (sv_2mortal (my_newSVll (statbuf->gid))); + PUSHs (sv_2mortal (my_newSVll (statbuf->rdev))); + PUSHs (sv_2mortal (my_newSVll (statbuf->size))); + PUSHs (sv_2mortal (my_newSVll (statbuf->blksize))); + PUSHs (sv_2mortal (my_newSVll (statbuf->blocks))); + PUSHs (sv_2mortal (my_newSVll (statbuf->atime))); + PUSHs (sv_2mortal (my_newSVll (statbuf->mtime))); + PUSHs (sv_2mortal (my_newSVll (statbuf->ctime))); + free (statbuf); + +void +lstat (g, path) + guestfs_h *g; + char *path; +PREINIT: + struct guestfs_stat *statbuf; + PPCODE: + statbuf = guestfs_lstat (g, path); + if (statbuf == NULL) + croak ("lstat: %s", guestfs_last_error (g)); + EXTEND (SP, 13); + PUSHs (sv_2mortal (my_newSVll (statbuf->dev))); + PUSHs (sv_2mortal (my_newSVll (statbuf->ino))); + PUSHs (sv_2mortal (my_newSVll (statbuf->mode))); + PUSHs (sv_2mortal (my_newSVll (statbuf->nlink))); + PUSHs (sv_2mortal (my_newSVll (statbuf->uid))); + PUSHs (sv_2mortal (my_newSVll (statbuf->gid))); + PUSHs (sv_2mortal (my_newSVll (statbuf->rdev))); + PUSHs (sv_2mortal (my_newSVll (statbuf->size))); + PUSHs (sv_2mortal (my_newSVll (statbuf->blksize))); + PUSHs (sv_2mortal (my_newSVll (statbuf->blocks))); + PUSHs (sv_2mortal (my_newSVll (statbuf->atime))); + PUSHs (sv_2mortal (my_newSVll (statbuf->mtime))); + PUSHs (sv_2mortal (my_newSVll (statbuf->ctime))); + free (statbuf); + +void +statvfs (g, path) + guestfs_h *g; + char *path; +PREINIT: + struct guestfs_statvfs *statbuf; + PPCODE: + statbuf = guestfs_statvfs (g, path); + if (statbuf == NULL) + croak ("statvfs: %s", guestfs_last_error (g)); + EXTEND (SP, 11); + PUSHs (sv_2mortal (my_newSVll (statbuf->bsize))); + PUSHs (sv_2mortal (my_newSVll (statbuf->frsize))); + PUSHs (sv_2mortal (my_newSVll (statbuf->blocks))); + PUSHs (sv_2mortal (my_newSVll (statbuf->bfree))); + PUSHs (sv_2mortal (my_newSVll (statbuf->bavail))); + PUSHs (sv_2mortal (my_newSVll (statbuf->files))); + PUSHs (sv_2mortal (my_newSVll (statbuf->ffree))); + PUSHs (sv_2mortal (my_newSVll (statbuf->favail))); + PUSHs (sv_2mortal (my_newSVll (statbuf->fsid))); + PUSHs (sv_2mortal (my_newSVll (statbuf->flag))); + PUSHs (sv_2mortal (my_newSVll (statbuf->namemax))); + free (statbuf); + +void +tune2fs_l (g, device) + guestfs_h *g; + char *device; +PREINIT: + char **superblock; + int i, n; + PPCODE: + superblock = guestfs_tune2fs_l (g, device); + if (superblock == NULL) + croak ("tune2fs_l: %s", guestfs_last_error (g)); + for (n = 0; superblock[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (superblock[i], 0))); + free (superblock[i]); + } + free (superblock); +