summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-05-15 14:01:28 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-05-15 14:52:34 +0100
commit5cd39c83e23eb300d1bdfa806902a31b409ff420 (patch)
treea47e2bf9afc16cb9404ae996f512a9d3f22e553b /perl
parentb8e5f51c79f539a740827506cc9da3ffcb6c87f8 (diff)
downloadlibguestfs-5cd39c83e23eb300d1bdfa806902a31b409ff420.tar.gz
libguestfs-5cd39c83e23eb300d1bdfa806902a31b409ff420.tar.xz
libguestfs-5cd39c83e23eb300d1bdfa806902a31b409ff420.zip
Add: pvresize, sfdisk-N, sfdisk-l, sfdisk-kernel-geomtry, sfdisk-disk-geometry commands. Pass --no-reread flag to sfdisk.
Diffstat (limited to 'perl')
-rw-r--r--perl/Guestfs.xs72
-rw-r--r--perl/lib/Sys/Guestfs.pm41
2 files changed, 113 insertions, 0 deletions
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index e87131bd..ff7ca9e1 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -1798,3 +1798,75 @@ PREINIT:
if (r == -1)
croak ("zerofree: %s", guestfs_last_error (g));
+void
+pvresize (g, device)
+ guestfs_h *g;
+ char *device;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_pvresize (g, device);
+ if (r == -1)
+ croak ("pvresize: %s", guestfs_last_error (g));
+
+void
+sfdisk_N (g, device, n, cyls, heads, sectors, line)
+ guestfs_h *g;
+ char *device;
+ int n;
+ int cyls;
+ int heads;
+ int sectors;
+ char *line;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line);
+ if (r == -1)
+ croak ("sfdisk_N: %s", guestfs_last_error (g));
+
+SV *
+sfdisk_l (g, device)
+ guestfs_h *g;
+ char *device;
+PREINIT:
+ char *partitions;
+ CODE:
+ partitions = guestfs_sfdisk_l (g, device);
+ if (partitions == NULL)
+ croak ("sfdisk_l: %s", guestfs_last_error (g));
+ RETVAL = newSVpv (partitions, 0);
+ free (partitions);
+ OUTPUT:
+ RETVAL
+
+SV *
+sfdisk_kernel_geometry (g, device)
+ guestfs_h *g;
+ char *device;
+PREINIT:
+ char *partitions;
+ CODE:
+ partitions = guestfs_sfdisk_kernel_geometry (g, device);
+ if (partitions == NULL)
+ croak ("sfdisk_kernel_geometry: %s", guestfs_last_error (g));
+ RETVAL = newSVpv (partitions, 0);
+ free (partitions);
+ OUTPUT:
+ RETVAL
+
+SV *
+sfdisk_disk_geometry (g, device)
+ guestfs_h *g;
+ char *device;
+PREINIT:
+ char *partitions;
+ CODE:
+ partitions = guestfs_sfdisk_disk_geometry (g, device);
+ if (partitions == NULL)
+ croak ("sfdisk_disk_geometry: %s", guestfs_last_error (g));
+ RETVAL = newSVpv (partitions, 0);
+ free (partitions);
+ OUTPUT:
+ RETVAL
+
diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm
index b11594f2..0249a412 100644
--- a/perl/lib/Sys/Guestfs.pm
+++ b/perl/lib/Sys/Guestfs.pm
@@ -840,6 +840,11 @@ The implementation uses the C<pvremove> command which refuses to
wipe physical volumes that contain any volume groups, so you have
to remove those first.
+=item $h->pvresize ($device);
+
+This resizes (expands or shrinks) an existing LVM physical
+volume to match the new size of the underlying device.
+
=item @physvols = $h->pvs ();
List all the physical volumes detected. This is the equivalent
@@ -985,9 +990,45 @@ To create a single partition occupying the whole disk, you would
pass C<lines> as a single element list, when the single element being
the string C<,> (comma).
+See also: C<$h-E<gt>sfdisk_l>, C<$h-E<gt>sfdisk_N>
+
+B<This command is dangerous. Without careful use you
+can easily destroy all your data>.
+
+=item $h->sfdisk_N ($device, $n, $cyls, $heads, $sectors, $line);
+
+This runs L<sfdisk(8)> option to modify just the single
+partition C<n> (note: C<n> counts from 1).
+
+For other parameters, see C<$h-E<gt>sfdisk>. You should usually
+pass C<0> for the cyls/heads/sectors parameters.
+
B<This command is dangerous. Without careful use you
can easily destroy all your data>.
+=item $partitions = $h->sfdisk_disk_geometry ($device);
+
+This displays the disk geometry of C<device> read from the
+partition table. Especially in the case where the underlying
+block device has been resized, this can be different from the
+kernel's idea of the geometry (see C<$h-E<gt>sfdisk_kernel_geometry>).
+
+The result is in human-readable format, and not designed to
+be parsed.
+
+=item $partitions = $h->sfdisk_kernel_geometry ($device);
+
+This displays the kernel's idea of the geometry of C<device>.
+
+The result is in human-readable format, and not designed to
+be parsed.
+
+=item $partitions = $h->sfdisk_l ($device);
+
+This displays the partition table on C<device>, in the
+human-readable output of the L<sfdisk(8)> command. It is
+not intended to be parsed.
+
=item %statbuf = $h->stat ($path);
Returns file information for the given C<path>.