Index: sys/amd64/linux/linux_dummy.c =================================================================== --- sys/amd64/linux/linux_dummy.c +++ sys/amd64/linux/linux_dummy.c @@ -99,7 +99,6 @@ DUMMY(unshare); /* Linux 2.6.17: */ DUMMY(splice); -DUMMY(sync_file_range); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ Index: sys/amd64/linux/linux_proto.h =================================================================== --- sys/amd64/linux/linux_proto.h +++ sys/amd64/linux/linux_proto.h @@ -940,7 +940,10 @@ register_t dummy; }; struct linux_sync_file_range_args { - register_t dummy; + char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t)]; l_loff_t offset; char offset_r_[PADR_(l_loff_t)]; + char nbytes_l_[PADL_(l_loff_t)]; l_loff_t nbytes; char nbytes_r_[PADR_(l_loff_t)]; + char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)]; }; struct linux_vmsplice_args { register_t dummy; Index: sys/amd64/linux/linux_sysent.c =================================================================== --- sys/amd64/linux/linux_sysent.c +++ sys/amd64/linux/linux_sysent.c @@ -294,7 +294,7 @@ { AS(linux_get_robust_list_args), (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 274 = linux_get_robust_list */ { 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 275 = linux_splice */ { 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 276 = linux_tee */ - { 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 277 = linux_sync_file_range */ + { AS(linux_sync_file_range_args), (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 277 = linux_sync_file_range */ { 0, (sy_call_t *)linux_vmsplice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 278 = linux_vmsplice */ { 0, (sy_call_t *)linux_move_pages, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 279 = linux_move_pages */ { AS(linux_utimensat_args), (sy_call_t *)linux_utimensat, AUE_FUTIMESAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 280 = linux_utimensat */ Index: sys/amd64/linux/linux_systrace_args.c =================================================================== --- sys/amd64/linux/linux_systrace_args.c +++ sys/amd64/linux/linux_systrace_args.c @@ -1977,7 +1977,12 @@ } /* linux_sync_file_range */ case 277: { - *n_args = 0; + struct linux_sync_file_range_args *p = params; + iarg[0] = p->fd; /* l_int */ + iarg[1] = p->offset; /* l_loff_t */ + iarg[2] = p->nbytes; /* l_loff_t */ + uarg[3] = p->flags; /* unsigned int */ + *n_args = 4; break; } /* linux_vmsplice */ @@ -5553,6 +5558,22 @@ break; /* linux_sync_file_range */ case 277: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_loff_t"; + break; + case 2: + p = "l_loff_t"; + break; + case 3: + p = "unsigned int"; + break; + default: + break; + }; break; /* linux_vmsplice */ case 278: @@ -7509,6 +7530,9 @@ case 276: /* linux_sync_file_range */ case 277: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_vmsplice */ case 278: /* linux_move_pages */ Index: sys/amd64/linux/syscalls.master =================================================================== --- sys/amd64/linux/syscalls.master +++ sys/amd64/linux/syscalls.master @@ -467,7 +467,8 @@ struct linux_robust_list_head **head, l_size_t *len); } 275 AUE_NULL STD { int linux_splice(void); } 276 AUE_NULL STD { int linux_tee(void); } -277 AUE_NULL STD { int linux_sync_file_range(void); } +277 AUE_NULL STD { int linux_sync_file_range(l_int fd, l_loff_t offset, + l_loff_t nbytes, unsigned int flags); } 278 AUE_NULL STD { int linux_vmsplice(void); } 279 AUE_NULL STD { int linux_move_pages(void); } 280 AUE_FUTIMESAT STD { int linux_utimensat(l_int dfd, const char *pathname, \ Index: sys/amd64/linux32/linux32_dummy.c =================================================================== --- sys/amd64/linux32/linux32_dummy.c +++ sys/amd64/linux32/linux32_dummy.c @@ -105,7 +105,6 @@ DUMMY(unshare); /* Linux 2.6.17: */ DUMMY(splice); -DUMMY(sync_file_range); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ Index: sys/amd64/linux32/linux32_proto.h =================================================================== --- sys/amd64/linux32/linux32_proto.h +++ sys/amd64/linux32/linux32_proto.h @@ -1020,7 +1020,10 @@ register_t dummy; }; struct linux_sync_file_range_args { - register_t dummy; + char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t)]; l_loff_t offset; char offset_r_[PADR_(l_loff_t)]; + char nbytes_l_[PADL_(l_loff_t)]; l_loff_t nbytes; char nbytes_r_[PADR_(l_loff_t)]; + char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)]; }; struct linux_tee_args { register_t dummy; Index: sys/amd64/linux32/linux32_sysent.c =================================================================== --- sys/amd64/linux32/linux32_sysent.c +++ sys/amd64/linux32/linux32_sysent.c @@ -331,7 +331,7 @@ { AS(linux_set_robust_list_args), (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 311 = linux_set_robust_list */ { AS(linux_get_robust_list_args), (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 312 = linux_get_robust_list */ { 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 313 = linux_splice */ - { 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 314 = linux_sync_file_range */ + { AS(linux_sync_file_range_args), (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 314 = linux_sync_file_range */ { 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 315 = linux_tee */ { 0, (sy_call_t *)linux_vmsplice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 316 = linux_vmsplice */ { 0, (sy_call_t *)linux_move_pages, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 317 = linux_move_pages */ Index: sys/amd64/linux32/linux32_systrace_args.c =================================================================== --- sys/amd64/linux32/linux32_systrace_args.c +++ sys/amd64/linux32/linux32_systrace_args.c @@ -2118,7 +2118,12 @@ } /* linux_sync_file_range */ case 314: { - *n_args = 0; + struct linux_sync_file_range_args *p = params; + iarg[0] = p->fd; /* l_int */ + iarg[1] = p->offset; /* l_loff_t */ + iarg[2] = p->nbytes; /* l_loff_t */ + uarg[3] = p->flags; /* unsigned int */ + *n_args = 4; break; } /* linux_tee */ @@ -6164,6 +6169,22 @@ break; /* linux_sync_file_range */ case 314: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_loff_t"; + break; + case 2: + p = "l_loff_t"; + break; + case 3: + p = "unsigned int"; + break; + default: + break; + }; break; /* linux_tee */ case 315: @@ -8654,6 +8675,9 @@ case 313: /* linux_sync_file_range */ case 314: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_tee */ case 315: /* linux_vmsplice */ Index: sys/amd64/linux32/syscalls.master =================================================================== --- sys/amd64/linux32/syscalls.master +++ sys/amd64/linux32/syscalls.master @@ -524,7 +524,8 @@ 312 AUE_NULL STD { int linux_get_robust_list(l_int pid, \ struct linux_robust_list_head **head, l_size_t *len); } 313 AUE_NULL STD { int linux_splice(void); } -314 AUE_NULL STD { int linux_sync_file_range(void); } +314 AUE_NULL STD { int linux_sync_file_range(l_int fd, l_loff_t offset, + l_loff_t nbytes, unsigned int flags); } 315 AUE_NULL STD { int linux_tee(void); } 316 AUE_NULL STD { int linux_vmsplice(void); } ; Linux 2.6.18: Index: sys/arm/linux/syscalls.master =================================================================== --- sys/arm/linux/syscalls.master +++ sys/arm/linux/syscalls.master @@ -1694,7 +1694,12 @@ int linux_splice(void); } 341 AUE_NULL STD { - int linux_sync_file_range(void); + int linux_sync_file_range( + l_int fd, + l_loff_t offset, + l_loff_t nbytes, + unsigned int flags + ); } 342 AUE_NULL STD { int linux_tee(void); Index: sys/arm64/linux/linux_dummy.c =================================================================== --- sys/arm64/linux/linux_dummy.c +++ sys/arm64/linux/linux_dummy.c @@ -101,7 +101,6 @@ DUMMY(unshare); /* Linux 2.6.17: */ DUMMY(splice); -DUMMY(sync_file_range); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ Index: sys/arm64/linux/linux_proto.h =================================================================== --- sys/arm64/linux/linux_proto.h +++ sys/arm64/linux/linux_proto.h @@ -317,7 +317,10 @@ char fd_l_[PADL_(l_uint)]; l_uint fd; char fd_r_[PADR_(l_uint)]; }; struct linux_sync_file_range_args { - register_t dummy; + char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t)]; l_loff_t offset; char offset_r_[PADR_(l_loff_t)]; + char nbytes_l_[PADL_(l_loff_t)]; l_loff_t nbytes; char nbytes_r_[PADR_(l_loff_t)]; + char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)]; }; struct linux_timerfd_create_args { char clockid_l_[PADL_(l_int)]; l_int clockid; char clockid_r_[PADR_(l_int)]; Index: sys/arm64/linux/linux_sysent.c =================================================================== --- sys/arm64/linux/linux_sysent.c +++ sys/arm64/linux/linux_sysent.c @@ -101,7 +101,7 @@ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 81 = linux_sync */ { AS(fsync_args), (sy_call_t *)sys_fsync, AUE_FSYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 82 = fsync */ { AS(linux_fdatasync_args), (sy_call_t *)linux_fdatasync, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 83 = linux_fdatasync */ - { 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 84 = linux_sync_file_range */ + { AS(linux_sync_file_range_args), (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 84 = linux_sync_file_range */ { AS(linux_timerfd_create_args), (sy_call_t *)linux_timerfd_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 85 = linux_timerfd_create */ { AS(linux_timerfd_settime_args), (sy_call_t *)linux_timerfd_settime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 86 = linux_timerfd_settime */ { AS(linux_timerfd_gettime_args), (sy_call_t *)linux_timerfd_gettime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 87 = linux_timerfd_gettime */ Index: sys/arm64/linux/linux_systrace_args.c =================================================================== --- sys/arm64/linux/linux_systrace_args.c +++ sys/arm64/linux/linux_systrace_args.c @@ -597,7 +597,12 @@ } /* linux_sync_file_range */ case 84: { - *n_args = 0; + struct linux_sync_file_range_args *p = params; + iarg[0] = p->fd; /* l_int */ + iarg[1] = p->offset; /* l_loff_t */ + iarg[2] = p->nbytes; /* l_loff_t */ + uarg[3] = p->flags; /* unsigned int */ + *n_args = 4; break; } /* linux_timerfd_create */ @@ -3025,6 +3030,22 @@ break; /* linux_sync_file_range */ case 84: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_loff_t"; + break; + case 2: + p = "l_loff_t"; + break; + case 3: + p = "unsigned int"; + break; + default: + break; + }; break; /* linux_timerfd_create */ case 85: @@ -5773,6 +5794,9 @@ break; /* linux_sync_file_range */ case 84: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_timerfd_create */ case 85: if (ndx == 0 || ndx == 1) Index: sys/arm64/linux/syscalls.master =================================================================== --- sys/arm64/linux/syscalls.master +++ sys/arm64/linux/syscalls.master @@ -450,7 +450,12 @@ l_uint fd); } 84 AUE_NULL STD { - int linux_sync_file_range(void); + int linux_sync_file_range( + l_int fd, + l_loff_t offset, + l_loff_t nbytes, + unsigned int flags + ); } 85 AUE_NULL STD { int linux_timerfd_create( Index: sys/compat/linux/linux_file.h =================================================================== --- sys/compat/linux/linux_file.h +++ sys/compat/linux/linux_file.h @@ -134,4 +134,11 @@ #define LINUX_RENAME_EXCHANGE 0x00000002 #define LINUX_RENAME_WHITEOUT 0x00000004 +/* + * sync_file_range flags + */ +#define LINUX_SYNC_FILE_RANGE_WAIT_BEFORE 1 +#define LINUX_SYNC_FILE_RANGE_WRITE 2 +#define LINUX_SYNC_FILE_RANGE_WAIT_AFTER 4 + #endif /* !_LINUX_FILE_H_ */ Index: sys/compat/linux/linux_file.c =================================================================== --- sys/compat/linux/linux_file.c +++ sys/compat/linux/linux_file.c @@ -901,6 +901,22 @@ } int +linux_sync_file_range(td, uap) + struct thread *td; + struct linux_sync_file_range_args *uap; +{ + + if (uap->offset < 0 || uap->nbytes < 0 || + (uap->flags & ~(LINUX_SYNC_FILE_RANGE_WAIT_BEFORE | + LINUX_SYNC_FILE_RANGE_WRITE | + LINUX_SYNC_FILE_RANGE_WAIT_AFTER)) != 0) { + return (EINVAL); + } + + return (kern_fsync(td, uap->fd, false)); +} + +int linux_pread(struct thread *td, struct linux_pread_args *uap) { struct vnode *vp; Index: sys/i386/linux/linux_dummy.c =================================================================== --- sys/i386/linux/linux_dummy.c +++ sys/i386/linux/linux_dummy.c @@ -101,7 +101,6 @@ DUMMY(unshare); /* Linux 2.6.17: */ DUMMY(splice); -DUMMY(sync_file_range); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ Index: sys/i386/linux/linux_proto.h =================================================================== --- sys/i386/linux/linux_proto.h +++ sys/i386/linux/linux_proto.h @@ -1038,7 +1038,10 @@ register_t dummy; }; struct linux_sync_file_range_args { - register_t dummy; + char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t)]; l_loff_t offset; char offset_r_[PADR_(l_loff_t)]; + char nbytes_l_[PADL_(l_loff_t)]; l_loff_t nbytes; char nbytes_r_[PADR_(l_loff_t)]; + char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)]; }; struct linux_tee_args { register_t dummy; Index: sys/i386/linux/linux_sysent.c =================================================================== --- sys/i386/linux/linux_sysent.c +++ sys/i386/linux/linux_sysent.c @@ -331,7 +331,7 @@ { AS(linux_set_robust_list_args), (sy_call_t *)linux_set_robust_list, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 311 = linux_set_robust_list */ { AS(linux_get_robust_list_args), (sy_call_t *)linux_get_robust_list, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 312 = linux_get_robust_list */ { 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 313 = linux_splice */ - { 0, (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 314 = linux_sync_file_range */ + { AS(linux_sync_file_range_args), (sy_call_t *)linux_sync_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 314 = linux_sync_file_range */ { 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 315 = linux_tee */ { 0, (sy_call_t *)linux_vmsplice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 316 = linux_vmsplice */ { 0, (sy_call_t *)linux_move_pages, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 317 = linux_move_pages */ Index: sys/i386/linux/linux_systrace_args.c =================================================================== --- sys/i386/linux/linux_systrace_args.c +++ sys/i386/linux/linux_systrace_args.c @@ -2194,7 +2194,12 @@ } /* linux_sync_file_range */ case 314: { - *n_args = 0; + struct linux_sync_file_range_args *p = params; + iarg[0] = p->fd; /* l_int */ + iarg[1] = p->offset; /* l_loff_t */ + iarg[2] = p->nbytes; /* l_loff_t */ + uarg[3] = p->flags; /* unsigned int */ + *n_args = 4; break; } /* linux_tee */ @@ -6395,6 +6400,22 @@ break; /* linux_sync_file_range */ case 314: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_loff_t"; + break; + case 2: + p = "l_loff_t"; + break; + case 3: + p = "unsigned int"; + break; + default: + break; + }; break; /* linux_tee */ case 315: @@ -8932,6 +8953,9 @@ case 313: /* linux_sync_file_range */ case 314: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_tee */ case 315: /* linux_vmsplice */ Index: sys/i386/linux/syscalls.master =================================================================== --- sys/i386/linux/syscalls.master +++ sys/i386/linux/syscalls.master @@ -533,7 +533,8 @@ 312 AUE_NULL STD { int linux_get_robust_list(l_int pid, \ struct linux_robust_list_head **head, l_size_t *len); } 313 AUE_NULL STD { int linux_splice(void); } -314 AUE_NULL STD { int linux_sync_file_range(void); } +314 AUE_NULL STD { int linux_sync_file_range(l_int fd, l_loff_t offset, + l_loff_t nbytes, unsigned int flags); } 315 AUE_NULL STD { int linux_tee(void); } 316 AUE_NULL STD { int linux_vmsplice(void); } ; Linux 2.6.18: