From b348eacbc4d84337856cf7cca518d61c63e92631 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 15 Apr 2009 17:48:54 +0100 Subject: Generated code for blockdev_* calls, RInt64, enhanced tests. --- perl/Guestfs.xs | 126 ++++++++++++++++++++++++++++++++++++++++++++++++ perl/lib/Sys/Guestfs.pm | 79 ++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) (limited to 'perl') diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index 93abd9ec..beb1c997 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -1106,3 +1106,129 @@ PREINIT: } free (superblock); +void +blockdev_setro (g, device) + guestfs_h *g; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_blockdev_setro (g, device); + if (r == -1) + croak ("blockdev_setro: %s", guestfs_last_error (g)); + +void +blockdev_setrw (g, device) + guestfs_h *g; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + croak ("blockdev_setrw: %s", guestfs_last_error (g)); + +SV * +blockdev_getro (g, device) + guestfs_h *g; + char *device; +PREINIT: + int ro; + CODE: + ro = guestfs_blockdev_getro (g, device); + if (ro == -1) + croak ("blockdev_getro: %s", guestfs_last_error (g)); + RETVAL = newSViv (ro); + OUTPUT: + RETVAL + +SV * +blockdev_getss (g, device) + guestfs_h *g; + char *device; +PREINIT: + int sectorsize; + CODE: + sectorsize = guestfs_blockdev_getss (g, device); + if (sectorsize == -1) + croak ("blockdev_getss: %s", guestfs_last_error (g)); + RETVAL = newSViv (sectorsize); + OUTPUT: + RETVAL + +SV * +blockdev_getbsz (g, device) + guestfs_h *g; + char *device; +PREINIT: + int blocksize; + CODE: + blocksize = guestfs_blockdev_getbsz (g, device); + if (blocksize == -1) + croak ("blockdev_getbsz: %s", guestfs_last_error (g)); + RETVAL = newSViv (blocksize); + OUTPUT: + RETVAL + +void +blockdev_setbsz (g, device, blocksize) + guestfs_h *g; + char *device; + int blocksize; +PREINIT: + int r; + PPCODE: + r = guestfs_blockdev_setbsz (g, device, blocksize); + if (r == -1) + croak ("blockdev_setbsz: %s", guestfs_last_error (g)); + +SV * +blockdev_getsz (g, device) + guestfs_h *g; + char *device; +PREINIT: + int64_t sizeinsectors; + CODE: + sizeinsectors = guestfs_blockdev_getsz (g, device); + if (sizeinsectors == -1) + croak ("blockdev_getsz: %s", guestfs_last_error (g)); + RETVAL = my_newSVll (sizeinsectors); + OUTPUT: + RETVAL + +SV * +blockdev_getsize64 (g, device) + guestfs_h *g; + char *device; +PREINIT: + int64_t sizeinbytes; + CODE: + sizeinbytes = guestfs_blockdev_getsize64 (g, device); + if (sizeinbytes == -1) + croak ("blockdev_getsize64: %s", guestfs_last_error (g)); + RETVAL = my_newSVll (sizeinbytes); + OUTPUT: + RETVAL + +void +blockdev_flushbufs (g, device) + guestfs_h *g; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_blockdev_flushbufs (g, device); + if (r == -1) + croak ("blockdev_flushbufs: %s", guestfs_last_error (g)); + +void +blockdev_rereadpt (g, device) + guestfs_h *g; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_blockdev_rereadpt (g, device); + if (r == -1) + croak ("blockdev_rereadpt: %s", guestfs_last_error (g)); + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 36bedd5e..a351d574 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -245,6 +245,85 @@ how files are saved. Set the value associated with C to C. +=item $h->blockdev_flushbufs ($device); + +This tells the kernel to flush internal buffers associated +with C. + +This uses the L command. + +=item $blocksize = $h->blockdev_getbsz ($device); + +This returns the block size of a device. + +(Note this is different from both I and +I). + +This uses the L command. + +=item $ro = $h->blockdev_getro ($device); + +Returns a boolean indicating if the block device is read-only +(true if read-only, false if not). + +This uses the L command. + +=item $sizeinbytes = $h->blockdev_getsize64 ($device); + +This returns the size of the device in bytes. + +See also C<$h-Eblockdev_getsz>. + +This uses the L command. + +=item $sectorsize = $h->blockdev_getss ($device); + +This returns the size of sectors on a block device. +Usually 512, but can be larger for modern devices. + +(Note, this is not the size in sectors, use C<$h-Eblockdev_getsz> +for that). + +This uses the L command. + +=item $sizeinsectors = $h->blockdev_getsz ($device); + +This returns the size of the device in units of 512-byte sectors +(even if the sectorsize isn't 512 bytes ... weird). + +See also C<$h-Eblockdev_getss> for the real sector size of +the device, and C<$h-Eblockdev_getsize64> for the more +useful I. + +This uses the L command. + +=item $h->blockdev_rereadpt ($device); + +Reread the partition table on C. + +This uses the L command. + +=item $h->blockdev_setbsz ($device, $blocksize); + +This sets the block size of a device. + +(Note this is different from both I and +I). + +This uses the L command. + +=item $h->blockdev_setro ($device); + +Sets the block device named C to read-only. + +This uses the L command. + +=item $h->blockdev_setrw ($device); + +Sets the block device named C to read-write. + +This uses the L command. + =item $content = $h->cat ($path); Return the contents of the file named C. -- cgit