1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.system; 18 19 import android.util.MutableInt; 20 import android.util.MutableLong; 21 import java.io.FileDescriptor; 22 import java.io.InterruptedIOException; 23 import java.net.InetAddress; 24 import java.net.InetSocketAddress; 25 import java.net.SocketAddress; 26 import java.net.SocketException; 27 import java.nio.ByteBuffer; 28 import libcore.io.Libcore; 29 30 /** 31 * Access to low-level system functionality. Most of these are system calls. Most users will want 32 * to use higher-level APIs where available, but this class provides access to the underlying 33 * primitives used to implement the higher-level APIs. 34 * 35 * <p>The corresponding constants can be found in {@link OsConstants}. 36 */ 37 public final class Os { Os()38 private Os() {} 39 40 /** 41 * See <a href="http://man7.org/linux/man-pages/man2/accept.2.html">accept(2)</a>. 42 */ accept(FileDescriptor fd, InetSocketAddress peerAddress)43 public static FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { return Libcore.os.accept(fd, peerAddress); } 44 45 /** 46 * See <a href="http://man7.org/linux/man-pages/man2/access.2.html">access(2)</a>. 47 */ access(String path, int mode)48 public static boolean access(String path, int mode) throws ErrnoException { return Libcore.os.access(path, mode); } 49 android_getaddrinfo(String node, StructAddrinfo hints, int netId)50 /** @hide */ public static InetAddress[] android_getaddrinfo(String node, StructAddrinfo hints, int netId) throws GaiException { return Libcore.os.android_getaddrinfo(node, hints, netId); } 51 52 /** 53 * See <a href="http://man7.org/linux/man-pages/man2/bind.2.html">bind(2)</a>. 54 */ bind(FileDescriptor fd, InetAddress address, int port)55 public static void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.bind(fd, address, port); } 56 57 /** 58 * See <a href="http://man7.org/linux/man-pages/man2/chmod.2.html">chmod(2)</a>. 59 */ chmod(String path, int mode)60 public static void chmod(String path, int mode) throws ErrnoException { Libcore.os.chmod(path, mode); } 61 62 /** 63 * See <a href="http://man7.org/linux/man-pages/man2/chown.2.html">chown(2)</a>. 64 */ chown(String path, int uid, int gid)65 public static void chown(String path, int uid, int gid) throws ErrnoException { Libcore.os.chown(path, uid, gid); } 66 67 /** 68 * See <a href="http://man7.org/linux/man-pages/man2/close.2.html">close(2)</a>. 69 */ close(FileDescriptor fd)70 public static void close(FileDescriptor fd) throws ErrnoException { Libcore.os.close(fd); } 71 72 /** 73 * See <a href="http://man7.org/linux/man-pages/man2/connect.2.html">connect(2)</a>. 74 */ connect(FileDescriptor fd, InetAddress address, int port)75 public static void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.connect(fd, address, port); } 76 77 /** 78 * See <a href="http://man7.org/linux/man-pages/man2/dup.2.html">dup(2)</a>. 79 */ dup(FileDescriptor oldFd)80 public static FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return Libcore.os.dup(oldFd); } 81 82 /** 83 * See <a href="http://man7.org/linux/man-pages/man2/dup2.2.html">dup2(2)</a>. 84 */ dup2(FileDescriptor oldFd, int newFd)85 public static FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return Libcore.os.dup2(oldFd, newFd); } 86 87 /** 88 * See <a href="http://man7.org/linux/man-pages/man3/environ.3.html">environ(3)</a>. 89 */ environ()90 public static String[] environ() { return Libcore.os.environ(); } 91 92 /** 93 * See <a href="http://man7.org/linux/man-pages/man2/execv.2.html">execv(2)</a>. 94 */ execv(String filename, String[] argv)95 public static void execv(String filename, String[] argv) throws ErrnoException { Libcore.os.execv(filename, argv); } 96 97 /** 98 * See <a href="http://man7.org/linux/man-pages/man2/execve.2.html">execve(2)</a>. 99 */ execve(String filename, String[] argv, String[] envp)100 public static void execve(String filename, String[] argv, String[] envp) throws ErrnoException { Libcore.os.execve(filename, argv, envp); } 101 102 /** 103 * See <a href="http://man7.org/linux/man-pages/man2/fchmod.2.html">fchmod(2)</a>. 104 */ fchmod(FileDescriptor fd, int mode)105 public static void fchmod(FileDescriptor fd, int mode) throws ErrnoException { Libcore.os.fchmod(fd, mode); } 106 107 /** 108 * See <a href="http://man7.org/linux/man-pages/man2/fchown.2.html">fchown(2)</a>. 109 */ fchown(FileDescriptor fd, int uid, int gid)110 public static void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { Libcore.os.fchown(fd, uid, gid); } 111 fcntlVoid(FileDescriptor fd, int cmd)112 /** @hide */ public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); } fcntlLong(FileDescriptor fd, int cmd, long arg)113 /** @hide */ public static int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return Libcore.os.fcntlLong(fd, cmd, arg); } fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg)114 /** @hide */ public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException, InterruptedIOException { return Libcore.os.fcntlFlock(fd, cmd, arg); } 115 116 /** 117 * See <a href="http://man7.org/linux/man-pages/man2/fdatasync.2.html">fdatasync(2)</a>. 118 */ fdatasync(FileDescriptor fd)119 public static void fdatasync(FileDescriptor fd) throws ErrnoException { Libcore.os.fdatasync(fd); } 120 121 /** 122 * See <a href="http://man7.org/linux/man-pages/man2/fstat.2.html">fstat(2)</a>. 123 */ fstat(FileDescriptor fd)124 public static StructStat fstat(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstat(fd); } 125 126 /** 127 * See <a href="http://man7.org/linux/man-pages/man2/fstatvfs.2.html">fstatvfs(2)</a>. 128 */ fstatvfs(FileDescriptor fd)129 public static StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstatvfs(fd); } 130 131 /** 132 * See <a href="http://man7.org/linux/man-pages/man2/fsync.2.html">fsync(2)</a>. 133 */ fsync(FileDescriptor fd)134 public static void fsync(FileDescriptor fd) throws ErrnoException { Libcore.os.fsync(fd); } 135 136 /** 137 * See <a href="http://man7.org/linux/man-pages/man2/ftruncate.2.html">ftruncate(2)</a>. 138 */ ftruncate(FileDescriptor fd, long length)139 public static void ftruncate(FileDescriptor fd, long length) throws ErrnoException { Libcore.os.ftruncate(fd, length); } 140 141 /** 142 * See <a href="http://man7.org/linux/man-pages/man3/gai_strerror.3.html">gai_strerror(3)</a>. 143 */ gai_strerror(int error)144 public static String gai_strerror(int error) { return Libcore.os.gai_strerror(error); } 145 146 /** 147 * See <a href="http://man7.org/linux/man-pages/man2/getegid.2.html">getegid(2)</a>. 148 */ getegid()149 public static int getegid() { return Libcore.os.getegid(); } 150 151 /** 152 * See <a href="http://man7.org/linux/man-pages/man2/geteuid.2.html">geteuid(2)</a>. 153 */ geteuid()154 public static int geteuid() { return Libcore.os.geteuid(); } 155 156 /** 157 * See <a href="http://man7.org/linux/man-pages/man2/getgid.2.html">getgid(2)</a>. 158 */ getgid()159 public static int getgid() { return Libcore.os.getgid(); } 160 161 /** 162 * See <a href="http://man7.org/linux/man-pages/man3/getenv.3.html">getenv(3)</a>. 163 */ getenv(String name)164 public static String getenv(String name) { return Libcore.os.getenv(name); } 165 getnameinfo(InetAddress address, int flags)166 /** @hide */ public static String getnameinfo(InetAddress address, int flags) throws GaiException { return Libcore.os.getnameinfo(address, flags); } 167 168 /** 169 * See <a href="http://man7.org/linux/man-pages/man2/getpeername.2.html">getpeername(2)</a>. 170 */ getpeername(FileDescriptor fd)171 public static SocketAddress getpeername(FileDescriptor fd) throws ErrnoException { return Libcore.os.getpeername(fd); } 172 173 /** 174 * See <a href="http://man7.org/linux/man-pages/man2/getpid.2.html">getpid(2)</a>. 175 */ getpid()176 public static int getpid() { return Libcore.os.getpid(); } 177 178 /** 179 * See <a href="http://man7.org/linux/man-pages/man2/getppid.2.html">getppid(2)</a>. 180 */ getppid()181 public static int getppid() { return Libcore.os.getppid(); } 182 getpwnam(String name)183 /** @hide */ public static StructPasswd getpwnam(String name) throws ErrnoException { return Libcore.os.getpwnam(name); } 184 getpwuid(int uid)185 /** @hide */ public static StructPasswd getpwuid(int uid) throws ErrnoException { return Libcore.os.getpwuid(uid); } 186 187 /** 188 * See <a href="http://man7.org/linux/man-pages/man2/getsockname.2.html">getsockname(2)</a>. 189 */ getsockname(FileDescriptor fd)190 public static SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return Libcore.os.getsockname(fd); } 191 getsockoptByte(FileDescriptor fd, int level, int option)192 /** @hide */ public static int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptByte(fd, level, option); } getsockoptInAddr(FileDescriptor fd, int level, int option)193 /** @hide */ public static InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInAddr(fd, level, option); } getsockoptInt(FileDescriptor fd, int level, int option)194 /** @hide */ public static int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInt(fd, level, option); } getsockoptLinger(FileDescriptor fd, int level, int option)195 /** @hide */ public static StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptLinger(fd, level, option); } getsockoptTimeval(FileDescriptor fd, int level, int option)196 /** @hide */ public static StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptTimeval(fd, level, option); } getsockoptUcred(FileDescriptor fd, int level, int option)197 /** @hide */ public static StructUcred getsockoptUcred(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptUcred(fd, level, option); } 198 199 /** 200 * See <a href="http://man7.org/linux/man-pages/man2/gettid.2.html">gettid(2)</a>. 201 */ gettid()202 public static int gettid() { return Libcore.os.gettid(); } 203 204 /** 205 * See <a href="http://man7.org/linux/man-pages/man2/getuid.2.html">getuid(2)</a>. 206 */ getuid()207 public static int getuid() { return Libcore.os.getuid(); } 208 209 /** 210 * See <a href="http://man7.org/linux/man-pages/man3/if_indextoname.3.html">if_indextoname(3)</a>. 211 */ if_indextoname(int index)212 public static String if_indextoname(int index) { return Libcore.os.if_indextoname(index); } 213 214 /** 215 * See <a href="http://man7.org/linux/man-pages/man3/inet_pton.3.html">inet_pton(3)</a>. 216 */ inet_pton(int family, String address)217 public static InetAddress inet_pton(int family, String address) { return Libcore.os.inet_pton(family, address); } 218 ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName)219 /** @hide */ public static InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return Libcore.os.ioctlInetAddress(fd, cmd, interfaceName); } ioctlInt(FileDescriptor fd, int cmd, MutableInt arg)220 /** @hide */ public static int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return Libcore.os.ioctlInt(fd, cmd, arg); } 221 222 /** 223 * See <a href="http://man7.org/linux/man-pages/man3/isatty.3.html">isatty(3)</a>. 224 */ isatty(FileDescriptor fd)225 public static boolean isatty(FileDescriptor fd) { return Libcore.os.isatty(fd); } 226 227 /** 228 * See <a href="http://man7.org/linux/man-pages/man2/kill.2.html">kill(2)</a>. 229 */ kill(int pid, int signal)230 public static void kill(int pid, int signal) throws ErrnoException { Libcore.os.kill(pid, signal); } 231 232 /** 233 * See <a href="http://man7.org/linux/man-pages/man2/lchown.2.html">lchown(2)</a>. 234 */ lchown(String path, int uid, int gid)235 public static void lchown(String path, int uid, int gid) throws ErrnoException { Libcore.os.lchown(path, uid, gid); } 236 237 /** 238 * See <a href="http://man7.org/linux/man-pages/man2/link.2.html">link(2)</a>. 239 */ link(String oldPath, String newPath)240 public static void link(String oldPath, String newPath) throws ErrnoException { Libcore.os.link(oldPath, newPath); } 241 242 /** 243 * See <a href="http://man7.org/linux/man-pages/man2/listen.2.html">listen(2)</a>. 244 */ listen(FileDescriptor fd, int backlog)245 public static void listen(FileDescriptor fd, int backlog) throws ErrnoException { Libcore.os.listen(fd, backlog); } 246 247 /** 248 * See <a href="http://man7.org/linux/man-pages/man2/lseek.2.html">lseek(2)</a>. 249 */ lseek(FileDescriptor fd, long offset, int whence)250 public static long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return Libcore.os.lseek(fd, offset, whence); } 251 252 /** 253 * See <a href="http://man7.org/linux/man-pages/man2/lstat.2.html">lstat(2)</a>. 254 */ lstat(String path)255 public static StructStat lstat(String path) throws ErrnoException { return Libcore.os.lstat(path); } 256 257 /** 258 * See <a href="http://man7.org/linux/man-pages/man2/mincore.2.html">mincore(2)</a>. 259 */ mincore(long address, long byteCount, byte[] vector)260 public static void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { Libcore.os.mincore(address, byteCount, vector); } 261 262 /** 263 * See <a href="http://man7.org/linux/man-pages/man2/mkdir.2.html">mkdir(2)</a>. 264 */ mkdir(String path, int mode)265 public static void mkdir(String path, int mode) throws ErrnoException { Libcore.os.mkdir(path, mode); } 266 267 /** 268 * See <a href="http://man7.org/linux/man-pages/man3/mkfifo.3.html">mkfifo(3)</a>. 269 */ mkfifo(String path, int mode)270 public static void mkfifo(String path, int mode) throws ErrnoException { Libcore.os.mkfifo(path, mode); } 271 272 /** 273 * See <a href="http://man7.org/linux/man-pages/man2/mlock.2.html">mlock(2)</a>. 274 */ mlock(long address, long byteCount)275 public static void mlock(long address, long byteCount) throws ErrnoException { Libcore.os.mlock(address, byteCount); } 276 277 /** 278 * See <a href="http://man7.org/linux/man-pages/man2/mmap.2.html">mmap(2)</a>. 279 */ mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset)280 public static long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException { return Libcore.os.mmap(address, byteCount, prot, flags, fd, offset); } 281 282 /** 283 * See <a href="http://man7.org/linux/man-pages/man2/msync.2.html">msync(2)</a>. 284 */ msync(long address, long byteCount, int flags)285 public static void msync(long address, long byteCount, int flags) throws ErrnoException { Libcore.os.msync(address, byteCount, flags); } 286 287 /** 288 * See <a href="http://man7.org/linux/man-pages/man2/munlock.2.html">munlock(2)</a>. 289 */ munlock(long address, long byteCount)290 public static void munlock(long address, long byteCount) throws ErrnoException { Libcore.os.munlock(address, byteCount); } 291 292 /** 293 * See <a href="http://man7.org/linux/man-pages/man2/munmap.2.html">munmap(2)</a>. 294 */ munmap(long address, long byteCount)295 public static void munmap(long address, long byteCount) throws ErrnoException { Libcore.os.munmap(address, byteCount); } 296 297 /** 298 * See <a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>. 299 */ open(String path, int flags, int mode)300 public static FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return Libcore.os.open(path, flags, mode); } 301 302 /** 303 * See <a href="http://man7.org/linux/man-pages/man2/pipe.2.html">pipe(2)</a>. 304 */ pipe()305 public static FileDescriptor[] pipe() throws ErrnoException { return Libcore.os.pipe(); } 306 307 /** 308 * See <a href="http://man7.org/linux/man-pages/man2/poll.2.html">poll(2)</a>. 309 */ poll(StructPollfd[] fds, int timeoutMs)310 public static int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { return Libcore.os.poll(fds, timeoutMs); } 311 312 /** 313 * See <a href="http://man7.org/linux/man-pages/man2/posix_fallocate.2.html">posix_fallocate(2)</a>. 314 */ posix_fallocate(FileDescriptor fd, long offset, long length)315 public static void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException { Libcore.os.posix_fallocate(fd, offset, length); } 316 317 /** 318 * See <a href="http://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a>. 319 */ prctl(int option, long arg2, long arg3, long arg4, long arg5)320 public static int prctl(int option, long arg2, long arg3, long arg4, long arg5) throws ErrnoException { return Libcore.os.prctl(option, arg2, arg3, arg4, arg5); }; 321 322 /** 323 * See <a href="http://man7.org/linux/man-pages/man2/pread.2.html">pread(2)</a>. 324 */ pread(FileDescriptor fd, ByteBuffer buffer, long offset)325 public static int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, buffer, offset); } 326 327 /** 328 * See <a href="http://man7.org/linux/man-pages/man2/pread.2.html">pread(2)</a>. 329 */ pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset)330 public static int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, bytes, byteOffset, byteCount, offset); } 331 332 /** 333 * See <a href="http://man7.org/linux/man-pages/man2/pwrite.2.html">pwrite(2)</a>. 334 */ pwrite(FileDescriptor fd, ByteBuffer buffer, long offset)335 public static int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, buffer, offset); } 336 337 /** 338 * See <a href="http://man7.org/linux/man-pages/man2/pwrite.2.html">pwrite(2)</a>. 339 */ pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset)340 public static int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, bytes, byteOffset, byteCount, offset); } 341 342 /** 343 * See <a href="http://man7.org/linux/man-pages/man2/read.2.html">read(2)</a>. 344 */ read(FileDescriptor fd, ByteBuffer buffer)345 public static int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, buffer); } 346 347 /** 348 * See <a href="http://man7.org/linux/man-pages/man2/read.2.html">read(2)</a>. 349 */ read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount)350 public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, bytes, byteOffset, byteCount); } 351 352 /** 353 * See <a href="http://man7.org/linux/man-pages/man2/readlink.2.html">readlink(2)</a>. 354 */ readlink(String path)355 public static String readlink(String path) throws ErrnoException { return Libcore.os.readlink(path); } 356 357 /** 358 * See <a href="http://man7.org/linux/man-pages/man2/readv.2.html">readv(2)</a>. 359 */ readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts)360 public static int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.readv(fd, buffers, offsets, byteCounts); } 361 362 /** 363 * See <a href="http://man7.org/linux/man-pages/man2/recvfrom.2.html">recvfrom(2)</a>. 364 */ recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress)365 public static int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, buffer, flags, srcAddress); } 366 367 /** 368 * See <a href="http://man7.org/linux/man-pages/man2/recvfrom.2.html">recvfrom(2)</a>. 369 */ recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress)370 public static int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress); } 371 372 /** 373 * See <a href="http://man7.org/linux/man-pages/man3/remove.3.html">remove(3)</a>. 374 */ remove(String path)375 public static void remove(String path) throws ErrnoException { Libcore.os.remove(path); } 376 377 /** 378 * See <a href="http://man7.org/linux/man-pages/man2/rename.2.html">rename(2)</a>. 379 */ rename(String oldPath, String newPath)380 public static void rename(String oldPath, String newPath) throws ErrnoException { Libcore.os.rename(oldPath, newPath); } 381 382 /** 383 * See <a href="http://man7.org/linux/man-pages/man2/sendfile.2.html">sendfile(2)</a>. 384 */ sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount)385 public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return Libcore.os.sendfile(outFd, inFd, inOffset, byteCount); } 386 387 /** 388 * See <a href="http://man7.org/linux/man-pages/man2/sendto.2.html">sendto(2)</a>. 389 */ sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port)390 public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, buffer, flags, inetAddress, port); } 391 392 /** 393 * See <a href="http://man7.org/linux/man-pages/man2/sendto.2.html">sendto(2)</a>. 394 */ sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port)395 public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); } 396 397 /** 398 * See <a href="http://man7.org/linux/man-pages/man2/setegid.2.html">setegid(2)</a>. 399 */ setegid(int egid)400 public static void setegid(int egid) throws ErrnoException { Libcore.os.setegid(egid); } 401 402 /** 403 * See <a href="http://man7.org/linux/man-pages/man3/setenv.3.html">setenv(3)</a>. 404 */ setenv(String name, String value, boolean overwrite)405 public static void setenv(String name, String value, boolean overwrite) throws ErrnoException { Libcore.os.setenv(name, value, overwrite); } 406 407 /** 408 * See <a href="http://man7.org/linux/man-pages/man2/seteuid.2.html">seteuid(2)</a>. 409 */ seteuid(int euid)410 public static void seteuid(int euid) throws ErrnoException { Libcore.os.seteuid(euid); } 411 412 /** 413 * See <a href="http://man7.org/linux/man-pages/man2/setgid.2.html">setgid(2)</a>. 414 */ setgid(int gid)415 public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); } 416 417 /** 418 * See <a href="http://man7.org/linux/man-pages/man2/setsid.2.html">setsid(2)</a>. 419 */ setsid()420 public static int setsid() throws ErrnoException { return Libcore.os.setsid(); } 421 setsockoptByte(FileDescriptor fd, int level, int option, int value)422 /** @hide */ public static void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptByte(fd, level, option, value); } setsockoptIfreq(FileDescriptor fd, int level, int option, String value)423 /** @hide */ public static void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException { Libcore.os.setsockoptIfreq(fd, level, option, value); } setsockoptInt(FileDescriptor fd, int level, int option, int value)424 /** @hide */ public static void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptInt(fd, level, option, value); } setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value)425 /** @hide */ public static void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptIpMreqn(fd, level, option, value); } setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value)426 /** @hide */ public static void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException { Libcore.os.setsockoptGroupReq(fd, level, option, value); } setsockoptGroupSourceReq(FileDescriptor fd, int level, int option, StructGroupSourceReq value)427 /** @hide */ public static void setsockoptGroupSourceReq(FileDescriptor fd, int level, int option, StructGroupSourceReq value) throws ErrnoException { Libcore.os.setsockoptGroupSourceReq(fd, level, option, value); } setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value)428 /** @hide */ public static void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { Libcore.os.setsockoptLinger(fd, level, option, value); } setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value)429 /** @hide */ public static void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { Libcore.os.setsockoptTimeval(fd, level, option, value); } 430 431 /** 432 * See <a href="http://man7.org/linux/man-pages/man2/setuid.2.html">setuid(2)</a>. 433 */ setuid(int uid)434 public static void setuid(int uid) throws ErrnoException { Libcore.os.setuid(uid); } 435 436 /** 437 * See <a href="http://man7.org/linux/man-pages/man2/shutdown.2.html">shutdown(2)</a>. 438 */ shutdown(FileDescriptor fd, int how)439 public static void shutdown(FileDescriptor fd, int how) throws ErrnoException { Libcore.os.shutdown(fd, how); } 440 441 /** 442 * See <a href="http://man7.org/linux/man-pages/man2/socket.2.html">socket(2)</a>. 443 */ socket(int domain, int type, int protocol)444 public static FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return Libcore.os.socket(domain, type, protocol); } 445 446 /** 447 * See <a href="http://man7.org/linux/man-pages/man2/socketpair.2.html">socketpair(2)</a>. 448 */ socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2)449 public static void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException { Libcore.os.socketpair(domain, type, protocol, fd1, fd2); } 450 451 /** 452 * See <a href="http://man7.org/linux/man-pages/man2/stat.2.html">stat(2)</a>. 453 */ stat(String path)454 public static StructStat stat(String path) throws ErrnoException { return Libcore.os.stat(path); } 455 456 /** 457 * See <a href="http://man7.org/linux/man-pages/man2/statvfs.2.html">statvfs(2)</a>. 458 */ statvfs(String path)459 public static StructStatVfs statvfs(String path) throws ErrnoException { return Libcore.os.statvfs(path); } 460 461 /** 462 * See <a href="http://man7.org/linux/man-pages/man3/strerror.3.html">strerror(2)</a>. 463 */ strerror(int errno)464 public static String strerror(int errno) { return Libcore.os.strerror(errno); } 465 466 /** 467 * See <a href="http://man7.org/linux/man-pages/man3/strsignal.3.html">strsignal(3)</a>. 468 */ strsignal(int signal)469 public static String strsignal(int signal) { return Libcore.os.strsignal(signal); } 470 471 /** 472 * See <a href="http://man7.org/linux/man-pages/man2/symlink.2.html">symlink(2)</a>. 473 */ symlink(String oldPath, String newPath)474 public static void symlink(String oldPath, String newPath) throws ErrnoException { Libcore.os.symlink(oldPath, newPath); } 475 476 /** 477 * See <a href="http://man7.org/linux/man-pages/man3/sysconf.3.html">sysconf(3)</a>. 478 */ sysconf(int name)479 public static long sysconf(int name) { return Libcore.os.sysconf(name); } 480 481 /** 482 * See <a href="http://man7.org/linux/man-pages/man3/tcdrain.3.html">tcdrain(3)</a>. 483 */ tcdrain(FileDescriptor fd)484 public static void tcdrain(FileDescriptor fd) throws ErrnoException { Libcore.os.tcdrain(fd); } 485 486 /** 487 * See <a href="http://man7.org/linux/man-pages/man3/tcsendbreak.3.html">tcsendbreak(3)</a>. 488 */ tcsendbreak(FileDescriptor fd, int duration)489 public static void tcsendbreak(FileDescriptor fd, int duration) throws ErrnoException { Libcore.os.tcsendbreak(fd, duration); } 490 491 /** 492 * See <a href="http://man7.org/linux/man-pages/man2/umask.2.html">umask(2)</a>. 493 */ umask(int mask)494 public static int umask(int mask) { return Libcore.os.umask(mask); } 495 496 /** 497 * See <a href="http://man7.org/linux/man-pages/man2/uname.2.html">uname(2)</a>. 498 */ uname()499 public static StructUtsname uname() { return Libcore.os.uname(); } 500 501 /** 502 * See <a href="http://man7.org/linux/man-pages/man3/unsetenv.3.html">unsetenv(3)</a>. 503 */ unsetenv(String name)504 public static void unsetenv(String name) throws ErrnoException { Libcore.os.unsetenv(name); } 505 506 /** 507 * See <a href="http://man7.org/linux/man-pages/man2/waitpid.2.html">waitpid(2)</a>. 508 */ waitpid(int pid, MutableInt status, int options)509 public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return Libcore.os.waitpid(pid, status, options); } 510 511 /** 512 * See <a href="http://man7.org/linux/man-pages/man2/write.2.html">write(2)</a>. 513 */ write(FileDescriptor fd, ByteBuffer buffer)514 public static int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, buffer); } 515 516 /** 517 * See <a href="http://man7.org/linux/man-pages/man2/write.2.html">write(2)</a>. 518 */ write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount)519 public static int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, bytes, byteOffset, byteCount); } 520 521 /** 522 * See <a href="http://man7.org/linux/man-pages/man2/writev.2.html">writev(2)</a>. 523 */ writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts)524 public static int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.writev(fd, buffers, offsets, byteCounts); } 525 } 526