1use rustix::fd::BorrowedFd;
2
3use libc::{c_int, c_uint, off64_t};
4
5use crate::convert_res;
6
7#[no_mangle]
8unsafe extern "C" fn fsync(fd: c_int) -> c_int {
9 libc!(libc::fsync(fd));
10
11 match convert_res(rustix::fs::fsync(BorrowedFd::borrow_raw(fd))) {
12 Some(()) => 0,
13 None => -1,
14 }
15}
16
17#[no_mangle]
18unsafe extern "C" fn fdatasync(fd: c_int) -> c_int {
19 libc!(libc::fdatasync(fd));
20
21 match convert_res(rustix::fs::fdatasync(BorrowedFd::borrow_raw(fd))) {
22 Some(()) => 0,
23 None => -1,
24 }
25}
26
27#[no_mangle]
28unsafe extern "C" fn syncfs(fd: c_int) -> c_int {
29 libc!(libc::syncfs(fd));
30
31 match convert_res(rustix::fs::syncfs(BorrowedFd::borrow_raw(fd))) {
32 Some(()) => 0,
33 None => -1,
34 }
35}
36
37#[no_mangle]
38unsafe extern "C" fn sync() {
39 libc!(libc::sync());
40
41 rustix::fs::sync()
42}
43
44#[no_mangle]
45unsafe extern "C" fn sync_file_range(
46 fd: c_int,
47 offset: off64_t,
48 nbytes: off64_t,
49 flags: c_uint,
50) -> c_int {
51 libc!(libc::sync_file_range(fd, offset, nbytes, flags));
52
53 let fd = BorrowedFd::borrow_raw(fd);
54
55 match convert_res(rustix::fs::fdatasync(fd)) {
57 Some(()) => 0,
58 None => -1,
59 }
60}