Debian Codegraph @

io/+freebsd/sync.ha

raw
1 // SPDX-License-Identifier: MPL-2.0
2 // (c) Hare authors <https://harelang.org>
3
4 use errors;
5 use rt;
6
7 // Flushes all in-flight I/O for the given file descriptor to persistent
8 // storage, flushing any writes the kernel has cached, and any changes to the
9 // corresponding inode.
10 export fn fsync(fd: file) (void | error) = {
11 match (rt::fsync(fd)) {
12 case let err: rt::errno =>
13 return errors::errno(err);
14 case void =>
15 return;
16 };
17 };
18
19 // Flushes all in-flight I/O for the given file descriptor to persistent
20 // storage, flushing any writes the kernel has cached. Only persists changes to
21 // the associated inode if it is not required for the file contents to be
22 // successfully retrieved. If the file size has changed, for example, this will
23 // block until the inode is updated; but it would not block on an update to its
24 // mtime.
25 export fn fdatasync(fd: file) (void | error) = {
26 match (rt::fdatasync(fd)) {
27 case let err: rt::errno =>
28 return errors::errno(err);
29 case void =>
30 return;
31 };
32 };