File: unix_utils.mli

package info (click to toggle)
libguestfs 1%3A1.40.2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,660 kB
  • sloc: ansic: 460,074; ml: 63,059; sh: 14,955; java: 9,512; makefile: 9,133; cs: 6,300; haskell: 5,652; python: 3,856; perl: 3,619; erlang: 2,435; xml: 1,683; ruby: 350; pascal: 255; lex: 135; yacc: 128; cpp: 10
file content (123 lines) | stat: -rw-r--r-- 4,108 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
(* mllib
 * Copyright (C) 2009-2019 Red Hat Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *)

(** Binding for various Unix/POSIX library functions which are not
    provided by the OCaml stdlib. *)

module Dev_t : sig
  (** Bindings for [dev_t] related functions [makedev], [major] and [minor]. *)

  val makedev : int -> int -> int
  (** makedev(3) *)

  val major : int -> int
  (** major(3) *)

  val minor : int -> int
  (** 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. *)
end

module Fnmatch : sig
  (** Binding for the fnmatch(3) function in glibc or gnulib. *)

  type flag =
    | FNM_NOESCAPE
    | FNM_PATHNAME
    | FNM_PERIOD
    | FNM_FILE_NAME
    | FNM_LEADING_DIR
    | FNM_CASEFOLD
  (** Flags passed to the fnmatch function. *)

  val fnmatch : string -> string -> flag list -> bool
  (** The [fnmatch pattern filename flags] function checks whether
      the [filename] argument matches the wildcard in the [pattern]
      argument.  The [flags] is a list of flags.  Consult the
      fnmatch(3) man page for details of the flags.

      The [filename] might be a filename element or a full path
      (depending on the pattern and flags). *)
end

module Fsync : sig
  (** Bindings for sync, fsync. *)

  val sync : unit -> unit
  (** sync(2) syscall. *)

  val file : string -> unit
  (** fsync a single file by name. *)
end

module Mkdtemp : sig
  (** Functions to create temporary directories. *)

  val mkdtemp : string -> string
  (** [mkdtemp pattern] Tiny wrapper to the C [mkdtemp]. *)

  val temp_dir : ?base_dir:string -> string -> string
  (** [temp_dir prefix] creates a new unique temporary directory.

      The optional [~base_dir:string] changes the base directory where
      to create the new temporary directory; if not specified, the default
      {!Filename.get_temp_dir_name} is used. *)
end

module Realpath : sig
  val realpath : string -> string
  (** [realpath(3)] returns the canonicalized absolute pathname. *)
end

module StatVFS : sig
  type statvfs = {
    f_bsize : int64;            (** Filesystem block size *)
    f_frsize : int64;           (** Fragment size *)
    f_blocks : int64;           (** Size of fs in f_frsize units *)
    f_bfree : int64;            (** Number of free blocks *)
    f_bavail : int64;           (** Number of free blocks for non-root *)
    f_files : int64;            (** Number of inodes *)
    f_ffree : int64;            (** Number of free inodes *)
    f_favail : int64;           (** Number of free inodes for non-root *)
    f_fsid : int64;             (** Filesystem ID *)
    f_flag : int64;             (** Mount flags *)
    f_namemax : int64;          (** Maximum length of filenames *)
  }
  val statvfs : string -> statvfs
  (** This calls [statvfs(3)] on the path parameter.

      In case of non-Linux or non-POSIX, this call is emulated as best
      we can with missing fields returned as [-1]. *)

  val free_space : statvfs -> int64
  (** [free_space (statvfs path)] returns the free space available on the
      filesystem that contains [path], in bytes. *)

  val is_network_filesystem : string -> bool
  (** [is_network_filesystem path] returns true if [path] is located on
      a network filesystem such as NFS or CIFS. *)
end