Skip to content

Commit 8f5e516

Browse files
committed
Remove sync_file_range()
After hearing horror stories from a trusted colleague, I don't think this is the kind of API we want to be supporting. Also SQLite wisdom regarding fdatasync() has been added to the documentation.
1 parent 8318d67 commit 8f5e516

14 files changed

+8
-65
lines changed

libc/calls/calls.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ int setresuid(unsigned, unsigned, unsigned);
201201
int getresgid(unsigned *, unsigned *, unsigned *);
202202
int getresuid(unsigned *, unsigned *, unsigned *);
203203
char *get_current_dir_name(void) __wur;
204-
int sync_file_range(int, int64_t, int64_t, unsigned);
205204
ssize_t splice(int, int64_t *, int, int64_t *, size_t, unsigned);
206205
int memfd_create(const char *, unsigned int);
207206
int execvpe(const char *, char *const[], char *const[]);

libc/calls/fdatasync.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
/**
3030
* Blocks until kernel flushes non-metadata buffers for fd to disk.
3131
*
32+
* NOTE: For `IsXnu()` it's recommended that `fcntl(F_FULLFSYNC)` be
33+
* favored instead of this function, and if that fails, the fallback
34+
* path should call `fsync()` see the SQLite codebase. In the future
35+
* Cosmopolitan might do this automatically.
36+
*
3237
* @return 0 on success, or -1 w/ errno
3338
* @raise ECANCELED if thread was cancelled in masked mode
3439
* @raise EROFS if `fd` is on a read-only filesystem e.g. /zip
@@ -37,8 +42,8 @@
3742
* @raise EBADF if `fd` isn't an open file
3843
* @raise EINTR if signal was delivered
3944
* @raise EIO if an i/o error happened
40-
* @see sync(), fsync(), sync_file_range()
4145
* @see __nosync to secretly disable
46+
* @see sync(), fsync()
4247
* @cancelationpoint
4348
* @asyncsignalsafe
4449
*/

libc/calls/fsync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
* @raise EBADF if `fd` isn't an open file
3838
* @raise EINTR if signal was delivered
3939
* @raise EIO if an i/o error happened
40-
* @see fdatasync(), sync_file_range()
4140
* @see __nosync to secretly disable
41+
* @see fdatasync()
4242
* @cancelationpoint
4343
* @asyncsignalsafe
4444
*/

libc/calls/sync_file_range.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

libc/calls/syscall-sysv.internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ i32 sys_sigaction(i32, const void *, void *, i64, i64);
108108
i32 sys_sigaltstack(const void *, void *);
109109
i32 sys_symlinkat(const char *, i32, const char *);
110110
i32 sys_sync(void);
111-
i32 sys_sync_file_range(i32, i64, i64, u32);
112111
i32 sys_syncfs(i32);
113112
i32 sys_syslog(i32, char *, i32);
114113
i32 sys_tgkill(i32, i32, i32);

libc/dlopen/dlopen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "libc/errno.h"
3636
#include "libc/fmt/itoa.h"
3737
#include "libc/intrin/bits.h"
38+
#include "libc/intrin/kprintf.h"
3839
#include "libc/intrin/strace.internal.h"
3940
#include "libc/limits.h"
4041
#include "libc/nt/dll.h"

libc/sysv/calls/sys_sync_file_range.S

Lines changed: 0 additions & 2 deletions
This file was deleted.

libc/sysv/consts.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,10 +1461,6 @@ syscon misc EFD_CLOEXEC 0x080000 0x080000 0 0 0 0 0 0
14611461
syscon misc EFD_NONBLOCK 0x0800 0x0800 0 0 0 0 0 0
14621462
syscon misc EFD_SEMAPHORE 1 1 0 0 0 0 0 0
14631463

1464-
syscon misc SYNC_FILE_RANGE_WAIT_AFTER 4 4 0 0 0 0 0 0
1465-
syscon misc SYNC_FILE_RANGE_WAIT_BEFORE 1 1 0 0 0 0 0 0
1466-
syscon misc SYNC_FILE_RANGE_WRITE 2 2 0 0 0 0 0 0
1467-
14681464
syscon misc TEST_UNIT_READY 0 0 0 0 0 0 0 0
14691465
syscon misc TFD_CLOEXEC 0x080000 0x080000 0 0 0 0 0 0
14701466
syscon misc TFD_NONBLOCK 0x0800 0x0800 0 0 0 0 0 0
@@ -1807,7 +1803,6 @@ syscon nr __NR_faccessat 0x010d 0x0030 0x20001d2 0x01d2 0x01e9 0x013
18071803
syscon nr __NR_unshare 0x0110 0x0061 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
18081804
syscon nr __NR_splice 0x0113 0x004c 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
18091805
syscon nr __NR_tee 0x0114 0x004d 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
1810-
syscon nr __NR_sync_file_range 0x0115 0x0054 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
18111806
syscon nr __NR_vmsplice 0x0116 0x004b 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
18121807
syscon nr __NR_migrate_pages 0x0100 0x00ee 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff
18131808
syscon nr __NR_move_pages 0x0117 0x00ef 0xfff 0xfff 0xfff 0xfff 0xfff 0xfff

libc/sysv/consts/SYNC_FILE_RANGE_WAIT_AFTER.S

Lines changed: 0 additions & 2 deletions
This file was deleted.

libc/sysv/consts/SYNC_FILE_RANGE_WAIT_BEFORE.S

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)