diff options
| author | Richard Jones <rjones@redhat.com> | 2009-04-10 12:53:28 +0100 |
|---|---|---|
| committer | Richard Jones <rjones@redhat.com> | 2009-04-10 12:55:04 +0100 |
| commit | 286841877f4223d67ec00b83e5a2aabfbb9e19ed (patch) | |
| tree | 17ac4dec06100bc6d6396c1080fa5490e255e9b5 /ocaml | |
| parent | 44da812b424f5e10e268d47149d012d49edf858b (diff) | |
| download | libguestfs-286841877f4223d67ec00b83e5a2aabfbb9e19ed.tar.gz libguestfs-286841877f4223d67ec00b83e5a2aabfbb9e19ed.tar.xz libguestfs-286841877f4223d67ec00b83e5a2aabfbb9e19ed.zip | |
Generated files for previous commands.
Diffstat (limited to 'ocaml')
| -rw-r--r-- | ocaml/guestfs.ml | 7 | ||||
| -rw-r--r-- | ocaml/guestfs.mli | 21 | ||||
| -rw-r--r-- | ocaml/guestfs_c_actions.c | 164 |
3 files changed, 192 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index fba005f6..32a6b82a 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -125,3 +125,10 @@ external aug_match : t -> string -> string array = "ocaml_guestfs_aug_match" external aug_save : t -> unit = "ocaml_guestfs_aug_save" external aug_load : t -> unit = "ocaml_guestfs_aug_load" external aug_ls : t -> string -> string array = "ocaml_guestfs_aug_ls" +external rm : t -> string -> unit = "ocaml_guestfs_rm" +external rmdir : t -> string -> unit = "ocaml_guestfs_rmdir" +external rm_rf : t -> string -> unit = "ocaml_guestfs_rm_rf" +external mkdir : t -> string -> unit = "ocaml_guestfs_mkdir" +external mkdir_p : t -> string -> unit = "ocaml_guestfs_mkdir_p" +external chmod : t -> int -> string -> unit = "ocaml_guestfs_chmod" +external chown : t -> int -> int -> string -> unit = "ocaml_guestfs_chown" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 4981eb1e..ecf86f11 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -214,3 +214,24 @@ val aug_load : t -> unit val aug_ls : t -> string -> string array (** list Augeas nodes under a path *) +val rm : t -> string -> unit +(** remove a file *) + +val rmdir : t -> string -> unit +(** remove a directory *) + +val rm_rf : t -> string -> unit +(** remove a file or directory recursively *) + +val mkdir : t -> string -> unit +(** create a directory *) + +val mkdir_p : t -> string -> unit +(** create a directory and parents *) + +val chmod : t -> int -> string -> unit +(** change file mode *) + +val chown : t -> int -> int -> string -> unit +(** change file owner and group *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index f26226c0..6675cf8c 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -1183,3 +1183,167 @@ ocaml_guestfs_aug_ls (value gv, value pathv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_rm (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("rm: used handle after closing it"); + + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_rm (g, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "rm"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_rmdir (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("rmdir: used handle after closing it"); + + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_rmdir (g, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "rmdir"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_rm_rf (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("rm_rf: used handle after closing it"); + + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_rm_rf (g, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "rm_rf"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mkdir (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mkdir: used handle after closing it"); + + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_mkdir (g, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mkdir"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mkdir_p (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mkdir_p: used handle after closing it"); + + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_mkdir_p (g, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mkdir_p"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_chmod (value gv, value modev, value pathv) +{ + CAMLparam3 (gv, modev, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("chmod: used handle after closing it"); + + int mode = Int_val (modev); + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_chmod (g, mode, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "chmod"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_chown (value gv, value ownerv, value groupv, value pathv) +{ + CAMLparam4 (gv, ownerv, groupv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("chown: used handle after closing it"); + + int owner = Int_val (ownerv); + int group = Int_val (groupv); + const char *path = String_val (pathv); + int r; + + caml_enter_blocking_section (); + r = guestfs_chown (g, owner, group, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "chown"); + + rv = Val_unit; + CAMLreturn (rv); +} + |
