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