mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
mllib: Add a binding for realpath(3).
This is a copy of the supermin binding: https://github.com/libguestfs/supermin/tree/master/src realpath*
This commit is contained in:
@@ -57,6 +57,7 @@ extern value guestfs_int_mllib_fnmatch (value patternv, value strv, value flagsv
|
||||
extern value guestfs_int_mllib_sync (value unitv);
|
||||
extern value guestfs_int_mllib_fsync_file (value filenamev);
|
||||
extern value guestfs_int_mllib_mkdtemp (value val_pattern);
|
||||
extern value guestfs_int_mllib_realpath (value pathv);
|
||||
extern value guestfs_int_mllib_statvfs_free_space (value pathv);
|
||||
|
||||
/* NB: This is a "noalloc" call. */
|
||||
@@ -195,6 +196,22 @@ guestfs_int_mllib_mkdtemp (value val_pattern)
|
||||
CAMLreturn (rv);
|
||||
}
|
||||
|
||||
value
|
||||
guestfs_int_mllib_realpath (value pathv)
|
||||
{
|
||||
CAMLparam1 (pathv);
|
||||
CAMLlocal1 (rv);
|
||||
char *r;
|
||||
|
||||
r = realpath (String_val (pathv), NULL);
|
||||
if (r == NULL)
|
||||
unix_error (errno, (char *) "realpath", pathv);
|
||||
|
||||
rv = caml_copy_string (r);
|
||||
free (r);
|
||||
CAMLreturn (rv);
|
||||
}
|
||||
|
||||
value
|
||||
guestfs_int_mllib_statvfs_free_space (value pathv)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,10 @@ module Mkdtemp = struct
|
||||
mkdtemp (Filename.concat base_dir (prefix ^ "XXXXXX" ^ suffix))
|
||||
end
|
||||
|
||||
module Realpath = struct
|
||||
external realpath : string -> string = "guestfs_int_mllib_realpath"
|
||||
end
|
||||
|
||||
module StatVFS = struct
|
||||
external free_space : string -> int64 =
|
||||
"guestfs_int_mllib_statvfs_free_space"
|
||||
|
||||
@@ -88,6 +88,11 @@ module Mkdtemp : sig
|
||||
[Filename.temp_dir_name] is used. *)
|
||||
end
|
||||
|
||||
module Realpath : sig
|
||||
val realpath : string -> string
|
||||
(** [realpath(3)] returns the canonicalized absolute pathname. *)
|
||||
end
|
||||
|
||||
module StatVFS : sig
|
||||
val free_space : string -> int64
|
||||
(** [free_space path] returns the free space available on the
|
||||
|
||||
Reference in New Issue
Block a user