From 592c960c15a368e347f967843bebeddff50560ed Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 22 Feb 2017 14:49:43 +0000 Subject: [PATCH] mllib: Add unsetenv(3) binding to Unix_utils. Missing from the OCaml stdlib. This implementation is the same as the one in Jane St's Core, except we don't bother to throw an exception on error. --- mllib/unix_utils-c.c | 9 +++++++++ mllib/unix_utils.ml | 4 ++++ mllib/unix_utils.mli | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/mllib/unix_utils-c.c b/mllib/unix_utils-c.c index f9615ec3f..1a4c3d719 100644 --- a/mllib/unix_utils-c.c +++ b/mllib/unix_utils-c.c @@ -45,6 +45,7 @@ extern void unix_error (int errcode, char * cmdname, value arg) Noreturn; extern value guestfs_int_mllib_dev_t_makedev (value majv, value minv); extern value guestfs_int_mllib_dev_t_major (value devv); extern value guestfs_int_mllib_dev_t_minor (value devv); +extern value guestfs_int_mllib_unsetenv (value strv); extern int guestfs_int_mllib_exit (value rv) __attribute__((noreturn)); extern value guestfs_int_mllib_fnmatch (value patternv, value strv, value flagsv); extern value guestfs_int_mllib_sync (value unitv); @@ -73,6 +74,14 @@ guestfs_int_mllib_dev_t_minor (value devv) return Val_int (minor (Int_val (devv))); } +/* NB: This is a "noalloc" call. */ +value +guestfs_int_mllib_unsetenv (value strv) +{ + unsetenv (String_val (strv)); + return Val_unit; +} + /* NB: This is a "noalloc" call. */ int guestfs_int_mllib_exit (value rv) diff --git a/mllib/unix_utils.ml b/mllib/unix_utils.ml index aeb24ed27..66b6e4f4e 100644 --- a/mllib/unix_utils.ml +++ b/mllib/unix_utils.ml @@ -22,6 +22,10 @@ module Dev_t = struct external minor : int -> int = "guestfs_int_mllib_dev_t_minor" "noalloc" end +module Env = struct + external unsetenv : string -> unit = "guestfs_int_mllib_unsetenv" "noalloc" +end + module Exit = struct external _exit : int -> 'a = "guestfs_int_mllib_exit" "noalloc" end diff --git a/mllib/unix_utils.mli b/mllib/unix_utils.mli index be3eab800..0a4c1b3a9 100644 --- a/mllib/unix_utils.mli +++ b/mllib/unix_utils.mli @@ -32,6 +32,11 @@ module Dev_t : sig (** minor(3) *) end +module Env : sig + val unsetenv : string -> unit + (** Unset named environment variable, see unsetenv(3). *) +end + module Exit : sig val _exit : int -> 'a (** Call _exit directly, ie. do not run OCaml atexit handlers. *)