svn commit: r350315 - in head/sys: kern sys
Konstantin Belousov
kostikbel at gmail.com
Sat Jul 27 13:48:14 UTC 2019
On Sat, Jul 27, 2019 at 01:35:06AM +0000, Rick Macklem wrote:
> Konstantin Belousov wrote:
> >On Thu, Jul 25, 2019 at 05:46:17AM +0000, Rick Macklem wrote:
> >> Author: rmacklem
> >> Date: Thu Jul 25 05:46:16 2019
> >> New Revision: 350315
> >> URL: https://svnweb.freebsd.org/changeset/base/350315
> >>
> >> Log:
> >> Add kernel support for a Linux compatible copy_file_range(2) syscall.
> >
> >> Modified: head/sys/kern/syscalls.master
> >> >=====================================================================>=========
> >> --- head/sys/kern/syscalls.master Thu Jul 25 03:55:05 2019 (r350314)
> >> +++ head/sys/kern/syscalls.master Thu Jul 25 05:46:16 2019 (r350315)
> >> @@ -3175,6 +3175,16 @@
> >> int flag
> >> );
> >> }
> >> +569 AUE_NULL STD {
> >> + ssize_t copy_file_range(
> >> + int infd,
> >> + _Inout_opt_ off_t *inoffp,
> >> + int outfd,
> >> + _Inout_opt_ off_t *outoffp,
> >> + size_t len,
> >> + unsigned int flags
> >> + );
> >> + }
> >
> >I sat to write the compat32 shims, and only then noted that len has size_t
> >type. Why is it size_t and not off_t ?
> Well, that's what Linux did.
>
> Also, since it returns ssize_t, it can't do more than SSIZE_MAX
> (generally 1/2 of SIZE_T_MAX). Returning ssize_t is also what Linux
> does and is consistent with read(2)/write(2).
If changing the length argument type to off_t, it is reasonable to change
the return type to off_t as well. We already have the lseek(2) syscall that
requires two return registers on 32bit.
Note that it is reasonable for read(2) to take length as size_t-typed
parameter, because size_t is the type for object sizes. There is no
object in user address space for copy_file_range(2) API, so potentially
wider off_t is acceptable and is in fact useful there. It is useful on
32bit machines where FreeBSD size_t is 32bit, while off_t is 64bit.
More information about the svn-src-all
mailing list