< prev index next >

src/java.base/unix/classes/sun/nio/ch/FileDispatcherImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  99     }
 100 
 101     void preClose(FileDescriptor fd) throws IOException {
 102         preClose0(fd);
 103     }
 104 
 105     FileDescriptor duplicateForMapping(FileDescriptor fd) {
 106         // file descriptor not required for mapping operations; okay
 107         // to return invalid file descriptor.
 108         return new FileDescriptor();
 109     }
 110 
 111     boolean canTransferToDirectly(java.nio.channels.SelectableChannel sc) {
 112         return true;
 113     }
 114 
 115     boolean transferToDirectlyNeedsPositionLock() {
 116         return false;
 117     }
 118 












 119     // -- Native methods --
 120 
 121     static native int read0(FileDescriptor fd, long address, int len)
 122         throws IOException;
 123 
 124     static native int pread0(FileDescriptor fd, long address, int len,
 125                              long position) throws IOException;
 126 
 127     static native long readv0(FileDescriptor fd, long address, int len)
 128         throws IOException;
 129 
 130     static native int write0(FileDescriptor fd, long address, int len)
 131         throws IOException;
 132 
 133     static native int pwrite0(FileDescriptor fd, long address, int len,
 134                              long position) throws IOException;
 135 
 136     static native long writev0(FileDescriptor fd, long address, int len)
 137         throws IOException;
 138 


 141 
 142     static native int truncate0(FileDescriptor fd, long size)
 143         throws IOException;
 144 
 145     static native int allocate0(FileDescriptor fd, long size)
 146         throws IOException;
 147 
 148     static native long size0(FileDescriptor fd) throws IOException;
 149 
 150     static native int lock0(FileDescriptor fd, boolean blocking, long pos,
 151                             long size, boolean shared) throws IOException;
 152 
 153     static native void release0(FileDescriptor fd, long pos, long size)
 154         throws IOException;
 155 
 156     static native void close0(FileDescriptor fd) throws IOException;
 157 
 158     static native void preClose0(FileDescriptor fd) throws IOException;
 159 
 160     static native void closeIntFD(int fd) throws IOException;


 161 
 162     static native void init();
 163 
 164 }
   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  99     }
 100 
 101     void preClose(FileDescriptor fd) throws IOException {
 102         preClose0(fd);
 103     }
 104 
 105     FileDescriptor duplicateForMapping(FileDescriptor fd) {
 106         // file descriptor not required for mapping operations; okay
 107         // to return invalid file descriptor.
 108         return new FileDescriptor();
 109     }
 110 
 111     boolean canTransferToDirectly(java.nio.channels.SelectableChannel sc) {
 112         return true;
 113     }
 114 
 115     boolean transferToDirectlyNeedsPositionLock() {
 116         return false;
 117     }
 118 
 119     int setDirectIO(FileDescriptor fd, String path)
 120     {
 121         int result = -1;
 122         try {
 123             result = setDirect0(fd);
 124         } catch (IOException e) {
 125             throw new UnsupportedOperationException
 126                 ("Error setting up DirectIO", e);
 127         }
 128         return result;
 129     }
 130 
 131     // -- Native methods --
 132 
 133     static native int read0(FileDescriptor fd, long address, int len)
 134         throws IOException;
 135 
 136     static native int pread0(FileDescriptor fd, long address, int len,
 137                              long position) throws IOException;
 138 
 139     static native long readv0(FileDescriptor fd, long address, int len)
 140         throws IOException;
 141 
 142     static native int write0(FileDescriptor fd, long address, int len)
 143         throws IOException;
 144 
 145     static native int pwrite0(FileDescriptor fd, long address, int len,
 146                              long position) throws IOException;
 147 
 148     static native long writev0(FileDescriptor fd, long address, int len)
 149         throws IOException;
 150 


 153 
 154     static native int truncate0(FileDescriptor fd, long size)
 155         throws IOException;
 156 
 157     static native int allocate0(FileDescriptor fd, long size)
 158         throws IOException;
 159 
 160     static native long size0(FileDescriptor fd) throws IOException;
 161 
 162     static native int lock0(FileDescriptor fd, boolean blocking, long pos,
 163                             long size, boolean shared) throws IOException;
 164 
 165     static native void release0(FileDescriptor fd, long pos, long size)
 166         throws IOException;
 167 
 168     static native void close0(FileDescriptor fd) throws IOException;
 169 
 170     static native void preClose0(FileDescriptor fd) throws IOException;
 171 
 172     static native void closeIntFD(int fd) throws IOException;
 173 
 174     static native int setDirect0(FileDescriptor fd) throws IOException;    
 175 
 176     static native void init();
 177 
 178 }
< prev index next >