|Anonymous | Login | Signup for a new account||2018-10-17 02:28 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0002533||OCaml||otherlibs||public||2004-04-30 17:00||2018-07-31 13:41|
|Target Version||Fixed in Version|
|Summary||0002533: Feature wish: Unix.fsync, etc.|
having to write a very filesystem-oriented system, I am in need of system
calls for synchronizing the in-core state of files and directories with
that on disk.
It would be nice to see the following easily implementable system calls
in the Unix-module (currently I'm working with extensions):
val fsync : file_descr -> unit
val fdatasync : file_descr -> unit
val dirfd : dir_handle -> file_descr
The last function (BSD, the other two are POSIX.1b) is needed, because
synchronizing data with fdatasync (and also metadata + data with fsync)
does not synchronize the directory entries as such. For this it is
necessary to extract the file descriptor from the directory stream and
explicitly call fsync on it.
If there are reasons not to exhibit the file_descr associated with a
dir_handle, a function "val dir_sync : dir_handle -> unit" would also
be a possibility.
It may be too inefficient to open files with every write being
synchronized (O_SYNC, etc.). Sometimes I even only want the directory
to be synchronized, not the data.
Markus Mottl http://www.oefai.at/~markus [^] email@example.com
This has been around for a really long time. I think at least the following POSIX system calls concerning syncing should be supported: sync and fsync. They are available on virtually every Unix system and indispensable for applications that need persistence guarantees.
Note that fdatasync is not supported on FreeBSD and Mac OS X.
|fsync(2) is also more relaxed on MacOS X; it needs the F_FULLFSYNC fcntl to ensure it actually hits the disk in-order.|
|Markus, do you have a pre-existing patch for this (or could you construct one) which could be looked at?|
Yes, just take a look at our Core-library, file "unix_ext_stubs.c". It contains a function "unix_fsync" that can surely be taken verbatim.
There are several other functions there that could probably be added to the OCaml distribution immediately, because they are well-standardized in POSIX and do not require elaborate API additions (types, etc.). E.g. pselect, abort, sync.
Some of the others are also well-standardized, but would need extra types, etc. I'm not sure what the OCaml team's preferred procedure for adding those would be.
|Damien, do you have an opinion on adding these? (I'm just asking given what you said about Set.map ...)|
I'm also surprised today by the lack of fsync in the stdlib's Unix module...
adding an external dependency to a project just for that looks insane
CAMLprim value unix_fsync(value v_fd)
ret = fsync(Int_val(v_fd));
if (ret == -1) uerror("fsync", Nothing);
|the corresponding PR on github has been merged, so this issue can probably be closed|
|The PR only implements the fsync call, there seem to be others that are important by the previous discussion. But since this issue has been open for 14 years, I will go ahead and close it. If needed a new one can be opened for the other functions.|
|2005-11-18 10:13||administrator||New Issue|
|2010-02-25 19:24||mottl||Note Added: 0005252|
|2010-03-20 21:19||avsm||Note Added: 0005270|
|2010-03-30 13:01||shinwell||Note Added: 0005277|
|2010-03-30 13:02||shinwell||Status||acknowledged => assigned|
|2010-03-30 13:02||shinwell||Assigned To||=> shinwell|
|2010-03-30 16:21||mottl||Note Added: 0005281|
|2013-08-30 23:27||doligez||Tag Attached: patch|
|2014-05-30 14:27||shinwell||Note Added: 0011597|
|2014-05-30 14:27||shinwell||Assigned To||shinwell => doligez|
|2016-12-07 16:15||shinwell||Category||OCaml general => OCaml otherlibs|
|2016-12-07 16:15||shinwell||Description Updated||View Revisions|
|2017-02-23 16:42||doligez||Category||OCaml otherlibs => otherlibs|
|2018-06-15 08:51||berenger||Note Added: 0019193|
|2018-06-15 08:55||berenger||Note Added: 0019194|
|2018-06-15 09:23||berenger||Note Added: 0019195|
|2018-07-31 09:15||berenger||Note Added: 0019284|
|2018-07-31 13:41||nojebar||Note Added: 0019288|
|2018-07-31 13:41||nojebar||Status||assigned => resolved|
|2018-07-31 13:41||nojebar||Resolution||open => fixed|
|Copyright © 2000 - 2011 MantisBT Group|