diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-05-15 14:01:28 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-05-15 14:52:34 +0100 |
commit | 5cd39c83e23eb300d1bdfa806902a31b409ff420 (patch) | |
tree | a47e2bf9afc16cb9404ae996f512a9d3f22e553b /ocaml | |
parent | b8e5f51c79f539a740827506cc9da3ffcb6c87f8 (diff) | |
download | libguestfs-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 'ocaml')
-rw-r--r-- | ocaml/guestfs.ml | 5 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 15 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 130 |
3 files changed, 150 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 3886022d..d50b2d8c 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -236,3 +236,8 @@ external strings : t -> string -> string array = "ocaml_guestfs_strings" external strings_e : t -> string -> string -> string array = "ocaml_guestfs_strings_e" external hexdump : t -> string -> string = "ocaml_guestfs_hexdump" external zerofree : t -> string -> unit = "ocaml_guestfs_zerofree" +external pvresize : t -> string -> unit = "ocaml_guestfs_pvresize" +external sfdisk_N : t -> string -> int -> int -> int -> int -> string -> unit = "ocaml_guestfs_sfdisk_N_byte" "ocaml_guestfs_sfdisk_N" +external sfdisk_l : t -> string -> string = "ocaml_guestfs_sfdisk_l" +external sfdisk_kernel_geometry : t -> string -> string = "ocaml_guestfs_sfdisk_kernel_geometry" +external sfdisk_disk_geometry : t -> string -> string = "ocaml_guestfs_sfdisk_disk_geometry" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 3776abe7..358a6d30 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -487,3 +487,18 @@ val hexdump : t -> string -> string val zerofree : t -> string -> unit (** zero unused inodes and disk blocks on ext2/3 filesystem *) +val pvresize : t -> string -> unit +(** resize an LVM physical volume *) + +val sfdisk_N : t -> string -> int -> int -> int -> int -> string -> unit +(** modify a single partition on a block device *) + +val sfdisk_l : t -> string -> string +(** display the partition table *) + +val sfdisk_kernel_geometry : t -> string -> string +(** display the kernel geometry *) + +val sfdisk_disk_geometry : t -> string -> string +(** display the disk geometry from the partition table *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 79a5c16f..f2d13b03 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -3201,3 +3201,133 @@ ocaml_guestfs_zerofree (value gv, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_pvresize (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("pvresize: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_pvresize (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "pvresize"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_N (value gv, value devicev, value nv, value cylsv, value headsv, value sectorsv, value linev) +{ + CAMLparam5 (gv, devicev, nv, cylsv, headsv); + CAMLxparam2 (sectorsv, linev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_N: used handle after closing it"); + + const char *device = String_val (devicev); + int n = Int_val (nv); + int cyls = Int_val (cylsv); + int heads = Int_val (headsv); + int sectors = Int_val (sectorsv); + const char *line = String_val (linev); + int r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "sfdisk_N"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_N_byte (value *argv, int argn) +{ + return ocaml_guestfs_sfdisk_N (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); +} + +CAMLprim value +ocaml_guestfs_sfdisk_l (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_l: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_l (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "sfdisk_l"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_kernel_geometry (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_kernel_geometry: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_kernel_geometry (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "sfdisk_kernel_geometry"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_disk_geometry (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_disk_geometry: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_disk_geometry (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "sfdisk_disk_geometry"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + |