summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rw-r--r--perl/Guestfs.xs126
-rw-r--r--perl/lib/Sys/Guestfs.pm79
2 files changed, 205 insertions, 0 deletions
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<path> to C<value>.
+=item $h->blockdev_flushbufs ($device);
+
+This tells the kernel to flush internal buffers associated
+with C<device>.
+
+This uses the L<blockdev(8)> command.
+
+=item $blocksize = $h->blockdev_getbsz ($device);
+
+This returns the block size of a device.
+
+(Note this is different from both I<size in blocks> and
+I<filesystem block size>).
+
+This uses the L<blockdev(8)> 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<blockdev(8)> command.
+
+=item $sizeinbytes = $h->blockdev_getsize64 ($device);
+
+This returns the size of the device in bytes.
+
+See also C<$h-E<gt>blockdev_getsz>.
+
+This uses the L<blockdev(8)> 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-E<gt>blockdev_getsz>
+for that).
+
+This uses the L<blockdev(8)> 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-E<gt>blockdev_getss> for the real sector size of
+the device, and C<$h-E<gt>blockdev_getsize64> for the more
+useful I<size in bytes>.
+
+This uses the L<blockdev(8)> command.
+
+=item $h->blockdev_rereadpt ($device);
+
+Reread the partition table on C<device>.
+
+This uses the L<blockdev(8)> command.
+
+=item $h->blockdev_setbsz ($device, $blocksize);
+
+This sets the block size of a device.
+
+(Note this is different from both I<size in blocks> and
+I<filesystem block size>).
+
+This uses the L<blockdev(8)> command.
+
+=item $h->blockdev_setro ($device);
+
+Sets the block device named C<device> to read-only.
+
+This uses the L<blockdev(8)> command.
+
+=item $h->blockdev_setrw ($device);
+
+Sets the block device named C<device> to read-write.
+
+This uses the L<blockdev(8)> command.
+
=item $content = $h->cat ($path);
Return the contents of the file named C<path>.