Add test target for figfs_test.
[figfs.git] / fuse / Unix_util.ml
blob37f8fca66bfc253a7105319ad789275f70e2a815
1 (*
2 This file is part of the "OCamlFuse" library.
4 OCamlFuse is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation (version 2 of the License).
8 OCamlFuse is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with OCamlFuse. See the file LICENSE. If you haven't received
15 a copy of the GNU General Public License, write to:
17 Free Software Foundation, Inc.,
18 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA
21 Vincenzo Ciancia
23 applejack@users.sf.net
24 vincenzo_ml@yahoo.it
27 open Result
29 external read_noexn : Unix.file_descr -> (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int result = "unix_util_read"
30 external write_noexn : Unix.file_descr -> (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int result = "unix_util_write"
32 external int_of_file_descr : Unix.file_descr -> int = "unix_util_int_of_file_descr"
33 external file_descr_of_int : int -> Unix.file_descr = "unix_util_file_descr_of_int"
35 let read fd buf =
36 match read_noexn fd buf with
37 Ok res -> res
38 | Bad err -> raise (Unix.Unix_error (err,"read",""))
40 let write fd buf =
41 match write_noexn fd buf with
42 Ok res -> res
43 | Bad err -> raise (Unix.Unix_error (err,"read",""))