Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
32288 views
/*1* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.ch;2627import java.io.FileDescriptor;28import java.io.IOException;2930class FileDispatcherImpl extends FileDispatcher {3132static {33IOUtil.load();34init();35}3637FileDispatcherImpl(boolean append) {38/* append is ignored */39}4041FileDispatcherImpl() {42}4344int read(FileDescriptor fd, long address, int len) throws IOException {45return read0(fd, address, len);46}4748int pread(FileDescriptor fd, long address, int len, long position)49throws IOException50{51return pread0(fd, address, len, position);52}5354long readv(FileDescriptor fd, long address, int len) throws IOException {55return readv0(fd, address, len);56}5758int write(FileDescriptor fd, long address, int len) throws IOException {59return write0(fd, address, len);60}6162int pwrite(FileDescriptor fd, long address, int len, long position)63throws IOException64{65return pwrite0(fd, address, len, position);66}6768long writev(FileDescriptor fd, long address, int len)69throws IOException70{71return writev0(fd, address, len);72}7374long seek(FileDescriptor fd, long offset) throws IOException {75return seek0(fd, offset);76}7778int force(FileDescriptor fd, boolean metaData) throws IOException {79return force0(fd, metaData);80}8182int truncate(FileDescriptor fd, long size) throws IOException {83return truncate0(fd, size);84}8586long size(FileDescriptor fd) throws IOException {87return size0(fd);88}8990int lock(FileDescriptor fd, boolean blocking, long pos, long size,91boolean shared) throws IOException92{93return lock0(fd, blocking, pos, size, shared);94}9596void release(FileDescriptor fd, long pos, long size) throws IOException {97release0(fd, pos, size);98}99100void close(FileDescriptor fd) throws IOException {101close0(fd);102}103104void preClose(FileDescriptor fd) throws IOException {105preClose0(fd);106}107108FileDescriptor duplicateForMapping(FileDescriptor fd) {109// file descriptor not required for mapping operations; okay110// to return invalid file descriptor.111return new FileDescriptor();112}113114boolean canTransferToDirectly(java.nio.channels.SelectableChannel sc) {115return true;116}117118boolean transferToDirectlyNeedsPositionLock() {119return false;120}121122// -- Native methods --123124static native int read0(FileDescriptor fd, long address, int len)125throws IOException;126127static native int pread0(FileDescriptor fd, long address, int len,128long position) throws IOException;129130static native long readv0(FileDescriptor fd, long address, int len)131throws IOException;132133static native int write0(FileDescriptor fd, long address, int len)134throws IOException;135136static native int pwrite0(FileDescriptor fd, long address, int len,137long position) throws IOException;138139static native long writev0(FileDescriptor fd, long address, int len)140throws IOException;141142static native int force0(FileDescriptor fd, boolean metaData)143throws IOException;144145static native long seek0(FileDescriptor fd, long size)146throws IOException;147148static native int truncate0(FileDescriptor fd, long size)149throws IOException;150151static native long size0(FileDescriptor fd) throws IOException;152153static native int lock0(FileDescriptor fd, boolean blocking, long pos,154long size, boolean shared) throws IOException;155156static native void release0(FileDescriptor fd, long pos, long size)157throws IOException;158159static native void close0(FileDescriptor fd) throws IOException;160161static native void preClose0(FileDescriptor fd) throws IOException;162163static native void closeIntFD(int fd) throws IOException;164165static native void init();166167}168169170