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
23 applejack@users.sf.net
29 #include <caml/mlvalues.h>
30 #include <caml/memory.h>
31 #include <caml/alloc.h>
32 #include <caml/fail.h>
33 #include <caml/callback.h>
35 #include <caml/custom.h>
36 #include <caml/bigarray.h>
38 #include <caml/camlidlruntime.h>
40 int c2ml_unix_error(int c_err
);
42 value
unix_util_read(value fd
,value buf
)
44 value vres
=alloc(1,1); /* Ok result */
46 enter_blocking_section();
47 res
= read(Int_val(fd
), /* TODO: unsafe coercion */
48 Bigarray_val(buf
)->data
,Bigarray_val(buf
)->dim
[0]);
49 leave_blocking_section();
50 if (res
>=0) Field(vres
,0)=Val_int(res
);
53 Tag_val(vres
)=0; /* Bad result */
54 Field(vres
,0)=Val_int(c2ml_unix_error(res
)); /* TODO: EUNKNOWN x is a block */
59 value
unix_util_write(value fd
,value buf
)
61 value vres
=alloc(1,1); /* Ok result */
63 enter_blocking_section();
64 res
= write(Int_val(fd
), /* TODO: unsafe coercion */
65 Bigarray_val(buf
)->data
,Bigarray_val(buf
)->dim
[0]);
66 leave_blocking_section();
67 if (res
>=0) Field(vres
,0)=Val_int(res
);
70 Tag_val(vres
)=0; /* Bad result */
71 Field(vres
,0)=Val_int(c2ml_unix_error(res
)); /* TODO: EUNKNOWN x is a block */
76 value
unix_util_int_of_file_descr(value fd
)
78 return Val_int(Int_val(fd
) /* TODO: unsafe coercion */ );
81 value
unix_util_file_descr_of_int(value fd
)
83 return Val_int(Int_val(fd
) /* TODO: unsafe coercion */ );