1 --- a/src/java.base/solaris/classes/sun/nio/ch/FileDispatcherImpl.java Mon Oct 10 20:08:47 2022
2 +++ b/src/java.base/solaris/classes/sun/nio/ch/FileDispatcherImpl.java Mon Oct 10 19:39:09 2022
5 + * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 + * This code is free software; you can redistribute it and/or modify it
9 + * under the terms of the GNU General Public License version 2 only, as
10 + * published by the Free Software Foundation. Oracle designates this
11 + * particular file as subject to the "Classpath" exception as provided
12 + * by Oracle in the LICENSE file that accompanied this code.
14 + * This code is distributed in the hope that it will be useful, but WITHOUT
15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 + * version 2 for more details (a copy is included in the LICENSE file that
18 + * accompanied this code).
20 + * You should have received a copy of the GNU General Public License version
21 + * 2 along with this work; if not, write to the Free Software Foundation,
22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
25 + * or visit www.oracle.com if you need additional information or have any
31 +import java.io.FileDescriptor;
33 +class FileDispatcherImpl extends UnixFileDispatcherImpl {
34 + FileDispatcherImpl() {
38 + long transferTo(FileDescriptor src, long position, long count,
39 + FileDescriptor dst, boolean append) {
40 + return transferTo0(src, position, count, dst, append);
43 + // -- Native methods --
45 + static native long transferTo0(FileDescriptor src, long position,
46 + long count, FileDescriptor dst,
49 --- a/src/java.base/solaris/native/libnio/ch/FileDispatcherImpl.c Mon Oct 10 20:09:47 2022
50 +++ b/src/java.base/solaris/native/libnio/ch/FileDispatcherImpl.c Mon Oct 10 19:39:25 2022
53 + * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
54 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
56 + * This code is free software; you can redistribute it and/or modify it
57 + * under the terms of the GNU General Public License version 2 only, as
58 + * published by the Free Software Foundation. Oracle designates this
59 + * particular file as subject to the "Classpath" exception as provided
60 + * by Oracle in the LICENSE file that accompanied this code.
62 + * This code is distributed in the hope that it will be useful, but WITHOUT
63 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
64 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
65 + * version 2 for more details (a copy is included in the LICENSE file that
66 + * accompanied this code).
68 + * You should have received a copy of the GNU General Public License version
69 + * 2 along with this work; if not, write to the Free Software Foundation,
70 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
72 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
73 + * or visit www.oracle.com if you need additional information or have any
77 +#include <sys/sendfile.h>
82 +#include "nio_util.h"
83 +#include "sun_nio_ch_FileDispatcherImpl.h"
85 +JNIEXPORT jlong JNICALL
86 +Java_sun_nio_ch_FileDispatcherImpl_transferTo0(JNIEnv *env, jobject this,
88 + jlong position, jlong count,
89 + jobject dstFDO, jboolean append)
91 + jint srcFD = fdval(env, srcFDO);
92 + jint dstFD = fdval(env, dstFDO);
94 + sendfilevec64_t sfv;
95 + size_t numBytes = 0;
100 + sfv.sfv_off = (off64_t)position;
101 + sfv.sfv_len = count;
103 + result = sendfilev64(dstFD, &sfv, 1, &numBytes);
105 + /* Solaris sendfilev() will return -1 even if some bytes have been
106 + * transferred, so we check numBytes first.
111 + if (errno == EAGAIN)
112 + return IOS_UNAVAILABLE;
113 + if (errno == EOPNOTSUPP)
114 + return IOS_UNSUPPORTED_CASE;
115 + if ((errno == EINVAL) && ((ssize_t)count >= 0))
116 + return IOS_UNSUPPORTED_CASE;
117 + if (errno == EINTR)
118 + return IOS_INTERRUPTED;
119 + JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");