2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
30 class FileDispatcherImpl extends FileDispatcher
38 FileDispatcherImpl(boolean append) {
39 /* append is ignored */
42 FileDispatcherImpl() {
45 int read(FileDescriptor fd, long address, int len) throws IOException {
46 return read0(fd, address, len);
49 int pread(FileDescriptor fd, long address, int len,
50 long position, Object lock) throws IOException {
51 return pread0(fd, address, len, position);
54 long readv(FileDescriptor fd, long address, int len) throws IOException {
55 return readv0(fd, address, len);
58 int write(FileDescriptor fd, long address, int len) throws IOException {
59 return write0(fd, address, len);
62 int pwrite(FileDescriptor fd, long address, int len,
63 long position, Object lock) throws IOException
65 return pwrite0(fd, address, len, position);
68 long writev(FileDescriptor fd, long address, int len)
71 return writev0(fd, address, len);
74 int force(FileDescriptor fd, boolean metaData) throws IOException {
75 return force0(fd, metaData);
78 int truncate(FileDescriptor fd, long size) throws IOException {
79 return truncate0(fd, size);
82 long size(FileDescriptor fd) throws IOException {
86 int lock(FileDescriptor fd, boolean blocking, long pos, long size,
87 boolean shared) throws IOException
89 return lock0(fd, blocking, pos, size, shared);
92 void release(FileDescriptor fd, long pos, long size) throws IOException {
93 release0(fd, pos, size);
96 void close(FileDescriptor fd) throws IOException {
100 void preClose(FileDescriptor fd) throws IOException {
104 FileDescriptor duplicateForMapping(FileDescriptor fd) {
105 // file descriptor not required for mapping operations; okay
106 // to return invalid file descriptor.
107 return new FileDescriptor();
110 // -- Native methods --
112 static native int read0(FileDescriptor fd, long address, int len)
115 static native int pread0(FileDescriptor fd, long address, int len,
116 long position) throws IOException;
118 static native long readv0(FileDescriptor fd, long address, int len)
121 static native int write0(FileDescriptor fd, long address, int len)
124 static native int pwrite0(FileDescriptor fd, long address, int len,
125 long position) throws IOException;
127 static native long writev0(FileDescriptor fd, long address, int len)
130 static native int force0(FileDescriptor fd, boolean metaData)
133 static native int truncate0(FileDescriptor fd, long size)
136 static native long size0(FileDescriptor fd) throws IOException;
138 static native int lock0(FileDescriptor fd, boolean blocking, long pos,
139 long size, boolean shared) throws IOException;
141 static native void release0(FileDescriptor fd, long pos, long size)
144 static native void close0(FileDescriptor fd) throws IOException;
146 static native void preClose0(FileDescriptor fd) throws IOException;
148 static native void closeIntFD(int fd) throws IOException;
150 static native void init();