summaryrefslogtreecommitdiff
path: root/android/system
diff options
context:
space:
mode:
authorJustin Klaassen <justinklaassen@google.com>2017-09-15 17:58:39 -0400
committerJustin Klaassen <justinklaassen@google.com>2017-09-15 17:58:39 -0400
commit10d07c88d69cc64f73a069163e7ea5ba2519a099 (patch)
tree8dbd149eb350320a29c3d10e7ad3201de1c5cbee /android/system
parent677516fb6b6f207d373984757d3d9450474b6b00 (diff)
downloadandroid-28-10d07c88d69cc64f73a069163e7ea5ba2519a099.tar.gz
Import Android SDK Platform PI [4335822]
/google/data/ro/projects/android/fetch_artifact \ --bid 4335822 \ --target sdk_phone_armv7-win_sdk \ sdk-repo-linux-sources-4335822.zip AndroidVersion.ApiLevel has been modified to appear as 28 Change-Id: Ic8f04be005a71c2b9abeaac754d8da8d6f9a2c32
Diffstat (limited to 'android/system')
-rw-r--r--android/system/ErrnoException.java82
-rw-r--r--android/system/GaiException.java83
-rw-r--r--android/system/NetlinkSocketAddress.java61
-rw-r--r--android/system/Os.java627
-rw-r--r--android/system/OsConstants.java925
-rw-r--r--android/system/PacketSocketAddress.java64
-rw-r--r--android/system/StructAddrinfo.java58
-rw-r--r--android/system/StructCapUserData.java48
-rw-r--r--android/system/StructCapUserHeader.java48
-rw-r--r--android/system/StructFlock.java47
-rw-r--r--android/system/StructGroupReq.java39
-rw-r--r--android/system/StructGroupSourceReq.java41
-rw-r--r--android/system/StructIcmpHdr.java62
-rw-r--r--android/system/StructIfaddrs.java47
-rw-r--r--android/system/StructLinger.java46
-rw-r--r--android/system/StructPasswd.java48
-rw-r--r--android/system/StructPollfd.java49
-rw-r--r--android/system/StructRlimit.java39
-rw-r--r--android/system/StructStat.java121
-rw-r--r--android/system/StructStatVfs.java80
-rw-r--r--android/system/StructTimespec.java79
-rw-r--r--android/system/StructTimeval.java52
-rw-r--r--android/system/StructUcred.java45
-rw-r--r--android/system/StructUtsname.java55
-rw-r--r--android/system/UnixSocketAddress.java119
-rw-r--r--android/system/UnixSocketAddressTest.java51
26 files changed, 3016 insertions, 0 deletions
diff --git a/android/system/ErrnoException.java b/android/system/ErrnoException.java
new file mode 100644
index 00000000..90155c89
--- /dev/null
+++ b/android/system/ErrnoException.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.io.IOException;
+import java.net.SocketException;
+import libcore.io.Libcore;
+
+/**
+ * A checked exception thrown when {@link Os} methods fail. This exception contains the native
+ * errno value, for comparison against the constants in {@link OsConstants}, should sophisticated
+ * callers need to adjust their behavior based on the exact failure.
+ */
+public final class ErrnoException extends Exception {
+ private final String functionName;
+
+ /**
+ * The errno value, for comparison with the {@code E} constants in {@link OsConstants}.
+ */
+ public final int errno;
+
+ /**
+ * Constructs an instance with the given function name and errno value.
+ */
+ public ErrnoException(String functionName, int errno) {
+ this.functionName = functionName;
+ this.errno = errno;
+ }
+
+ /**
+ * Constructs an instance with the given function name, errno value, and cause.
+ */
+ public ErrnoException(String functionName, int errno, Throwable cause) {
+ super(cause);
+ this.functionName = functionName;
+ this.errno = errno;
+ }
+
+ /**
+ * Converts the stashed function name and errno value to a human-readable string.
+ * We do this here rather than in the constructor so that callers only pay for
+ * this if they need it.
+ */
+ @Override public String getMessage() {
+ String errnoName = OsConstants.errnoName(errno);
+ if (errnoName == null) {
+ errnoName = "errno " + errno;
+ }
+ String description = Libcore.os.strerror(errno);
+ return functionName + " failed: " + errnoName + " (" + description + ")";
+ }
+
+ /**
+ * @hide - internal use only.
+ */
+ public IOException rethrowAsIOException() throws IOException {
+ IOException newException = new IOException(getMessage());
+ newException.initCause(this);
+ throw newException;
+ }
+
+ /**
+ * @hide - internal use only.
+ */
+ public SocketException rethrowAsSocketException() throws SocketException {
+ throw new SocketException(getMessage(), this);
+ }
+}
diff --git a/android/system/GaiException.java b/android/system/GaiException.java
new file mode 100644
index 00000000..dc105668
--- /dev/null
+++ b/android/system/GaiException.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.net.UnknownHostException;
+import libcore.io.Libcore;
+
+/**
+ * An unchecked exception thrown when {@code getaddrinfo} or {@code getnameinfo} fails.
+ * This exception contains the native {@link #error} value, should sophisticated
+ * callers need to adjust their behavior based on the exact failure.
+ *
+ * @hide
+ */
+public final class GaiException extends RuntimeException {
+ private final String functionName;
+
+ /**
+ * The native error value, for comparison with the {@code GAI_} constants in {@link OsConstants}.
+ */
+ public final int error;
+
+ /**
+ * Constructs an instance with the given function name and error value.
+ */
+ public GaiException(String functionName, int error) {
+ this.functionName = functionName;
+ this.error = error;
+ }
+
+ /**
+ * Constructs an instance with the given function name, error value, and cause.
+ */
+ public GaiException(String functionName, int error, Throwable cause) {
+ super(cause);
+ this.functionName = functionName;
+ this.error = error;
+ }
+
+ /**
+ * Converts the stashed function name and error value to a human-readable string.
+ * We do this here rather than in the constructor so that callers only pay for
+ * this if they need it.
+ */
+ @Override public String getMessage() {
+ String gaiName = OsConstants.gaiName(error);
+ if (gaiName == null) {
+ gaiName = "GAI_ error " + error;
+ }
+ String description = Libcore.os.gai_strerror(error);
+ return functionName + " failed: " + gaiName + " (" + description + ")";
+ }
+
+ /**
+ * @hide - internal use only.
+ */
+ public UnknownHostException rethrowAsUnknownHostException(String detailMessage) throws UnknownHostException {
+ UnknownHostException newException = new UnknownHostException(detailMessage);
+ newException.initCause(this);
+ throw newException;
+ }
+
+ /**
+ * @hide - internal use only.
+ */
+ public UnknownHostException rethrowAsUnknownHostException() throws UnknownHostException {
+ throw rethrowAsUnknownHostException(getMessage());
+ }
+}
diff --git a/android/system/NetlinkSocketAddress.java b/android/system/NetlinkSocketAddress.java
new file mode 100644
index 00000000..af78cd09
--- /dev/null
+++ b/android/system/NetlinkSocketAddress.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+import java.net.SocketAddress;
+
+/**
+ * Netlink socket address.
+ *
+ * Corresponds to Linux's {@code struct sockaddr_nl} from
+ * <a href="https://github.com/torvalds/linux/blob/master/include/uapi/linux/netlink.h">&lt;linux/netlink.h&gt;</a>.
+ *
+ * @hide
+ */
+public final class NetlinkSocketAddress extends SocketAddress {
+ /** port ID */
+ private final int nlPortId;
+
+ /** multicast groups mask */
+ private final int nlGroupsMask;
+
+ public NetlinkSocketAddress() {
+ this(0, 0);
+ }
+
+ public NetlinkSocketAddress(int nlPortId) {
+ this(nlPortId, 0);
+ }
+
+ public NetlinkSocketAddress(int nlPortId, int nlGroupsMask) {
+ this.nlPortId = nlPortId;
+ this.nlGroupsMask = nlGroupsMask;
+ }
+
+ public int getPortId() {
+ return nlPortId;
+ }
+
+ public int getGroupsMask() {
+ return nlGroupsMask;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/Os.java b/android/system/Os.java
new file mode 100644
index 00000000..5b9ff476
--- /dev/null
+++ b/android/system/Os.java
@@ -0,0 +1,627 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import android.util.MutableInt;
+import android.util.MutableLong;
+import java.io.FileDescriptor;
+import java.io.InterruptedIOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.nio.ByteBuffer;
+import libcore.io.Libcore;
+
+/**
+ * Access to low-level system functionality. Most of these are system calls. Most users will want
+ * to use higher-level APIs where available, but this class provides access to the underlying
+ * primitives used to implement the higher-level APIs.
+ *
+ * <p>The corresponding constants can be found in {@link OsConstants}.
+ */
+public final class Os {
+ private Os() {}
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/accept.2.html">accept(2)</a>.
+ */
+ public static FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { return Libcore.os.accept(fd, peerAddress); }
+
+ /**
+ * TODO Change the public API by removing the overload above and unhiding this version.
+ * @hide
+ */
+ public static FileDescriptor accept(FileDescriptor fd, SocketAddress peerAddress) throws ErrnoException, SocketException { return Libcore.os.accept(fd, peerAddress); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/access.2.html">access(2)</a>.
+ */
+ public static boolean access(String path, int mode) throws ErrnoException { return Libcore.os.access(path, mode); }
+
+ /** @hide */ public static InetAddress[] android_getaddrinfo(String node, StructAddrinfo hints, int netId) throws GaiException { return Libcore.os.android_getaddrinfo(node, hints, netId); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/bind.2.html">bind(2)</a>.
+ */
+ public static void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.bind(fd, address, port); }
+
+ /** @hide */ public static void bind(FileDescriptor fd, SocketAddress address) throws ErrnoException, SocketException { Libcore.os.bind(fd, address); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>.
+ *
+ * @hide
+ */
+ public static StructCapUserData[] capget(StructCapUserHeader hdr) throws ErrnoException {
+ return Libcore.os.capget(hdr);
+ }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/capset.2.html">capset(2)</a>.
+ *
+ * @hide
+ */
+ public static void capset(StructCapUserHeader hdr, StructCapUserData[] data)
+ throws ErrnoException {
+ Libcore.os.capset(hdr, data);
+ }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/chmod.2.html">chmod(2)</a>.
+ */
+ public static void chmod(String path, int mode) throws ErrnoException { Libcore.os.chmod(path, mode); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/chown.2.html">chown(2)</a>.
+ */
+ public static void chown(String path, int uid, int gid) throws ErrnoException { Libcore.os.chown(path, uid, gid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/close.2.html">close(2)</a>.
+ */
+ public static void close(FileDescriptor fd) throws ErrnoException { Libcore.os.close(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/connect.2.html">connect(2)</a>.
+ */
+ public static void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.connect(fd, address, port); }
+
+ /** @hide */ public static void connect(FileDescriptor fd, SocketAddress address) throws ErrnoException, SocketException { Libcore.os.connect(fd, address); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/dup.2.html">dup(2)</a>.
+ */
+ public static FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return Libcore.os.dup(oldFd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/dup2.2.html">dup2(2)</a>.
+ */
+ public static FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return Libcore.os.dup2(oldFd, newFd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/environ.3.html">environ(3)</a>.
+ */
+ public static String[] environ() { return Libcore.os.environ(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/execv.2.html">execv(2)</a>.
+ */
+ public static void execv(String filename, String[] argv) throws ErrnoException { Libcore.os.execv(filename, argv); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/execve.2.html">execve(2)</a>.
+ */
+ public static void execve(String filename, String[] argv, String[] envp) throws ErrnoException { Libcore.os.execve(filename, argv, envp); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fchmod.2.html">fchmod(2)</a>.
+ */
+ public static void fchmod(FileDescriptor fd, int mode) throws ErrnoException { Libcore.os.fchmod(fd, mode); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fchown.2.html">fchown(2)</a>.
+ */
+ public static void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { Libcore.os.fchown(fd, uid, gid); }
+
+ /** @hide */ public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException, InterruptedIOException { return Libcore.os.fcntlFlock(fd, cmd, arg); }
+ /** @hide */ public static int fcntlInt(FileDescriptor fd, int cmd, int arg) throws ErrnoException { return Libcore.os.fcntlInt(fd, cmd, arg); }
+ /** @hide */ public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fdatasync.2.html">fdatasync(2)</a>.
+ */
+ public static void fdatasync(FileDescriptor fd) throws ErrnoException { Libcore.os.fdatasync(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fstat.2.html">fstat(2)</a>.
+ */
+ public static StructStat fstat(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstat(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fstatvfs.2.html">fstatvfs(2)</a>.
+ */
+ public static StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstatvfs(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fsync.2.html">fsync(2)</a>.
+ */
+ public static void fsync(FileDescriptor fd) throws ErrnoException { Libcore.os.fsync(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/ftruncate.2.html">ftruncate(2)</a>.
+ */
+ public static void ftruncate(FileDescriptor fd, long length) throws ErrnoException { Libcore.os.ftruncate(fd, length); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/gai_strerror.3.html">gai_strerror(3)</a>.
+ */
+ public static String gai_strerror(int error) { return Libcore.os.gai_strerror(error); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getegid.2.html">getegid(2)</a>.
+ */
+ public static int getegid() { return Libcore.os.getegid(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/geteuid.2.html">geteuid(2)</a>.
+ */
+ public static int geteuid() { return Libcore.os.geteuid(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getgid.2.html">getgid(2)</a>.
+ */
+ public static int getgid() { return Libcore.os.getgid(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/getenv.3.html">getenv(3)</a>.
+ */
+ public static String getenv(String name) { return Libcore.os.getenv(name); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/getifaddrs.3.html">getifaddrs(3)</a>.
+ */
+ /** @hide */ public static StructIfaddrs[] getifaddrs() throws ErrnoException { return Libcore.os.getifaddrs(); }
+
+ /** @hide */ public static String getnameinfo(InetAddress address, int flags) throws GaiException { return Libcore.os.getnameinfo(address, flags); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getpeername.2.html">getpeername(2)</a>.
+ */
+ public static SocketAddress getpeername(FileDescriptor fd) throws ErrnoException { return Libcore.os.getpeername(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getpgid.2.html">getpgid(2)</a>.
+ */
+ /** @hide */ public static int getpgid(int pid) throws ErrnoException { return Libcore.os.getpgid(pid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getpid.2.html">getpid(2)</a>.
+ */
+ public static int getpid() { return Libcore.os.getpid(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getppid.2.html">getppid(2)</a>.
+ */
+ public static int getppid() { return Libcore.os.getppid(); }
+
+ /** @hide */ public static StructPasswd getpwnam(String name) throws ErrnoException { return Libcore.os.getpwnam(name); }
+
+ /** @hide */ public static StructPasswd getpwuid(int uid) throws ErrnoException { return Libcore.os.getpwuid(uid); }
+
+ /** @hide */ public static StructRlimit getrlimit(int resource) throws ErrnoException { return Libcore.os.getrlimit(resource); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getsockname.2.html">getsockname(2)</a>.
+ */
+ public static SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return Libcore.os.getsockname(fd); }
+
+ /** @hide */ public static int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptByte(fd, level, option); }
+ /** @hide */ public static InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInAddr(fd, level, option); }
+ /** @hide */ public static int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInt(fd, level, option); }
+ /** @hide */ public static StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptLinger(fd, level, option); }
+ /** @hide */ public static StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptTimeval(fd, level, option); }
+ /** @hide */ public static StructUcred getsockoptUcred(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptUcred(fd, level, option); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/gettid.2.html">gettid(2)</a>.
+ */
+ public static int gettid() { return Libcore.os.gettid(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getuid.2.html">getuid(2)</a>.
+ */
+ public static int getuid() { return Libcore.os.getuid(); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/getxattr.2.html">getxattr(2)</a>
+ */
+ public static byte[] getxattr(String path, String name) throws ErrnoException { return Libcore.os.getxattr(path, name); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/if_indextoname.3.html">if_indextoname(3)</a>.
+ */
+ public static String if_indextoname(int index) { return Libcore.os.if_indextoname(index); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/if_nametoindex.3.html">if_nametoindex(3)</a>.
+ */
+ public static int if_nametoindex(String name) { return Libcore.os.if_nametoindex(name); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/inet_pton.3.html">inet_pton(3)</a>.
+ */
+ public static InetAddress inet_pton(int family, String address) { return Libcore.os.inet_pton(family, address); }
+
+ /** @hide */ public static InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return Libcore.os.ioctlInetAddress(fd, cmd, interfaceName); }
+ /** @hide */ public static int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return Libcore.os.ioctlInt(fd, cmd, arg); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/isatty.3.html">isatty(3)</a>.
+ */
+ public static boolean isatty(FileDescriptor fd) { return Libcore.os.isatty(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/kill.2.html">kill(2)</a>.
+ */
+ public static void kill(int pid, int signal) throws ErrnoException { Libcore.os.kill(pid, signal); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/lchown.2.html">lchown(2)</a>.
+ */
+ public static void lchown(String path, int uid, int gid) throws ErrnoException { Libcore.os.lchown(path, uid, gid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/link.2.html">link(2)</a>.
+ */
+ public static void link(String oldPath, String newPath) throws ErrnoException { Libcore.os.link(oldPath, newPath); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/listen.2.html">listen(2)</a>.
+ */
+ public static void listen(FileDescriptor fd, int backlog) throws ErrnoException { Libcore.os.listen(fd, backlog); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/listxattr.2.html">listxattr(2)</a>
+ */
+ public static String[] listxattr(String path) throws ErrnoException { return Libcore.os.listxattr(path); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/lseek.2.html">lseek(2)</a>.
+ */
+ public static long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return Libcore.os.lseek(fd, offset, whence); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/lstat.2.html">lstat(2)</a>.
+ */
+ public static StructStat lstat(String path) throws ErrnoException { return Libcore.os.lstat(path); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/mincore.2.html">mincore(2)</a>.
+ */
+ public static void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { Libcore.os.mincore(address, byteCount, vector); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/mkdir.2.html">mkdir(2)</a>.
+ */
+ public static void mkdir(String path, int mode) throws ErrnoException { Libcore.os.mkdir(path, mode); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/mkfifo.3.html">mkfifo(3)</a>.
+ */
+ public static void mkfifo(String path, int mode) throws ErrnoException { Libcore.os.mkfifo(path, mode); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/mlock.2.html">mlock(2)</a>.
+ */
+ public static void mlock(long address, long byteCount) throws ErrnoException { Libcore.os.mlock(address, byteCount); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/mmap.2.html">mmap(2)</a>.
+ */
+ 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); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/msync.2.html">msync(2)</a>.
+ */
+ public static void msync(long address, long byteCount, int flags) throws ErrnoException { Libcore.os.msync(address, byteCount, flags); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/munlock.2.html">munlock(2)</a>.
+ */
+ public static void munlock(long address, long byteCount) throws ErrnoException { Libcore.os.munlock(address, byteCount); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/munmap.2.html">munmap(2)</a>.
+ */
+ public static void munmap(long address, long byteCount) throws ErrnoException { Libcore.os.munmap(address, byteCount); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>.
+ */
+ public static FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return Libcore.os.open(path, flags, mode); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/pipe.2.html">pipe(2)</a>.
+ */
+ public static FileDescriptor[] pipe() throws ErrnoException { return Libcore.os.pipe2(0); }
+
+ /** @hide */ public static FileDescriptor[] pipe2(int flags) throws ErrnoException { return Libcore.os.pipe2(flags); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/poll.2.html">poll(2)</a>.
+ *
+ * <p>Note that in Lollipop this could throw an {@code ErrnoException} with {@code EINTR}.
+ * In later releases, the implementation will automatically just restart the system call with
+ * an appropriately reduced timeout.
+ */
+ public static int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { return Libcore.os.poll(fds, timeoutMs); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/posix_fallocate.3.html">posix_fallocate(3)</a>.
+ */
+ public static void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException { Libcore.os.posix_fallocate(fd, offset, length); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a>.
+ */
+ 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); };
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/pread.2.html">pread(2)</a>.
+ */
+ public static int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, buffer, offset); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/pread.2.html">pread(2)</a>.
+ */
+ 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); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/pwrite.2.html">pwrite(2)</a>.
+ */
+ public static int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, buffer, offset); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/pwrite.2.html">pwrite(2)</a>.
+ */
+ 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); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/read.2.html">read(2)</a>.
+ */
+ public static int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, buffer); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/read.2.html">read(2)</a>.
+ */
+ public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, bytes, byteOffset, byteCount); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/readlink.2.html">readlink(2)</a>.
+ */
+ public static String readlink(String path) throws ErrnoException { return Libcore.os.readlink(path); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/readv.2.html">readv(2)</a>.
+ */
+ public static int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.readv(fd, buffers, offsets, byteCounts); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/recvfrom.2.html">recvfrom(2)</a>.
+ */
+ public static int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, buffer, flags, srcAddress); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/recvfrom.2.html">recvfrom(2)</a>.
+ */
+ 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); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/remove.3.html">remove(3)</a>.
+ */
+ public static void remove(String path) throws ErrnoException { Libcore.os.remove(path); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/removexattr.2.html">removexattr(2)</a>.
+ */
+ public static void removexattr(String path, String name) throws ErrnoException { Libcore.os.removexattr(path, name); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/rename.2.html">rename(2)</a>.
+ */
+ public static void rename(String oldPath, String newPath) throws ErrnoException { Libcore.os.rename(oldPath, newPath); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/sendfile.2.html">sendfile(2)</a>.
+ */
+ public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return Libcore.os.sendfile(outFd, inFd, inOffset, byteCount); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/sendto.2.html">sendto(2)</a>.
+ */
+ 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); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/sendto.2.html">sendto(2)</a>.
+ */
+ 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); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/sendto.2.html">sendto(2)</a>.
+ */
+ /** @hide */ public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, SocketAddress address) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, address); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setegid.2.html">setegid(2)</a>.
+ */
+ public static void setegid(int egid) throws ErrnoException { Libcore.os.setegid(egid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/setenv.3.html">setenv(3)</a>.
+ */
+ public static void setenv(String name, String value, boolean overwrite) throws ErrnoException { Libcore.os.setenv(name, value, overwrite); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/seteuid.2.html">seteuid(2)</a>.
+ */
+ public static void seteuid(int euid) throws ErrnoException { Libcore.os.seteuid(euid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setgid.2.html">setgid(2)</a>.
+ */
+ public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setpgid.2.html">setpgid(2)</a>.
+ */
+ /** @hide */ public static void setpgid(int pid, int pgid) throws ErrnoException { Libcore.os.setpgid(pid, pgid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setregid.2.html">setregid(2)</a>.
+ */
+ /** @hide */ public static void setregid(int rgid, int egid) throws ErrnoException { Libcore.os.setregid(rgid, egid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setreuid.2.html">setreuid(2)</a>.
+ */
+ /** @hide */ public static void setreuid(int ruid, int euid) throws ErrnoException { Libcore.os.setreuid(ruid, euid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setsid.2.html">setsid(2)</a>.
+ */
+ public static int setsid() throws ErrnoException { return Libcore.os.setsid(); }
+
+ /** @hide */ public static void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptByte(fd, level, option, value); }
+ /** @hide */ public static void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException { Libcore.os.setsockoptIfreq(fd, level, option, value); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setsockopt.2.html">setsockopt(2)</a>.
+ */
+ public static void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptInt(fd, level, option, value); }
+
+ /** @hide */ public static void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptIpMreqn(fd, level, option, value); }
+ /** @hide */ public static void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException { Libcore.os.setsockoptGroupReq(fd, level, option, value); }
+ /** @hide */ public static void setsockoptGroupSourceReq(FileDescriptor fd, int level, int option, StructGroupSourceReq value) throws ErrnoException { Libcore.os.setsockoptGroupSourceReq(fd, level, option, value); }
+ /** @hide */ public static void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { Libcore.os.setsockoptLinger(fd, level, option, value); }
+ /** @hide */ public static void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { Libcore.os.setsockoptTimeval(fd, level, option, value); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setuid.2.html">setuid(2)</a>.
+ */
+ public static void setuid(int uid) throws ErrnoException { Libcore.os.setuid(uid); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/setxattr.2.html">setxattr(2)</a>
+ */
+ public static void setxattr(String path, String name, byte[] value, int flags) throws ErrnoException { Libcore.os.setxattr(path, name, value, flags); };
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/shutdown.2.html">shutdown(2)</a>.
+ */
+ public static void shutdown(FileDescriptor fd, int how) throws ErrnoException { Libcore.os.shutdown(fd, how); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/socket.2.html">socket(2)</a>.
+ */
+ public static FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return Libcore.os.socket(domain, type, protocol); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/socketpair.2.html">socketpair(2)</a>.
+ */
+ public static void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException { Libcore.os.socketpair(domain, type, protocol, fd1, fd2); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/stat.2.html">stat(2)</a>.
+ */
+ public static StructStat stat(String path) throws ErrnoException { return Libcore.os.stat(path); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/statvfs.2.html">statvfs(2)</a>.
+ */
+ public static StructStatVfs statvfs(String path) throws ErrnoException { return Libcore.os.statvfs(path); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/strerror.3.html">strerror(2)</a>.
+ */
+ public static String strerror(int errno) { return Libcore.os.strerror(errno); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/strsignal.3.html">strsignal(3)</a>.
+ */
+ public static String strsignal(int signal) { return Libcore.os.strsignal(signal); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/symlink.2.html">symlink(2)</a>.
+ */
+ public static void symlink(String oldPath, String newPath) throws ErrnoException { Libcore.os.symlink(oldPath, newPath); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/sysconf.3.html">sysconf(3)</a>.
+ */
+ public static long sysconf(int name) { return Libcore.os.sysconf(name); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/tcdrain.3.html">tcdrain(3)</a>.
+ */
+ public static void tcdrain(FileDescriptor fd) throws ErrnoException { Libcore.os.tcdrain(fd); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/tcsendbreak.3.html">tcsendbreak(3)</a>.
+ */
+ public static void tcsendbreak(FileDescriptor fd, int duration) throws ErrnoException { Libcore.os.tcsendbreak(fd, duration); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/umask.2.html">umask(2)</a>.
+ */
+ public static int umask(int mask) { return Libcore.os.umask(mask); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/uname.2.html">uname(2)</a>.
+ */
+ public static StructUtsname uname() { return Libcore.os.uname(); }
+
+ /**
+ * @hide See <a href="http://man7.org/linux/man-pages/man2/unlink.2.html">unlink(2)</a>.
+ */
+ public static void unlink(String pathname) throws ErrnoException { Libcore.os.unlink(pathname); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man3/unsetenv.3.html">unsetenv(3)</a>.
+ */
+ public static void unsetenv(String name) throws ErrnoException { Libcore.os.unsetenv(name); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/waitpid.2.html">waitpid(2)</a>.
+ */
+ public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return Libcore.os.waitpid(pid, status, options); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/write.2.html">write(2)</a>.
+ */
+ public static int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, buffer); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/write.2.html">write(2)</a>.
+ */
+ public static int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, bytes, byteOffset, byteCount); }
+
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/writev.2.html">writev(2)</a>.
+ */
+ public static int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.writev(fd, buffers, offsets, byteCounts); }
+}
diff --git a/android/system/OsConstants.java b/android/system/OsConstants.java
new file mode 100644
index 00000000..3e1f007d
--- /dev/null
+++ b/android/system/OsConstants.java
@@ -0,0 +1,925 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+/**
+ * Constants and helper functions for use with {@link Os}.
+ */
+public final class OsConstants {
+ private OsConstants() {
+ }
+
+ /**
+ * Returns the index of the element in the cap_user_data array that this capability is stored
+ * in.
+ * @hide
+ */
+ public static int CAP_TO_INDEX(int x) { return x >>> 5; }
+
+ /**
+ * Returns the mask for the given capability. This is relative to the capability's cap_user_data
+ * element, the index of which can be retrieved with CAP_TO_INDEX.
+ * @hide
+ */
+ public static int CAP_TO_MASK(int x) { return 1 << (x & 31); }
+
+ /**
+ * Tests whether the given mode is a block device.
+ */
+ public static boolean S_ISBLK(int mode) { return (mode & S_IFMT) == S_IFBLK; }
+
+ /**
+ * Tests whether the given mode is a character device.
+ */
+ public static boolean S_ISCHR(int mode) { return (mode & S_IFMT) == S_IFCHR; }
+
+ /**
+ * Tests whether the given mode is a directory.
+ */
+ public static boolean S_ISDIR(int mode) { return (mode & S_IFMT) == S_IFDIR; }
+
+ /**
+ * Tests whether the given mode is a FIFO.
+ */
+ public static boolean S_ISFIFO(int mode) { return (mode & S_IFMT) == S_IFIFO; }
+
+ /**
+ * Tests whether the given mode is a regular file.
+ */
+ public static boolean S_ISREG(int mode) { return (mode & S_IFMT) == S_IFREG; }
+
+ /**
+ * Tests whether the given mode is a symbolic link.
+ */
+ public static boolean S_ISLNK(int mode) { return (mode & S_IFMT) == S_IFLNK; }
+
+ /**
+ * Tests whether the given mode is a socket.
+ */
+ public static boolean S_ISSOCK(int mode) { return (mode & S_IFMT) == S_IFSOCK; }
+
+ /**
+ * Extracts the exit status of a child. Only valid if WIFEXITED returns true.
+ */
+ public static int WEXITSTATUS(int status) { return (status & 0xff00) >> 8; }
+
+ /**
+ * Tests whether the child dumped core. Only valid if WIFSIGNALED returns true.
+ */
+ public static boolean WCOREDUMP(int status) { return (status & 0x80) != 0; }
+
+ /**
+ * Returns the signal that caused the child to exit. Only valid if WIFSIGNALED returns true.
+ */
+ public static int WTERMSIG(int status) { return status & 0x7f; }
+
+ /**
+ * Returns the signal that cause the child to stop. Only valid if WIFSTOPPED returns true.
+ */
+ public static int WSTOPSIG(int status) { return WEXITSTATUS(status); }
+
+ /**
+ * Tests whether the child exited normally.
+ */
+ public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); }
+
+ /**
+ * Tests whether the child was stopped (not terminated) by a signal.
+ */
+ public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); }
+
+ /**
+ * Tests whether the child was terminated by a signal.
+ */
+ public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); }
+
+ public static final int AF_INET = placeholder();
+ public static final int AF_INET6 = placeholder();
+ /** @hide */ public static final int AF_NETLINK = placeholder();
+ /** @hide */ public static final int AF_PACKET = placeholder();
+ public static final int AF_UNIX = placeholder();
+ public static final int AF_UNSPEC = placeholder();
+ public static final int AI_ADDRCONFIG = placeholder();
+ public static final int AI_ALL = placeholder();
+ public static final int AI_CANONNAME = placeholder();
+ public static final int AI_NUMERICHOST = placeholder();
+ public static final int AI_NUMERICSERV = placeholder();
+ public static final int AI_PASSIVE = placeholder();
+ public static final int AI_V4MAPPED = placeholder();
+ /** @hide */ public static final int ARPHRD_ETHER = placeholder();
+ /** @hide */ public static final int ARPHRD_LOOPBACK = placeholder();
+ public static final int CAP_AUDIT_CONTROL = placeholder();
+ public static final int CAP_AUDIT_WRITE = placeholder();
+ public static final int CAP_BLOCK_SUSPEND = placeholder();
+ public static final int CAP_CHOWN = placeholder();
+ public static final int CAP_DAC_OVERRIDE = placeholder();
+ public static final int CAP_DAC_READ_SEARCH = placeholder();
+ public static final int CAP_FOWNER = placeholder();
+ public static final int CAP_FSETID = placeholder();
+ public static final int CAP_IPC_LOCK = placeholder();
+ public static final int CAP_IPC_OWNER = placeholder();
+ public static final int CAP_KILL = placeholder();
+ public static final int CAP_LAST_CAP = placeholder();
+ public static final int CAP_LEASE = placeholder();
+ public static final int CAP_LINUX_IMMUTABLE = placeholder();
+ public static final int CAP_MAC_ADMIN = placeholder();
+ public static final int CAP_MAC_OVERRIDE = placeholder();
+ public static final int CAP_MKNOD = placeholder();
+ public static final int CAP_NET_ADMIN = placeholder();
+ public static final int CAP_NET_BIND_SERVICE = placeholder();
+ public static final int CAP_NET_BROADCAST = placeholder();
+ public static final int CAP_NET_RAW = placeholder();
+ public static final int CAP_SETFCAP = placeholder();
+ public static final int CAP_SETGID = placeholder();
+ public static final int CAP_SETPCAP = placeholder();
+ public static final int CAP_SETUID = placeholder();
+ public static final int CAP_SYS_ADMIN = placeholder();
+ public static final int CAP_SYS_BOOT = placeholder();
+ public static final int CAP_SYS_CHROOT = placeholder();
+ public static final int CAP_SYSLOG = placeholder();
+ public static final int CAP_SYS_MODULE = placeholder();
+ public static final int CAP_SYS_NICE = placeholder();
+ public static final int CAP_SYS_PACCT = placeholder();
+ public static final int CAP_SYS_PTRACE = placeholder();
+ public static final int CAP_SYS_RAWIO = placeholder();
+ public static final int CAP_SYS_RESOURCE = placeholder();
+ public static final int CAP_SYS_TIME = placeholder();
+ public static final int CAP_SYS_TTY_CONFIG = placeholder();
+ public static final int CAP_WAKE_ALARM = placeholder();
+ public static final int E2BIG = placeholder();
+ public static final int EACCES = placeholder();
+ public static final int EADDRINUSE = placeholder();
+ public static final int EADDRNOTAVAIL = placeholder();
+ public static final int EAFNOSUPPORT = placeholder();
+ public static final int EAGAIN = placeholder();
+ public static final int EAI_AGAIN = placeholder();
+ public static final int EAI_BADFLAGS = placeholder();
+ public static final int EAI_FAIL = placeholder();
+ public static final int EAI_FAMILY = placeholder();
+ public static final int EAI_MEMORY = placeholder();
+ public static final int EAI_NODATA = placeholder();
+ public static final int EAI_NONAME = placeholder();
+ public static final int EAI_OVERFLOW = placeholder();
+ public static final int EAI_SERVICE = placeholder();
+ public static final int EAI_SOCKTYPE = placeholder();
+ public static final int EAI_SYSTEM = placeholder();
+ public static final int EALREADY = placeholder();
+ public static final int EBADF = placeholder();
+ public static final int EBADMSG = placeholder();
+ public static final int EBUSY = placeholder();
+ public static final int ECANCELED = placeholder();
+ public static final int ECHILD = placeholder();
+ public static final int ECONNABORTED = placeholder();
+ public static final int ECONNREFUSED = placeholder();
+ public static final int ECONNRESET = placeholder();
+ public static final int EDEADLK = placeholder();
+ public static final int EDESTADDRREQ = placeholder();
+ public static final int EDOM = placeholder();
+ public static final int EDQUOT = placeholder();
+ public static final int EEXIST = placeholder();
+ public static final int EFAULT = placeholder();
+ public static final int EFBIG = placeholder();
+ public static final int EHOSTUNREACH = placeholder();
+ public static final int EIDRM = placeholder();
+ public static final int EILSEQ = placeholder();
+ public static final int EINPROGRESS = placeholder();
+ public static final int EINTR = placeholder();
+ public static final int EINVAL = placeholder();
+ public static final int EIO = placeholder();
+ public static final int EISCONN = placeholder();
+ public static final int EISDIR = placeholder();
+ public static final int ELOOP = placeholder();
+ public static final int EMFILE = placeholder();
+ public static final int EMLINK = placeholder();
+ public static final int EMSGSIZE = placeholder();
+ public static final int EMULTIHOP = placeholder();
+ public static final int ENAMETOOLONG = placeholder();
+ public static final int ENETDOWN = placeholder();
+ public static final int ENETRESET = placeholder();
+ public static final int ENETUNREACH = placeholder();
+ public static final int ENFILE = placeholder();
+ public static final int ENOBUFS = placeholder();
+ public static final int ENODATA = placeholder();
+ public static final int ENODEV = placeholder();
+ public static final int ENOENT = placeholder();
+ public static final int ENOEXEC = placeholder();
+ public static final int ENOLCK = placeholder();
+ public static final int ENOLINK = placeholder();
+ public static final int ENOMEM = placeholder();
+ public static final int ENOMSG = placeholder();
+ /** @hide */ public static final int ENONET = placeholder();
+ public static final int ENOPROTOOPT = placeholder();
+ public static final int ENOSPC = placeholder();
+ public static final int ENOSR = placeholder();
+ public static final int ENOSTR = placeholder();
+ public static final int ENOSYS = placeholder();
+ public static final int ENOTCONN = placeholder();
+ public static final int ENOTDIR = placeholder();
+ public static final int ENOTEMPTY = placeholder();
+ public static final int ENOTSOCK = placeholder();
+ public static final int ENOTSUP = placeholder();
+ public static final int ENOTTY = placeholder();
+ public static final int ENXIO = placeholder();
+ public static final int EOPNOTSUPP = placeholder();
+ public static final int EOVERFLOW = placeholder();
+ public static final int EPERM = placeholder();
+ public static final int EPIPE = placeholder();
+ public static final int EPROTO = placeholder();
+ public static final int EPROTONOSUPPORT = placeholder();
+ public static final int EPROTOTYPE = placeholder();
+ public static final int ERANGE = placeholder();
+ public static final int EROFS = placeholder();
+ public static final int ESPIPE = placeholder();
+ public static final int ESRCH = placeholder();
+ public static final int ESTALE = placeholder();
+ /** @hide */ public static final int ETH_P_ALL = placeholder();
+ /** @hide */ public static final int ETH_P_ARP = placeholder();
+ /** @hide */ public static final int ETH_P_IP = placeholder();
+ /** @hide */ public static final int ETH_P_IPV6 = placeholder();
+ public static final int ETIME = placeholder();
+ public static final int ETIMEDOUT = placeholder();
+ public static final int ETXTBSY = placeholder();
+ /** @hide */ public static final int EUSERS = placeholder();
+ // On Linux, EWOULDBLOCK == EAGAIN. Use EAGAIN instead, to reduce confusion.
+ public static final int EXDEV = placeholder();
+ public static final int EXIT_FAILURE = placeholder();
+ public static final int EXIT_SUCCESS = placeholder();
+ public static final int FD_CLOEXEC = placeholder();
+ public static final int FIONREAD = placeholder();
+ public static final int F_DUPFD = placeholder();
+ public static final int F_DUPFD_CLOEXEC = placeholder();
+ public static final int F_GETFD = placeholder();
+ public static final int F_GETFL = placeholder();
+ public static final int F_GETLK = placeholder();
+ public static final int F_GETLK64 = placeholder();
+ public static final int F_GETOWN = placeholder();
+ public static final int F_OK = placeholder();
+ public static final int F_RDLCK = placeholder();
+ public static final int F_SETFD = placeholder();
+ public static final int F_SETFL = placeholder();
+ public static final int F_SETLK = placeholder();
+ public static final int F_SETLK64 = placeholder();
+ public static final int F_SETLKW = placeholder();
+ public static final int F_SETLKW64 = placeholder();
+ public static final int F_SETOWN = placeholder();
+ public static final int F_UNLCK = placeholder();
+ public static final int F_WRLCK = placeholder();
+ /** @hide */ public static final int ICMP_ECHO = placeholder();
+ /** @hide */ public static final int ICMP_ECHOREPLY = placeholder();
+ /** @hide */ public static final int ICMP6_ECHO_REQUEST = placeholder();
+ /** @hide */ public static final int ICMP6_ECHO_REPLY = placeholder();
+ public static final int IFA_F_DADFAILED = placeholder();
+ public static final int IFA_F_DEPRECATED = placeholder();
+ public static final int IFA_F_HOMEADDRESS = placeholder();
+ public static final int IFA_F_NODAD = placeholder();
+ public static final int IFA_F_OPTIMISTIC = placeholder();
+ public static final int IFA_F_PERMANENT = placeholder();
+ public static final int IFA_F_SECONDARY = placeholder();
+ public static final int IFA_F_TEMPORARY = placeholder();
+ public static final int IFA_F_TENTATIVE = placeholder();
+ public static final int IFF_ALLMULTI = placeholder();
+ public static final int IFF_AUTOMEDIA = placeholder();
+ public static final int IFF_BROADCAST = placeholder();
+ public static final int IFF_DEBUG = placeholder();
+ public static final int IFF_DYNAMIC = placeholder();
+ public static final int IFF_LOOPBACK = placeholder();
+ public static final int IFF_MASTER = placeholder();
+ public static final int IFF_MULTICAST = placeholder();
+ public static final int IFF_NOARP = placeholder();
+ public static final int IFF_NOTRAILERS = placeholder();
+ public static final int IFF_POINTOPOINT = placeholder();
+ public static final int IFF_PORTSEL = placeholder();
+ public static final int IFF_PROMISC = placeholder();
+ public static final int IFF_RUNNING = placeholder();
+ public static final int IFF_SLAVE = placeholder();
+ public static final int IFF_UP = placeholder();
+ public static final int IPPROTO_ICMP = placeholder();
+ public static final int IPPROTO_ICMPV6 = placeholder();
+ public static final int IPPROTO_IP = placeholder();
+ public static final int IPPROTO_IPV6 = placeholder();
+ public static final int IPPROTO_RAW = placeholder();
+ public static final int IPPROTO_TCP = placeholder();
+ public static final int IPPROTO_UDP = placeholder();
+ public static final int IPV6_CHECKSUM = placeholder();
+ public static final int IPV6_MULTICAST_HOPS = placeholder();
+ public static final int IPV6_MULTICAST_IF = placeholder();
+ public static final int IPV6_MULTICAST_LOOP = placeholder();
+ public static final int IPV6_RECVDSTOPTS = placeholder();
+ public static final int IPV6_RECVHOPLIMIT = placeholder();
+ public static final int IPV6_RECVHOPOPTS = placeholder();
+ public static final int IPV6_RECVPKTINFO = placeholder();
+ public static final int IPV6_RECVRTHDR = placeholder();
+ public static final int IPV6_RECVTCLASS = placeholder();
+ public static final int IPV6_TCLASS = placeholder();
+ public static final int IPV6_UNICAST_HOPS = placeholder();
+ public static final int IPV6_V6ONLY = placeholder();
+ /** @hide */ public static final int IP_MULTICAST_ALL = placeholder();
+ public static final int IP_MULTICAST_IF = placeholder();
+ public static final int IP_MULTICAST_LOOP = placeholder();
+ public static final int IP_MULTICAST_TTL = placeholder();
+ /** @hide */ public static final int IP_RECVTOS = placeholder();
+ public static final int IP_TOS = placeholder();
+ public static final int IP_TTL = placeholder();
+ /** @hide */ public static final int _LINUX_CAPABILITY_VERSION_3 = placeholder();
+ public static final int MAP_FIXED = placeholder();
+ /** @hide */ public static final int MAP_POPULATE = placeholder();
+ public static final int MAP_PRIVATE = placeholder();
+ public static final int MAP_SHARED = placeholder();
+ public static final int MCAST_JOIN_GROUP = placeholder();
+ public static final int MCAST_LEAVE_GROUP = placeholder();
+ public static final int MCAST_JOIN_SOURCE_GROUP = placeholder();
+ public static final int MCAST_LEAVE_SOURCE_GROUP = placeholder();
+ public static final int MCAST_BLOCK_SOURCE = placeholder();
+ public static final int MCAST_UNBLOCK_SOURCE = placeholder();
+ public static final int MCL_CURRENT = placeholder();
+ public static final int MCL_FUTURE = placeholder();
+ public static final int MSG_CTRUNC = placeholder();
+ public static final int MSG_DONTROUTE = placeholder();
+ public static final int MSG_EOR = placeholder();
+ public static final int MSG_OOB = placeholder();
+ public static final int MSG_PEEK = placeholder();
+ public static final int MSG_TRUNC = placeholder();
+ public static final int MSG_WAITALL = placeholder();
+ public static final int MS_ASYNC = placeholder();
+ public static final int MS_INVALIDATE = placeholder();
+ public static final int MS_SYNC = placeholder();
+ /** @hide */ public static final int NETLINK_NETFILTER = placeholder();
+ /** @hide */ public static final int NETLINK_ROUTE = placeholder();
+ public static final int NI_DGRAM = placeholder();
+ public static final int NI_NAMEREQD = placeholder();
+ public static final int NI_NOFQDN = placeholder();
+ public static final int NI_NUMERICHOST = placeholder();
+ public static final int NI_NUMERICSERV = placeholder();
+ public static final int O_ACCMODE = placeholder();
+ public static final int O_APPEND = placeholder();
+ public static final int O_CLOEXEC = placeholder();
+ public static final int O_CREAT = placeholder();
+ public static final int O_EXCL = placeholder();
+ public static final int O_NOCTTY = placeholder();
+ public static final int O_NOFOLLOW = placeholder();
+ public static final int O_NONBLOCK = placeholder();
+ public static final int O_RDONLY = placeholder();
+ public static final int O_RDWR = placeholder();
+ public static final int O_SYNC = placeholder();
+ public static final int O_DSYNC = placeholder();
+ public static final int O_TRUNC = placeholder();
+ public static final int O_WRONLY = placeholder();
+ public static final int POLLERR = placeholder();
+ public static final int POLLHUP = placeholder();
+ public static final int POLLIN = placeholder();
+ public static final int POLLNVAL = placeholder();
+ public static final int POLLOUT = placeholder();
+ public static final int POLLPRI = placeholder();
+ public static final int POLLRDBAND = placeholder();
+ public static final int POLLRDNORM = placeholder();
+ public static final int POLLWRBAND = placeholder();
+ public static final int POLLWRNORM = placeholder();
+ /** @hide */ public static final int PR_CAP_AMBIENT = placeholder();
+ /** @hide */ public static final int PR_CAP_AMBIENT_RAISE = placeholder();
+ public static final int PR_GET_DUMPABLE = placeholder();
+ public static final int PR_SET_DUMPABLE = placeholder();
+ public static final int PR_SET_NO_NEW_PRIVS = placeholder();
+ public static final int PROT_EXEC = placeholder();
+ public static final int PROT_NONE = placeholder();
+ public static final int PROT_READ = placeholder();
+ public static final int PROT_WRITE = placeholder();
+ public static final int R_OK = placeholder();
+ /** @hide */ public static final int RLIMIT_NOFILE = placeholder();
+ public static final int RT_SCOPE_HOST = placeholder();
+ public static final int RT_SCOPE_LINK = placeholder();
+ public static final int RT_SCOPE_NOWHERE = placeholder();
+ public static final int RT_SCOPE_SITE = placeholder();
+ public static final int RT_SCOPE_UNIVERSE = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV4_IFADDR = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV4_MROUTE = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV4_ROUTE = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV4_RULE = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV6_IFADDR = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV6_IFINFO = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV6_MROUTE = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV6_PREFIX = placeholder();
+ /** @hide */ public static final int RTMGRP_IPV6_ROUTE = placeholder();
+ /** @hide */ public static final int RTMGRP_LINK = placeholder();
+ /** @hide */ public static final int RTMGRP_NEIGH = placeholder();
+ /** @hide */ public static final int RTMGRP_NOTIFY = placeholder();
+ /** @hide */ public static final int RTMGRP_TC = placeholder();
+ public static final int SEEK_CUR = placeholder();
+ public static final int SEEK_END = placeholder();
+ public static final int SEEK_SET = placeholder();
+ public static final int SHUT_RD = placeholder();
+ public static final int SHUT_RDWR = placeholder();
+ public static final int SHUT_WR = placeholder();
+ public static final int SIGABRT = placeholder();
+ public static final int SIGALRM = placeholder();
+ public static final int SIGBUS = placeholder();
+ public static final int SIGCHLD = placeholder();
+ public static final int SIGCONT = placeholder();
+ public static final int SIGFPE = placeholder();
+ public static final int SIGHUP = placeholder();
+ public static final int SIGILL = placeholder();
+ public static final int SIGINT = placeholder();
+ public static final int SIGIO = placeholder();
+ public static final int SIGKILL = placeholder();
+ public static final int SIGPIPE = placeholder();
+ public static final int SIGPROF = placeholder();
+ public static final int SIGPWR = placeholder();
+ public static final int SIGQUIT = placeholder();
+ public static final int SIGRTMAX = placeholder();
+ public static final int SIGRTMIN = placeholder();
+ public static final int SIGSEGV = placeholder();
+ public static final int SIGSTKFLT = placeholder();
+ public static final int SIGSTOP = placeholder();
+ public static final int SIGSYS = placeholder();
+ public static final int SIGTERM = placeholder();
+ public static final int SIGTRAP = placeholder();
+ public static final int SIGTSTP = placeholder();
+ public static final int SIGTTIN = placeholder();
+ public static final int SIGTTOU = placeholder();
+ public static final int SIGURG = placeholder();
+ public static final int SIGUSR1 = placeholder();
+ public static final int SIGUSR2 = placeholder();
+ public static final int SIGVTALRM = placeholder();
+ public static final int SIGWINCH = placeholder();
+ public static final int SIGXCPU = placeholder();
+ public static final int SIGXFSZ = placeholder();
+ public static final int SIOCGIFADDR = placeholder();
+ public static final int SIOCGIFBRDADDR = placeholder();
+ public static final int SIOCGIFDSTADDR = placeholder();
+ public static final int SIOCGIFNETMASK = placeholder();
+ public static final int SOCK_DGRAM = placeholder();
+ public static final int SOCK_RAW = placeholder();
+ public static final int SOCK_SEQPACKET = placeholder();
+ public static final int SOCK_STREAM = placeholder();
+ public static final int SOL_SOCKET = placeholder();
+ public static final int SO_BINDTODEVICE = placeholder();
+ public static final int SO_BROADCAST = placeholder();
+ public static final int SO_DEBUG = placeholder();
+ /** @hide */ public static final int SO_DOMAIN = placeholder();
+ public static final int SO_DONTROUTE = placeholder();
+ public static final int SO_ERROR = placeholder();
+ public static final int SO_KEEPALIVE = placeholder();
+ public static final int SO_LINGER = placeholder();
+ public static final int SO_OOBINLINE = placeholder();
+ public static final int SO_PASSCRED = placeholder();
+ public static final int SO_PEERCRED = placeholder();
+ /** @hide */ public static final int SO_PROTOCOL = placeholder();
+ public static final int SO_RCVBUF = placeholder();
+ public static final int SO_RCVLOWAT = placeholder();
+ public static final int SO_RCVTIMEO = placeholder();
+ public static final int SO_REUSEADDR = placeholder();
+ public static final int SO_SNDBUF = placeholder();
+ public static final int SO_SNDLOWAT = placeholder();
+ public static final int SO_SNDTIMEO = placeholder();
+ public static final int SO_TYPE = placeholder();
+ public static final int STDERR_FILENO = placeholder();
+ public static final int STDIN_FILENO = placeholder();
+ public static final int STDOUT_FILENO = placeholder();
+ public static final int ST_MANDLOCK = placeholder();
+ public static final int ST_NOATIME = placeholder();
+ public static final int ST_NODEV = placeholder();
+ public static final int ST_NODIRATIME = placeholder();
+ public static final int ST_NOEXEC = placeholder();
+ public static final int ST_NOSUID = placeholder();
+ public static final int ST_RDONLY = placeholder();
+ public static final int ST_RELATIME = placeholder();
+ public static final int ST_SYNCHRONOUS = placeholder();
+ public static final int S_IFBLK = placeholder();
+ public static final int S_IFCHR = placeholder();
+ public static final int S_IFDIR = placeholder();
+ public static final int S_IFIFO = placeholder();
+ public static final int S_IFLNK = placeholder();
+ public static final int S_IFMT = placeholder();
+ public static final int S_IFREG = placeholder();
+ public static final int S_IFSOCK = placeholder();
+ public static final int S_IRGRP = placeholder();
+ public static final int S_IROTH = placeholder();
+ public static final int S_IRUSR = placeholder();
+ public static final int S_IRWXG = placeholder();
+ public static final int S_IRWXO = placeholder();
+ public static final int S_IRWXU = placeholder();
+ public static final int S_ISGID = placeholder();
+ public static final int S_ISUID = placeholder();
+ public static final int S_ISVTX = placeholder();
+ public static final int S_IWGRP = placeholder();
+ public static final int S_IWOTH = placeholder();
+ public static final int S_IWUSR = placeholder();
+ public static final int S_IXGRP = placeholder();
+ public static final int S_IXOTH = placeholder();
+ public static final int S_IXUSR = placeholder();
+ public static final int TCP_NODELAY = placeholder();
+ public static final int TCP_USER_TIMEOUT = placeholder();
+ /** @hide */ public static final int TIOCOUTQ = placeholder();
+ /** @hide */ public static final int UDP_ENCAP = placeholder();
+ /** @hide */ public static final int UDP_ENCAP_ESPINUDP_NON_IKE = placeholder();
+ /** @hide */ public static final int UDP_ENCAP_ESPINUDP = placeholder();
+ /** @hide */ public static final int UNIX_PATH_MAX = placeholder();
+ public static final int WCONTINUED = placeholder();
+ public static final int WEXITED = placeholder();
+ public static final int WNOHANG = placeholder();
+ public static final int WNOWAIT = placeholder();
+ public static final int WSTOPPED = placeholder();
+ public static final int WUNTRACED = placeholder();
+ public static final int W_OK = placeholder();
+ /** @hide */ public static final int XATTR_CREATE = placeholder();
+ /** @hide */ public static final int XATTR_REPLACE = placeholder();
+ public static final int X_OK = placeholder();
+ public static final int _SC_2_CHAR_TERM = placeholder();
+ public static final int _SC_2_C_BIND = placeholder();
+ public static final int _SC_2_C_DEV = placeholder();
+ public static final int _SC_2_C_VERSION = placeholder();
+ public static final int _SC_2_FORT_DEV = placeholder();
+ public static final int _SC_2_FORT_RUN = placeholder();
+ public static final int _SC_2_LOCALEDEF = placeholder();
+ public static final int _SC_2_SW_DEV = placeholder();
+ public static final int _SC_2_UPE = placeholder();
+ public static final int _SC_2_VERSION = placeholder();
+ public static final int _SC_AIO_LISTIO_MAX = placeholder();
+ public static final int _SC_AIO_MAX = placeholder();
+ public static final int _SC_AIO_PRIO_DELTA_MAX = placeholder();
+ public static final int _SC_ARG_MAX = placeholder();
+ public static final int _SC_ASYNCHRONOUS_IO = placeholder();
+ public static final int _SC_ATEXIT_MAX = placeholder();
+ public static final int _SC_AVPHYS_PAGES = placeholder();
+ public static final int _SC_BC_BASE_MAX = placeholder();
+ public static final int _SC_BC_DIM_MAX = placeholder();
+ public static final int _SC_BC_SCALE_MAX = placeholder();
+ public static final int _SC_BC_STRING_MAX = placeholder();
+ public static final int _SC_CHILD_MAX = placeholder();
+ public static final int _SC_CLK_TCK = placeholder();
+ public static final int _SC_COLL_WEIGHTS_MAX = placeholder();
+ public static final int _SC_DELAYTIMER_MAX = placeholder();
+ public static final int _SC_EXPR_NEST_MAX = placeholder();
+ public static final int _SC_FSYNC = placeholder();
+ public static final int _SC_GETGR_R_SIZE_MAX = placeholder();
+ public static final int _SC_GETPW_R_SIZE_MAX = placeholder();
+ public static final int _SC_IOV_MAX = placeholder();
+ public static final int _SC_JOB_CONTROL = placeholder();
+ public static final int _SC_LINE_MAX = placeholder();
+ public static final int _SC_LOGIN_NAME_MAX = placeholder();
+ public static final int _SC_MAPPED_FILES = placeholder();
+ public static final int _SC_MEMLOCK = placeholder();
+ public static final int _SC_MEMLOCK_RANGE = placeholder();
+ public static final int _SC_MEMORY_PROTECTION = placeholder();
+ public static final int _SC_MESSAGE_PASSING = placeholder();
+ public static final int _SC_MQ_OPEN_MAX = placeholder();
+ public static final int _SC_MQ_PRIO_MAX = placeholder();
+ public static final int _SC_NGROUPS_MAX = placeholder();
+ public static final int _SC_NPROCESSORS_CONF = placeholder();
+ public static final int _SC_NPROCESSORS_ONLN = placeholder();
+ public static final int _SC_OPEN_MAX = placeholder();
+ public static final int _SC_PAGESIZE = placeholder();
+ public static final int _SC_PAGE_SIZE = placeholder();
+ public static final int _SC_PASS_MAX = placeholder();
+ public static final int _SC_PHYS_PAGES = placeholder();
+ public static final int _SC_PRIORITIZED_IO = placeholder();
+ public static final int _SC_PRIORITY_SCHEDULING = placeholder();
+ public static final int _SC_REALTIME_SIGNALS = placeholder();
+ public static final int _SC_RE_DUP_MAX = placeholder();
+ public static final int _SC_RTSIG_MAX = placeholder();
+ public static final int _SC_SAVED_IDS = placeholder();
+ public static final int _SC_SEMAPHORES = placeholder();
+ public static final int _SC_SEM_NSEMS_MAX = placeholder();
+ public static final int _SC_SEM_VALUE_MAX = placeholder();
+ public static final int _SC_SHARED_MEMORY_OBJECTS = placeholder();
+ public static final int _SC_SIGQUEUE_MAX = placeholder();
+ public static final int _SC_STREAM_MAX = placeholder();
+ public static final int _SC_SYNCHRONIZED_IO = placeholder();
+ public static final int _SC_THREADS = placeholder();
+ public static final int _SC_THREAD_ATTR_STACKADDR = placeholder();
+ public static final int _SC_THREAD_ATTR_STACKSIZE = placeholder();
+ public static final int _SC_THREAD_DESTRUCTOR_ITERATIONS = placeholder();
+ public static final int _SC_THREAD_KEYS_MAX = placeholder();
+ public static final int _SC_THREAD_PRIORITY_SCHEDULING = placeholder();
+ public static final int _SC_THREAD_PRIO_INHERIT = placeholder();
+ public static final int _SC_THREAD_PRIO_PROTECT = placeholder();
+ public static final int _SC_THREAD_SAFE_FUNCTIONS = placeholder();
+ public static final int _SC_THREAD_STACK_MIN = placeholder();
+ public static final int _SC_THREAD_THREADS_MAX = placeholder();
+ public static final int _SC_TIMERS = placeholder();
+ public static final int _SC_TIMER_MAX = placeholder();
+ public static final int _SC_TTY_NAME_MAX = placeholder();
+ public static final int _SC_TZNAME_MAX = placeholder();
+ public static final int _SC_VERSION = placeholder();
+ public static final int _SC_XBS5_ILP32_OFF32 = placeholder();
+ public static final int _SC_XBS5_ILP32_OFFBIG = placeholder();
+ public static final int _SC_XBS5_LP64_OFF64 = placeholder();
+ public static final int _SC_XBS5_LPBIG_OFFBIG = placeholder();
+ public static final int _SC_XOPEN_CRYPT = placeholder();
+ public static final int _SC_XOPEN_ENH_I18N = placeholder();
+ public static final int _SC_XOPEN_LEGACY = placeholder();
+ public static final int _SC_XOPEN_REALTIME = placeholder();
+ public static final int _SC_XOPEN_REALTIME_THREADS = placeholder();
+ public static final int _SC_XOPEN_SHM = placeholder();
+ public static final int _SC_XOPEN_UNIX = placeholder();
+ public static final int _SC_XOPEN_VERSION = placeholder();
+ public static final int _SC_XOPEN_XCU_VERSION = placeholder();
+
+ /**
+ * Returns the string name of a getaddrinfo(3) error value.
+ * For example, "EAI_AGAIN".
+ */
+ public static String gaiName(int error) {
+ if (error == EAI_AGAIN) {
+ return "EAI_AGAIN";
+ }
+ if (error == EAI_BADFLAGS) {
+ return "EAI_BADFLAGS";
+ }
+ if (error == EAI_FAIL) {
+ return "EAI_FAIL";
+ }
+ if (error == EAI_FAMILY) {
+ return "EAI_FAMILY";
+ }
+ if (error == EAI_MEMORY) {
+ return "EAI_MEMORY";
+ }
+ if (error == EAI_NODATA) {
+ return "EAI_NODATA";
+ }
+ if (error == EAI_NONAME) {
+ return "EAI_NONAME";
+ }
+ if (error == EAI_OVERFLOW) {
+ return "EAI_OVERFLOW";
+ }
+ if (error == EAI_SERVICE) {
+ return "EAI_SERVICE";
+ }
+ if (error == EAI_SOCKTYPE) {
+ return "EAI_SOCKTYPE";
+ }
+ if (error == EAI_SYSTEM) {
+ return "EAI_SYSTEM";
+ }
+ return null;
+ }
+
+ /**
+ * Returns the string name of an errno value.
+ * For example, "EACCES". See {@link Os#strerror} for human-readable errno descriptions.
+ */
+ public static String errnoName(int errno) {
+ if (errno == E2BIG) {
+ return "E2BIG";
+ }
+ if (errno == EACCES) {
+ return "EACCES";
+ }
+ if (errno == EADDRINUSE) {
+ return "EADDRINUSE";
+ }
+ if (errno == EADDRNOTAVAIL) {
+ return "EADDRNOTAVAIL";
+ }
+ if (errno == EAFNOSUPPORT) {
+ return "EAFNOSUPPORT";
+ }
+ if (errno == EAGAIN) {
+ return "EAGAIN";
+ }
+ if (errno == EALREADY) {
+ return "EALREADY";
+ }
+ if (errno == EBADF) {
+ return "EBADF";
+ }
+ if (errno == EBADMSG) {
+ return "EBADMSG";
+ }
+ if (errno == EBUSY) {
+ return "EBUSY";
+ }
+ if (errno == ECANCELED) {
+ return "ECANCELED";
+ }
+ if (errno == ECHILD) {
+ return "ECHILD";
+ }
+ if (errno == ECONNABORTED) {
+ return "ECONNABORTED";
+ }
+ if (errno == ECONNREFUSED) {
+ return "ECONNREFUSED";
+ }
+ if (errno == ECONNRESET) {
+ return "ECONNRESET";
+ }
+ if (errno == EDEADLK) {
+ return "EDEADLK";
+ }
+ if (errno == EDESTADDRREQ) {
+ return "EDESTADDRREQ";
+ }
+ if (errno == EDOM) {
+ return "EDOM";
+ }
+ if (errno == EDQUOT) {
+ return "EDQUOT";
+ }
+ if (errno == EEXIST) {
+ return "EEXIST";
+ }
+ if (errno == EFAULT) {
+ return "EFAULT";
+ }
+ if (errno == EFBIG) {
+ return "EFBIG";
+ }
+ if (errno == EHOSTUNREACH) {
+ return "EHOSTUNREACH";
+ }
+ if (errno == EIDRM) {
+ return "EIDRM";
+ }
+ if (errno == EILSEQ) {
+ return "EILSEQ";
+ }
+ if (errno == EINPROGRESS) {
+ return "EINPROGRESS";
+ }
+ if (errno == EINTR) {
+ return "EINTR";
+ }
+ if (errno == EINVAL) {
+ return "EINVAL";
+ }
+ if (errno == EIO) {
+ return "EIO";
+ }
+ if (errno == EISCONN) {
+ return "EISCONN";
+ }
+ if (errno == EISDIR) {
+ return "EISDIR";
+ }
+ if (errno == ELOOP) {
+ return "ELOOP";
+ }
+ if (errno == EMFILE) {
+ return "EMFILE";
+ }
+ if (errno == EMLINK) {
+ return "EMLINK";
+ }
+ if (errno == EMSGSIZE) {
+ return "EMSGSIZE";
+ }
+ if (errno == EMULTIHOP) {
+ return "EMULTIHOP";
+ }
+ if (errno == ENAMETOOLONG) {
+ return "ENAMETOOLONG";
+ }
+ if (errno == ENETDOWN) {
+ return "ENETDOWN";
+ }
+ if (errno == ENETRESET) {
+ return "ENETRESET";
+ }
+ if (errno == ENETUNREACH) {
+ return "ENETUNREACH";
+ }
+ if (errno == ENFILE) {
+ return "ENFILE";
+ }
+ if (errno == ENOBUFS) {
+ return "ENOBUFS";
+ }
+ if (errno == ENODATA) {
+ return "ENODATA";
+ }
+ if (errno == ENODEV) {
+ return "ENODEV";
+ }
+ if (errno == ENOENT) {
+ return "ENOENT";
+ }
+ if (errno == ENOEXEC) {
+ return "ENOEXEC";
+ }
+ if (errno == ENOLCK) {
+ return "ENOLCK";
+ }
+ if (errno == ENOLINK) {
+ return "ENOLINK";
+ }
+ if (errno == ENOMEM) {
+ return "ENOMEM";
+ }
+ if (errno == ENOMSG) {
+ return "ENOMSG";
+ }
+ if (errno == ENONET) {
+ return "ENONET";
+ }
+ if (errno == ENOPROTOOPT) {
+ return "ENOPROTOOPT";
+ }
+ if (errno == ENOSPC) {
+ return "ENOSPC";
+ }
+ if (errno == ENOSR) {
+ return "ENOSR";
+ }
+ if (errno == ENOSTR) {
+ return "ENOSTR";
+ }
+ if (errno == ENOSYS) {
+ return "ENOSYS";
+ }
+ if (errno == ENOTCONN) {
+ return "ENOTCONN";
+ }
+ if (errno == ENOTDIR) {
+ return "ENOTDIR";
+ }
+ if (errno == ENOTEMPTY) {
+ return "ENOTEMPTY";
+ }
+ if (errno == ENOTSOCK) {
+ return "ENOTSOCK";
+ }
+ if (errno == ENOTSUP) {
+ return "ENOTSUP";
+ }
+ if (errno == ENOTTY) {
+ return "ENOTTY";
+ }
+ if (errno == ENXIO) {
+ return "ENXIO";
+ }
+ if (errno == EOPNOTSUPP) {
+ return "EOPNOTSUPP";
+ }
+ if (errno == EOVERFLOW) {
+ return "EOVERFLOW";
+ }
+ if (errno == EPERM) {
+ return "EPERM";
+ }
+ if (errno == EPIPE) {
+ return "EPIPE";
+ }
+ if (errno == EPROTO) {
+ return "EPROTO";
+ }
+ if (errno == EPROTONOSUPPORT) {
+ return "EPROTONOSUPPORT";
+ }
+ if (errno == EPROTOTYPE) {
+ return "EPROTOTYPE";
+ }
+ if (errno == ERANGE) {
+ return "ERANGE";
+ }
+ if (errno == EROFS) {
+ return "EROFS";
+ }
+ if (errno == ESPIPE) {
+ return "ESPIPE";
+ }
+ if (errno == ESRCH) {
+ return "ESRCH";
+ }
+ if (errno == ESTALE) {
+ return "ESTALE";
+ }
+ if (errno == ETIME) {
+ return "ETIME";
+ }
+ if (errno == ETIMEDOUT) {
+ return "ETIMEDOUT";
+ }
+ if (errno == ETXTBSY) {
+ return "ETXTBSY";
+ }
+ if (errno == EXDEV) {
+ return "EXDEV";
+ }
+ return null;
+ }
+
+ private static native void initConstants();
+
+ // A hack to avoid these constants being inlined by javac...
+ private static int placeholder() { return 0; }
+ // ...because we want to initialize them at runtime.
+ static {
+ initConstants();
+ }
+}
diff --git a/android/system/PacketSocketAddress.java b/android/system/PacketSocketAddress.java
new file mode 100644
index 00000000..510771c4
--- /dev/null
+++ b/android/system/PacketSocketAddress.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+import java.net.SocketAddress;
+
+/**
+ * Packet socket address.
+ *
+ * Corresponds to Linux's {@code struct sockaddr_ll}.
+ *
+ * @hide
+ */
+public final class PacketSocketAddress extends SocketAddress {
+ /** Protocol. An Ethernet protocol type, e.g., {@code ETH_P_IPV6}. */
+ public short sll_protocol;
+
+ /** Interface index. */
+ public int sll_ifindex;
+
+ /** ARP hardware type. One of the {@code ARPHRD_*} constants. */
+ public short sll_hatype;
+
+ /** Packet type. One of the {@code PACKET_*} constants, such as {@code PACKET_OTHERHOST}. */
+ public byte sll_pkttype;
+
+ /** Hardware address. */
+ public byte[] sll_addr;
+
+ /** Constructs a new PacketSocketAddress. */
+ public PacketSocketAddress(short sll_protocol, int sll_ifindex,
+ short sll_hatype, byte sll_pkttype, byte[] sll_addr) {
+ this.sll_protocol = sll_protocol;
+ this.sll_ifindex = sll_ifindex;
+ this.sll_hatype = sll_hatype;
+ this.sll_pkttype = sll_pkttype;
+ this.sll_addr = sll_addr;
+ }
+
+ /** Constructs a new PacketSocketAddress suitable for binding to. */
+ public PacketSocketAddress(short sll_protocol, int sll_ifindex) {
+ this(sll_protocol, sll_ifindex, (short) 0, (byte) 0, null);
+ }
+
+ /** Constructs a new PacketSocketAddress suitable for sending to. */
+ public PacketSocketAddress(int sll_ifindex, byte[] sll_addr) {
+ this((short) 0, sll_ifindex, (short) 0, (byte) 0, sll_addr);
+ }
+}
diff --git a/android/system/StructAddrinfo.java b/android/system/StructAddrinfo.java
new file mode 100644
index 00000000..2425946f
--- /dev/null
+++ b/android/system/StructAddrinfo.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.net.InetAddress;
+import libcore.util.Objects;
+
+/**
+ * Information returned/taken by getaddrinfo(3). Corresponds to C's {@code struct addrinfo} from
+ * <a href="http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html">&lt;netdb.h&gt;</a>
+ *
+ * TODO: we currently only _take_ a StructAddrinfo; getaddrinfo returns an InetAddress[].
+ *
+ * @hide
+ */
+public final class StructAddrinfo {
+ /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */
+ public int ai_flags;
+
+ /** Desired address family for results. (Such as AF_INET6 for IPv6. AF_UNSPEC means "any".) */
+ public int ai_family;
+
+ /** Socket type. (Such as SOCK_DGRAM. 0 means "any".) */
+ public int ai_socktype;
+
+ /** Protocol. (Such as IPPROTO_IPV6 IPv6. 0 means "any".) */
+ public int ai_protocol;
+
+ /** Address length. (Not useful in Java.) */
+ // public int ai_addrlen;
+
+ /** Address. */
+ public InetAddress ai_addr;
+
+ /** Canonical name of service location (if AI_CANONNAME provided in ai_flags). */
+ // public String ai_canonname;
+
+ /** Next element in linked list. */
+ public StructAddrinfo ai_next;
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructCapUserData.java b/android/system/StructCapUserData.java
new file mode 100644
index 00000000..af63caf7
--- /dev/null
+++ b/android/system/StructCapUserData.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Corresponds to Linux' __user_cap_data_struct for capget and capset.
+ *
+ * @hide
+ */
+public final class StructCapUserData {
+ /** Effective capability mask. */
+ public final int effective; /* __u32 */
+
+ /** Permitted capability mask. */
+ public final int permitted; /* __u32 */
+
+ /** Inheritable capability mask. */
+ public final int inheritable; /* __u32 */
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructCapUserData(int effective, int permitted, int inheritable) {
+ this.effective = effective;
+ this.permitted = permitted;
+ this.inheritable = inheritable;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructCapUserHeader.java b/android/system/StructCapUserHeader.java
new file mode 100644
index 00000000..abbb3954
--- /dev/null
+++ b/android/system/StructCapUserHeader.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Corresponds to Linux' __user_cap_header_struct for capget and capset.
+ *
+ * @hide
+ */
+public final class StructCapUserHeader {
+ /**
+ * Version of the header. Note this is not final as capget() may mutate the field when an
+ * invalid version is provided. See
+ * <a href="http://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>.
+ */
+ public int version; /* __u32 */
+
+ /** Pid of the header. The pid a call applies to. */
+ public final int pid;
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructCapUserHeader(int version, int pid) {
+ this.version = version;
+ this.pid = pid;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructFlock.java b/android/system/StructFlock.java
new file mode 100644
index 00000000..92cd95ab
--- /dev/null
+++ b/android/system/StructFlock.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Information returned/taken by fcntl(2) F_GETFL and F_SETFL. Corresponds to C's
+ * {@code struct flock} from
+ * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html">&lt;fcntl.h&gt;</a>
+ *
+ * @hide
+ */
+public final class StructFlock {
+ /** The operation type, one of F_RDLCK, F_WRLCK, or F_UNLCK. */
+ public short l_type;
+
+ /** How to interpret l_start, one of SEEK_CUR, SEEK_END, SEEK_SET. */
+ public short l_whence;
+
+ /** Start offset. */
+ public long l_start; /*off_t*/
+
+ /** Byte count to operate on. */
+ public long l_len; /*off_t*/
+
+ /** Process blocking our lock (filled in by F_GETLK, otherwise unused). */
+ public int l_pid; /*pid_t*/
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructGroupReq.java b/android/system/StructGroupReq.java
new file mode 100644
index 00000000..8ed5950b
--- /dev/null
+++ b/android/system/StructGroupReq.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.net.InetAddress;
+import libcore.util.Objects;
+
+/**
+ * Corresponds to C's {@code struct group_req}.
+ *
+ * @hide
+ */
+public final class StructGroupReq {
+ public final int gr_interface;
+ public final InetAddress gr_group;
+
+ public StructGroupReq(int gr_interface, InetAddress gr_group) {
+ this.gr_interface = gr_interface;
+ this.gr_group = gr_group;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructGroupSourceReq.java b/android/system/StructGroupSourceReq.java
new file mode 100644
index 00000000..c300338f
--- /dev/null
+++ b/android/system/StructGroupSourceReq.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.net.InetAddress;
+import libcore.util.Objects;
+
+/**
+ * Corresponds to C's {@code struct group_source_req}.
+ *
+ * @hide
+ */
+public final class StructGroupSourceReq {
+ public final int gsr_interface;
+ public final InetAddress gsr_group;
+ public final InetAddress gsr_source;
+
+ public StructGroupSourceReq(int gsr_interface, InetAddress gsr_group, InetAddress gsr_source) {
+ this.gsr_interface = gsr_interface;
+ this.gsr_group = gsr_group;
+ this.gsr_source = gsr_source;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructIcmpHdr.java b/android/system/StructIcmpHdr.java
new file mode 100644
index 00000000..87ae679d
--- /dev/null
+++ b/android/system/StructIcmpHdr.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import static android.system.OsConstants.ICMP6_ECHO_REQUEST;
+import static android.system.OsConstants.ICMP_ECHO;
+
+/**
+ * Corresponds to C's {@code struct icmphdr} from linux/icmp.h and {@code struct icmp6hdr} from
+ * linux/icmpv6.h
+ *
+ * @hide
+ */
+public final class StructIcmpHdr {
+ private byte[] packet;
+
+ private StructIcmpHdr() {
+ packet = new byte[8];
+ }
+
+ /*
+ * Echo or Echo Reply Message
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type | Code | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Identifier | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Data ...
+ * +-+-+-+-+-
+ */
+ public static StructIcmpHdr IcmpEchoHdr(boolean ipv4, int seq) {
+ StructIcmpHdr hdr = new StructIcmpHdr();
+ hdr.packet[0] = ipv4 ? (byte) ICMP_ECHO : (byte) ICMP6_ECHO_REQUEST;
+ // packet[1]: Code is always zero.
+ // packet[2,3]: Checksum is computed by kernel.
+ // packet[4,5]: ID (= port) inserted by kernel.
+ hdr.packet[6] = (byte) (seq >> 8);
+ hdr.packet[7] = (byte) seq;
+ return hdr;
+ }
+
+ public byte[] getBytes() {
+ return packet.clone();
+ }
+}
diff --git a/android/system/StructIfaddrs.java b/android/system/StructIfaddrs.java
new file mode 100644
index 00000000..7769f282
--- /dev/null
+++ b/android/system/StructIfaddrs.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.net.InetAddress;
+
+/**
+ * Information returned by {@link Os#getifaddrs}. Loosely corresponds to C's
+ * {@code struct ifaddrs} from {@code <ifaddrs.h>}.
+ *
+ * @hide
+ */
+public final class StructIfaddrs {
+ public final String ifa_name;
+ public final int ifa_flags;
+ public final InetAddress ifa_addr;
+ public final InetAddress ifa_netmask;
+ public final InetAddress ifa_broadaddr;
+ public final byte[] hwaddr;
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructIfaddrs(String ifa_name, int ifa_flags, InetAddress ifa_addr, InetAddress ifa_netmask,
+ InetAddress ifa_broadaddr, byte[] hwaddr) {
+ this.ifa_name = ifa_name;
+ this.ifa_flags = ifa_flags;
+ this.ifa_addr = ifa_addr;
+ this.ifa_netmask = ifa_netmask;
+ this.ifa_broadaddr = ifa_broadaddr;
+ this.hwaddr = hwaddr;
+ }
+}
diff --git a/android/system/StructLinger.java b/android/system/StructLinger.java
new file mode 100644
index 00000000..55ffc5c9
--- /dev/null
+++ b/android/system/StructLinger.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Corresponds to C's {@code struct linger} from
+ * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html">&lt;sys/socket.h&gt;</a>
+ *
+ * @hide
+ */
+public final class StructLinger {
+ /** Whether or not linger is enabled. Non-zero is on. */
+ public final int l_onoff;
+
+ /** Linger time in seconds. */
+ public final int l_linger;
+
+ public StructLinger(int l_onoff, int l_linger) {
+ this.l_onoff = l_onoff;
+ this.l_linger = l_linger;
+ }
+
+ public boolean isOn() {
+ return l_onoff != 0;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructPasswd.java b/android/system/StructPasswd.java
new file mode 100644
index 00000000..93655c19
--- /dev/null
+++ b/android/system/StructPasswd.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Information returned by {@link Os#getpwnam} and {@link Os#getpwuid}. Corresponds to C's
+ * {@code struct passwd} from {@code <pwd.h>}.
+ *
+ * @hide
+ */
+public final class StructPasswd {
+ public final String pw_name;
+ public final int pw_uid;
+ public final int pw_gid;
+ public final String pw_dir;
+ public final String pw_shell;
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructPasswd(String pw_name, int pw_uid, int pw_gid, String pw_dir, String pw_shell) {
+ this.pw_name = pw_name;
+ this.pw_uid = pw_uid;
+ this.pw_gid = pw_gid;
+ this.pw_dir = pw_dir;
+ this.pw_shell = pw_shell;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructPollfd.java b/android/system/StructPollfd.java
new file mode 100644
index 00000000..2ca117e9
--- /dev/null
+++ b/android/system/StructPollfd.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.io.FileDescriptor;
+import libcore.util.Objects;
+
+/**
+ * Used as an in/out parameter to {@link Os#poll}.
+ * Corresponds to C's {@code struct pollfd} from {@code <poll.h>}.
+ */
+public final class StructPollfd {
+ /** The file descriptor to poll. */
+ public FileDescriptor fd;
+
+ /**
+ * The events we're interested in. POLLIN corresponds to being in select(2)'s read fd set,
+ * POLLOUT to the write fd set.
+ */
+ public short events;
+
+ /** The events that actually happened. */
+ public short revents;
+
+ /**
+ * A non-standard extension that lets callers conveniently map back to the object
+ * their fd belongs to. This is used by Selector, for example, to associate each
+ * FileDescriptor with the corresponding SelectionKey.
+ */
+ public Object userData;
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructRlimit.java b/android/system/StructRlimit.java
new file mode 100644
index 00000000..6bb05a9c
--- /dev/null
+++ b/android/system/StructRlimit.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Information returned by {@link Os#getrlimit}. Corresponds to C's {@code struct rlimit} from
+ * {@code <sys/resource.h>}.
+ *
+ * @hide
+ */
+public final class StructRlimit {
+ public final long rlim_cur;
+ public final long rlim_max;
+
+ public StructRlimit(long rlim_cur, long rlim_max) {
+ this.rlim_cur = rlim_cur;
+ this.rlim_max = rlim_max;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructStat.java b/android/system/StructStat.java
new file mode 100644
index 00000000..a1e87296
--- /dev/null
+++ b/android/system/StructStat.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * File information returned by {@link Os#fstat}, {@link Os#lstat}, and {@link Os#stat}.
+ * Corresponds to C's {@code struct stat} from {@code <stat.h>}.
+ */
+public final class StructStat {
+ /** Device ID of device containing file. */
+ public final long st_dev; /*dev_t*/
+
+ /** File serial number (inode). */
+ public final long st_ino; /*ino_t*/
+
+ /** Mode (permissions) of file. */
+ public final int st_mode; /*mode_t*/
+
+ /** Number of hard links to the file. */
+ public final long st_nlink; /*nlink_t*/
+
+ /** User ID of file. */
+ public final int st_uid; /*uid_t*/
+
+ /** Group ID of file. */
+ public final int st_gid; /*gid_t*/
+
+ /** Device ID (if file is character or block special). */
+ public final long st_rdev; /*dev_t*/
+
+ /**
+ * For regular files, the file size in bytes.
+ * For symbolic links, the length in bytes of the pathname contained in the symbolic link.
+ * For a shared memory object, the length in bytes.
+ * For a typed memory object, the length in bytes.
+ * For other file types, the use of this field is unspecified.
+ */
+ public final long st_size; /*off_t*/
+
+ /** Seconds part of time of last access. */
+ public final long st_atime; /*time_t*/
+
+ /** StructTimespec with time of last access. */
+ public final StructTimespec st_atim;
+
+ /** Seconds part of time of last data modification. */
+ public final long st_mtime; /*time_t*/
+
+ /** StructTimespec with time of last modification. */
+ public final StructTimespec st_mtim;
+
+ /** Seconds part of time of last status change */
+ public final long st_ctime; /*time_t*/
+
+ /** StructTimespec with time of last status change. */
+ public final StructTimespec st_ctim;
+
+ /**
+ * A file system-specific preferred I/O block size for this object.
+ * For some file system types, this may vary from file to file.
+ */
+ public final long st_blksize; /*blksize_t*/
+
+ /** Number of blocks allocated for this object. */
+ public final long st_blocks; /*blkcnt_t*/
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid,
+ long st_rdev, long st_size, long st_atime, long st_mtime, long st_ctime,
+ long st_blksize, long st_blocks) {
+ this(st_dev, st_ino, st_mode, st_nlink, st_uid, st_gid,
+ st_rdev, st_size, new StructTimespec(st_atime, 0L), new StructTimespec(st_mtime, 0L),
+ new StructTimespec(st_ctime, 0L), st_blksize, st_blocks);
+ }
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid,
+ long st_rdev, long st_size, StructTimespec st_atim, StructTimespec st_mtim,
+ StructTimespec st_ctim, long st_blksize, long st_blocks) {
+ this.st_dev = st_dev;
+ this.st_ino = st_ino;
+ this.st_mode = st_mode;
+ this.st_nlink = st_nlink;
+ this.st_uid = st_uid;
+ this.st_gid = st_gid;
+ this.st_rdev = st_rdev;
+ this.st_size = st_size;
+ this.st_atime = st_atim.tv_sec;
+ this.st_mtime = st_mtim.tv_sec;
+ this.st_ctime = st_ctim.tv_sec;
+ this.st_atim = st_atim;
+ this.st_mtim = st_mtim;
+ this.st_ctim = st_ctim;
+ this.st_blksize = st_blksize;
+ this.st_blocks = st_blocks;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructStatVfs.java b/android/system/StructStatVfs.java
new file mode 100644
index 00000000..942a39a8
--- /dev/null
+++ b/android/system/StructStatVfs.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * File information returned by {@link Os#fstatvfs} and {@link Os#statvfs}.
+ */
+public final class StructStatVfs {
+ /** File system block size (used for block counts). */
+ public final long f_bsize; /*unsigned long*/
+
+ /** Fundamental file system block size. */
+ public final long f_frsize; /*unsigned long*/
+
+ /** Total block count. */
+ public final long f_blocks; /*fsblkcnt_t*/
+
+ /** Free block count. */
+ public final long f_bfree; /*fsblkcnt_t*/
+
+ /** Free block count available to non-root. */
+ public final long f_bavail; /*fsblkcnt_t*/
+
+ /** Total file (inode) count. */
+ public final long f_files; /*fsfilcnt_t*/
+
+ /** Free file (inode) count. */
+ public final long f_ffree; /*fsfilcnt_t*/
+
+ /** Free file (inode) count available to non-root. */
+ public final long f_favail; /*fsfilcnt_t*/
+
+ /** File system id. */
+ public final long f_fsid; /*unsigned long*/
+
+ /** Bit mask of ST_* flags. */
+ public final long f_flag; /*unsigned long*/
+
+ /** Maximum filename length. */
+ public final long f_namemax; /*unsigned long*/
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructStatVfs(long f_bsize, long f_frsize, long f_blocks, long f_bfree, long f_bavail,
+ long f_files, long f_ffree, long f_favail,
+ long f_fsid, long f_flag, long f_namemax) {
+ this.f_bsize = f_bsize;
+ this.f_frsize = f_frsize;
+ this.f_blocks = f_blocks;
+ this.f_bfree = f_bfree;
+ this.f_bavail = f_bavail;
+ this.f_files = f_files;
+ this.f_ffree = f_ffree;
+ this.f_favail = f_favail;
+ this.f_fsid = f_fsid;
+ this.f_flag = f_flag;
+ this.f_namemax = f_namemax;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructTimespec.java b/android/system/StructTimespec.java
new file mode 100644
index 00000000..b5e192e5
--- /dev/null
+++ b/android/system/StructTimespec.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;;
+
+/**
+ * Corresponds to C's {@code struct timespec} from {@code <time.h>}.
+ */
+public final class StructTimespec implements Comparable<StructTimespec> {
+ /** Seconds part of time of last data modification. */
+ public final long tv_sec; /*time_t*/
+
+ /** Nanoseconds (values are [0, 999999999]). */
+ public final long tv_nsec;
+
+ public StructTimespec(long tv_sec, long tv_nsec) {
+ this.tv_sec = tv_sec;
+ this.tv_nsec = tv_nsec;
+ if (tv_nsec < 0 || tv_nsec > 999_999_999) {
+ throw new IllegalArgumentException(
+ "tv_nsec value " + tv_nsec + " is not in [0, 999999999]");
+ }
+ }
+
+ @Override
+ public int compareTo(StructTimespec other) {
+ if (tv_sec > other.tv_sec) {
+ return 1;
+ }
+ if (tv_sec < other.tv_sec) {
+ return -1;
+ }
+ if (tv_nsec > other.tv_nsec) {
+ return 1;
+ }
+ if (tv_nsec < other.tv_nsec) {
+ return -1;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ StructTimespec that = (StructTimespec) o;
+
+ if (tv_sec != that.tv_sec) return false;
+ return tv_nsec == that.tv_nsec;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (int) (tv_sec ^ (tv_sec >>> 32));
+ result = 31 * result + (int) (tv_nsec ^ (tv_nsec >>> 32));
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructTimeval.java b/android/system/StructTimeval.java
new file mode 100644
index 00000000..8a155b4f
--- /dev/null
+++ b/android/system/StructTimeval.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Corresponds to C's {@code struct timeval} from
+ * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html">&lt;sys/time.h&gt;</a>
+ *
+ * @hide
+ */
+public final class StructTimeval {
+ /** Seconds. */
+ public final long tv_sec;
+
+ /** Microseconds. */
+ public final long tv_usec;
+
+ private StructTimeval(long tv_sec, long tv_usec) {
+ this.tv_sec = tv_sec;
+ this.tv_usec = tv_usec;
+ }
+
+ public static StructTimeval fromMillis(long millis) {
+ long tv_sec = millis / 1000;
+ long tv_usec = (millis - (tv_sec * 1000)) * 1000;
+ return new StructTimeval(tv_sec, tv_usec);
+ }
+
+ public long toMillis() {
+ return (tv_sec * 1000) + (tv_usec / 1000);
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructUcred.java b/android/system/StructUcred.java
new file mode 100644
index 00000000..a1e3cd6e
--- /dev/null
+++ b/android/system/StructUcred.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Corresponds to C's {@code struct ucred}.
+ *
+ * @hide
+ */
+public final class StructUcred {
+ /** The peer's process id. */
+ public final int pid;
+
+ /** The peer process' uid. */
+ public final int uid;
+
+ /** The peer process' gid. */
+ public final int gid;
+
+ public StructUcred(int pid, int uid, int gid) {
+ this.pid = pid;
+ this.uid = uid;
+ this.gid = gid;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/StructUtsname.java b/android/system/StructUtsname.java
new file mode 100644
index 00000000..37778380
--- /dev/null
+++ b/android/system/StructUtsname.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;
+
+/**
+ * Information returned by {@link Os#uname}.
+ * Corresponds to C's {@code struct utsname} from {@code <sys/utsname.h>}.
+ */
+public final class StructUtsname {
+ /** The OS name, such as "Linux". */
+ public final String sysname;
+
+ /** The machine's unqualified name on some implementation-defined network. */
+ public final String nodename;
+
+ /** The OS release, such as "2.6.35-27-generic". */
+ public final String release;
+
+ /** The OS version, such as "#48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011". */
+ public final String version;
+
+ /** The machine architecture, such as "armv7l" or "x86_64". */
+ public final String machine;
+
+ /**
+ * Constructs an instance with the given field values.
+ */
+ public StructUtsname(String sysname, String nodename, String release, String version, String machine) {
+ this.sysname = sysname;
+ this.nodename = nodename;
+ this.release = release;
+ this.version = version;
+ this.machine = machine;
+ }
+
+ @Override public String toString() {
+ return Objects.toString(this);
+ }
+}
diff --git a/android/system/UnixSocketAddress.java b/android/system/UnixSocketAddress.java
new file mode 100644
index 00000000..e0ade789
--- /dev/null
+++ b/android/system/UnixSocketAddress.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import java.net.SocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+/**
+ * A UNIX-domain (AF_UNIX / AF_LOCAL) socket address.
+ *
+ * @hide
+ */
+public final class UnixSocketAddress extends SocketAddress {
+
+ private static final int NAMED_PATH_LENGTH = OsConstants.UNIX_PATH_MAX;
+ private static final byte[] UNNAMED_PATH = new byte[0];
+
+ // See unix(7): Three types of UnixSocketAddress:
+ // 1) pathname: 0 < sun_path.length <= NAMED_PATH_LENGTH, sun_path[0] != 0.
+ // 2) unnamed: sun_path = [].
+ // 3) abstract: 0 < sun_path.length <= NAMED_PATH_LENGTH, sun_path[0] == 0.
+ private byte[] sun_path;
+
+ /** This constructor is also used from JNI. */
+ private UnixSocketAddress(byte[] sun_path) {
+ if (sun_path == null) {
+ throw new IllegalArgumentException("sun_path must not be null");
+ }
+ if (sun_path.length > NAMED_PATH_LENGTH) {
+ throw new IllegalArgumentException("sun_path exceeds the maximum length");
+ }
+
+ if (sun_path.length == 0) {
+ this.sun_path = UNNAMED_PATH;
+ } else {
+ this.sun_path = new byte[sun_path.length];
+ System.arraycopy(sun_path, 0, this.sun_path, 0, sun_path.length);
+ }
+ }
+
+ /**
+ * Creates a named, abstract AF_UNIX socket address.
+ */
+ public static UnixSocketAddress createAbstract(String name) {
+ byte[] nameBytes = name.getBytes(StandardCharsets.UTF_8);
+ // Abstract sockets have a path that starts with (byte) 0.
+ byte[] path = new byte[nameBytes.length + 1];
+ System.arraycopy(nameBytes, 0, path, 1, nameBytes.length);
+ return new UnixSocketAddress(path);
+ }
+
+ /**
+ * Creates a named, filesystem AF_UNIX socket address.
+ */
+ public static UnixSocketAddress createFileSystem(String pathName) {
+ byte[] pathNameBytes = pathName.getBytes(StandardCharsets.UTF_8);
+ // File system sockets have a path that ends with (byte) 0.
+ byte[] path = new byte[pathNameBytes.length + 1];
+ System.arraycopy(pathNameBytes, 0, path, 0, pathNameBytes.length);
+ return new UnixSocketAddress(path);
+ }
+
+ /**
+ * Creates an unnamed, filesystem AF_UNIX socket address.
+ */
+ public static UnixSocketAddress createUnnamed() {
+ return new UnixSocketAddress(UNNAMED_PATH);
+ }
+
+ /** Used for testing. */
+ public byte[] getSunPath() {
+ if (sun_path.length == 0) {
+ return sun_path;
+ }
+ byte[] sunPathCopy = new byte[sun_path.length];
+ System.arraycopy(sun_path, 0, sunPathCopy, 0, sun_path.length);
+ return sunPathCopy;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ UnixSocketAddress that = (UnixSocketAddress) o;
+ return Arrays.equals(sun_path, that.sun_path);
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(sun_path);
+ }
+
+ @Override
+ public String toString() {
+ return "UnixSocketAddress[" +
+ "sun_path=" + Arrays.toString(sun_path) +
+ ']';
+ }
+}
diff --git a/android/system/UnixSocketAddressTest.java b/android/system/UnixSocketAddressTest.java
new file mode 100644
index 00000000..f1b7fc23
--- /dev/null
+++ b/android/system/UnixSocketAddressTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import junit.framework.TestCase;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+public class UnixSocketAddressTest extends TestCase {
+
+ public void testFilesystemSunPath() throws Exception {
+ String path = "/foo/bar";
+ UnixSocketAddress sa = UnixSocketAddress.createFileSystem(path);
+
+ byte[] abstractNameBytes = path.getBytes(StandardCharsets.UTF_8);
+ byte[] expected = new byte[abstractNameBytes.length + 1];
+ // See unix(7)
+ System.arraycopy(abstractNameBytes, 0, expected, 0, abstractNameBytes.length);
+ assertTrue(Arrays.equals(expected, sa.getSunPath()));
+ }
+
+ public void testUnnamedSunPath() throws Exception {
+ UnixSocketAddress sa = UnixSocketAddress.createUnnamed();
+ assertEquals(0, sa.getSunPath().length);
+ }
+
+ public void testAbstractSunPath() throws Exception {
+ String abstractName = "abstract";
+ UnixSocketAddress sa = UnixSocketAddress.createAbstract(abstractName);
+ byte[] abstractNameBytes = abstractName.getBytes(StandardCharsets.UTF_8);
+ byte[] expected = new byte[abstractNameBytes.length + 1];
+ // See unix(7)
+ System.arraycopy(abstractNameBytes, 0, expected, 1, abstractNameBytes.length);
+ assertTrue(Arrays.equals(expected, sa.getSunPath()));
+ }
+}