Os.java revision 3218082325b6b8713a8ac15731482e3da86a7df9
10c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org/*
20c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * Copyright (C) 2011 The Android Open Source Project
30c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org *
40c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * Licensed under the Apache License, Version 2.0 (the "License");
50c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * you may not use this file except in compliance with the License.
60c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * You may obtain a copy of the License at
70c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org *
80c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org *      http://www.apache.org/licenses/LICENSE-2.0
90c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org *
100c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * Unless required by applicable law or agreed to in writing, software
110c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * distributed under the License is distributed on an "AS IS" BASIS,
120c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * See the License for the specific language governing permissions and
140c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org * limitations under the License.
150c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org */
160c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org
1700b8f6b3643332cce1ee711715f7fbb824d793cakwiberg@webrtc.orgpackage libcore.io;
180c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org
190c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport java.io.FileDescriptor;
200c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport java.net.InetAddress;
210c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport java.net.InetSocketAddress;
220c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport java.net.SocketAddress;
230c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport java.net.SocketException;
240c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport java.nio.ByteBuffer;
250c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport libcore.util.MutableInt;
260c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgimport libcore.util.MutableLong;
270c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org
280c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.orgpublic interface Os {
290c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException;
306955870806624479723addfae6dcf5d13968796cPeter Kasting    public boolean access(String path, int mode) throws ErrnoException;
310c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException;
320c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void chmod(String path, int mode) throws ErrnoException;
336955870806624479723addfae6dcf5d13968796cPeter Kasting    public void chown(String path, int uid, int gid) throws ErrnoException;
340c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void close(FileDescriptor fd) throws ErrnoException;
350c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException;
360c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException;
370c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException;
380c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public String[] environ();
390c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void fchmod(FileDescriptor fd, int mode) throws ErrnoException;
400c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException;
410c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException;
420c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException;
430c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException;
440c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void fdatasync(FileDescriptor fd) throws ErrnoException;
450c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructStat fstat(FileDescriptor fd) throws ErrnoException;
460c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException;
470c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void fsync(FileDescriptor fd) throws ErrnoException;
480c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void ftruncate(FileDescriptor fd, long length) throws ErrnoException;
490c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public String gai_strerror(int error);
500c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public InetAddress[] getaddrinfo(String node, StructAddrinfo hints) throws GaiException;
510c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int getegid();
520c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int geteuid();
530c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int getgid();
546955870806624479723addfae6dcf5d13968796cPeter Kasting    public String getenv(String name);
550c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    /* TODO: break into getnameinfoHost and getnameinfoService? */
560c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public String getnameinfo(InetAddress address, int flags) throws GaiException;
570c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int getpid();
580c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int getppid();
590c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructPasswd getpwnam(String name) throws ErrnoException;
600c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructPasswd getpwuid(int uid) throws ErrnoException;
610c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public SocketAddress getsockname(FileDescriptor fd) throws ErrnoException;
6291d6edef35e7275879c30ce16ecb8b6dc73c6e4ahenrikg    public int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException;
6391d6edef35e7275879c30ce16ecb8b6dc73c6e4ahenrikg    public InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException;
640c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException;
650c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException;
660c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException;
670c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int getuid();
680c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public String if_indextoname(int index);
690c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public InetAddress inet_pton(int family, String address);
700c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException;
710c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException;
720c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public boolean isatty(FileDescriptor fd);
730c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void kill(int pid, int signal) throws ErrnoException;
740c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void lchown(String path, int uid, int gid) throws ErrnoException;
750c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void listen(FileDescriptor fd, int backlog) throws ErrnoException;
760c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException;
770c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public StructStat lstat(String path) throws ErrnoException;
780c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException;
790c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void mkdir(String path, int mode) throws ErrnoException;
800c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void mlock(long address, long byteCount) throws ErrnoException;
810c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException;
820c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void msync(long address, long byteCount, int flags) throws ErrnoException;
830c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void munlock(long address, long byteCount) throws ErrnoException;
840c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public void munmap(long address, long byteCount) throws ErrnoException;
856955870806624479723addfae6dcf5d13968796cPeter Kasting    public FileDescriptor open(String path, int flags, int mode) throws ErrnoException;
866955870806624479723addfae6dcf5d13968796cPeter Kasting    public FileDescriptor[] pipe() throws ErrnoException;
870c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    /* TODO: if we used the non-standard ppoll(2) behind the scenes, we could take a long timeout. */
880c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException;
890c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException;
900c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException;
910c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException;
920c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException;
930c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException;
940c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException;
950c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException;
960c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException;
970c39e91cc827f222ab227bad09cf9199163d28f8aluebs@webrtc.org    public int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException;
98    public void remove(String path) throws ErrnoException;
99    public void rename(String oldPath, String newPath) throws ErrnoException;
100    public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException;
101    public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException;
102    public long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException;
103    public void setegid(int egid) throws ErrnoException;
104    public void seteuid(int euid) throws ErrnoException;
105    public void setgid(int gid) throws ErrnoException;
106    public int setsid() throws ErrnoException;
107    public void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException;
108    public void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException;
109    public void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException;
110    public void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException;
111    public void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException;
112    public void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException;
113    public void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException;
114    public void setuid(int uid) throws ErrnoException;
115    public void shutdown(FileDescriptor fd, int how) throws ErrnoException;
116    public FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException;
117    public void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException;
118    public StructStat stat(String path) throws ErrnoException;
119    /* TODO: replace statfs with statvfs. */
120    public StructStatFs statfs(String path) throws ErrnoException;
121    public String strerror(int errno);
122    public void symlink(String oldPath, String newPath) throws ErrnoException;
123    public long sysconf(int name);
124    public void tcdrain(FileDescriptor fd) throws ErrnoException;
125    public int umask(int mask);
126    public StructUtsname uname();
127    public int waitpid(int pid, MutableInt status, int options) throws ErrnoException;
128    public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException;
129    public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException;
130    public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException;
131}
132