1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.system; 18 19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 20 21 import android.annotation.SystemApi; 22 import android.compat.annotation.UnsupportedAppUsage; 23 24 /** 25 * Constants and helper functions for use with {@link Os}. 26 */ 27 public final class OsConstants { 28 @UnsupportedAppUsage OsConstants()29 private OsConstants() { 30 } 31 32 /** 33 * Returns the index of the element in the {@link StructCapUserData} (cap_user_data) 34 * array that this capability is stored in. 35 * 36 * @param x capability 37 * @return index of the element in the {@link StructCapUserData} array storing this capability 38 * 39 * @hide 40 */ 41 @UnsupportedAppUsage 42 @SystemApi(client = MODULE_LIBRARIES) 43 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) CAP_TO_INDEX(int x)44 public static int CAP_TO_INDEX(int x) { return x >>> 5; } 45 46 /** 47 * Returns the mask for the given capability. This is relative to the capability's 48 * {@link StructCapUserData} (cap_user_data) element, the index of which can be 49 * retrieved with {@link CAP_TO_INDEX}. 50 * 51 * @param x capability 52 * @return mask for given capability 53 * 54 * @hide 55 */ 56 @UnsupportedAppUsage 57 @SystemApi(client = MODULE_LIBRARIES) 58 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) CAP_TO_MASK(int x)59 public static int CAP_TO_MASK(int x) { return 1 << (x & 31); } 60 61 /** 62 * Tests whether the given mode is a block device. 63 */ S_ISBLK(int mode)64 public static boolean S_ISBLK(int mode) { return (mode & S_IFMT) == S_IFBLK; } 65 66 /** 67 * Tests whether the given mode is a character device. 68 */ S_ISCHR(int mode)69 public static boolean S_ISCHR(int mode) { return (mode & S_IFMT) == S_IFCHR; } 70 71 /** 72 * Tests whether the given mode is a directory. 73 */ S_ISDIR(int mode)74 public static boolean S_ISDIR(int mode) { return (mode & S_IFMT) == S_IFDIR; } 75 76 /** 77 * Tests whether the given mode is a FIFO. 78 */ S_ISFIFO(int mode)79 public static boolean S_ISFIFO(int mode) { return (mode & S_IFMT) == S_IFIFO; } 80 81 /** 82 * Tests whether the given mode is a regular file. 83 */ S_ISREG(int mode)84 public static boolean S_ISREG(int mode) { return (mode & S_IFMT) == S_IFREG; } 85 86 /** 87 * Tests whether the given mode is a symbolic link. 88 */ S_ISLNK(int mode)89 public static boolean S_ISLNK(int mode) { return (mode & S_IFMT) == S_IFLNK; } 90 91 /** 92 * Tests whether the given mode is a socket. 93 */ S_ISSOCK(int mode)94 public static boolean S_ISSOCK(int mode) { return (mode & S_IFMT) == S_IFSOCK; } 95 96 /** 97 * Extracts the exit status of a child. Only valid if WIFEXITED returns true. 98 */ WEXITSTATUS(int status)99 public static int WEXITSTATUS(int status) { return (status & 0xff00) >> 8; } 100 101 /** 102 * Tests whether the child dumped core. Only valid if WIFSIGNALED returns true. 103 */ WCOREDUMP(int status)104 public static boolean WCOREDUMP(int status) { return (status & 0x80) != 0; } 105 106 /** 107 * Returns the signal that caused the child to exit. Only valid if WIFSIGNALED returns true. 108 */ WTERMSIG(int status)109 public static int WTERMSIG(int status) { return status & 0x7f; } 110 111 /** 112 * Returns the signal that cause the child to stop. Only valid if WIFSTOPPED returns true. 113 */ WSTOPSIG(int status)114 public static int WSTOPSIG(int status) { return WEXITSTATUS(status); } 115 116 /** 117 * Tests whether the child exited normally. 118 */ WIFEXITED(int status)119 public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); } 120 121 /** 122 * Tests whether the child was stopped (not terminated) by a signal. 123 */ WIFSTOPPED(int status)124 public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); } 125 126 /** 127 * Tests whether the child was terminated by a signal. 128 */ WIFSIGNALED(int status)129 public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); } 130 131 public static final int AF_INET = placeholder(); 132 public static final int AF_INET6 = placeholder(); 133 public static final int AF_NETLINK = placeholder(); 134 public static final int AF_PACKET = placeholder(); 135 public static final int AF_UNIX = placeholder(); 136 137 /** 138 * The virt-vsock address family, linux specific. 139 * It is used with {@code struct sockaddr_vm} from uapi/linux/vm_sockets.h. 140 * 141 * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a> 142 * @see VmSocketAddress 143 */ 144 public static final int AF_VSOCK = placeholder(); 145 public static final int AF_UNSPEC = placeholder(); 146 public static final int AI_ADDRCONFIG = placeholder(); 147 public static final int AI_ALL = placeholder(); 148 public static final int AI_CANONNAME = placeholder(); 149 public static final int AI_NUMERICHOST = placeholder(); 150 public static final int AI_NUMERICSERV = placeholder(); 151 public static final int AI_PASSIVE = placeholder(); 152 public static final int AI_V4MAPPED = placeholder(); 153 public static final int ARPHRD_ETHER = placeholder(); 154 155 /** 156 * The virtio-vsock {@code svmPort} value to bind for any available port. 157 * 158 * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a> 159 * @see VmSocketAddress 160 */ 161 public static final int VMADDR_PORT_ANY = placeholder(); 162 163 /** 164 * The virtio-vsock {@code svmCid} value to listens for all CIDs. 165 * 166 * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a> 167 * @see VmSocketAddress 168 */ 169 public static final int VMADDR_CID_ANY = placeholder(); 170 171 /** 172 * The virtio-vsock {@code svmCid} value for host communication. 173 * 174 * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a> 175 * @see VmSocketAddress 176 */ 177 public static final int VMADDR_CID_LOCAL = placeholder(); 178 179 /** 180 * The virtio-vsock {@code svmCid} value for loopback communication. 181 * 182 * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a> 183 * @see VmSocketAddress 184 */ 185 public static final int VMADDR_CID_HOST = placeholder(); 186 187 /** 188 * ARP protocol loopback device identifier. 189 * 190 * @hide 191 */ 192 @UnsupportedAppUsage 193 @SystemApi(client = MODULE_LIBRARIES) 194 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 195 public static final int ARPHRD_LOOPBACK = placeholder(); 196 public static final int CAP_AUDIT_CONTROL = placeholder(); 197 public static final int CAP_AUDIT_WRITE = placeholder(); 198 public static final int CAP_BLOCK_SUSPEND = placeholder(); 199 public static final int CAP_CHOWN = placeholder(); 200 public static final int CAP_DAC_OVERRIDE = placeholder(); 201 public static final int CAP_DAC_READ_SEARCH = placeholder(); 202 public static final int CAP_FOWNER = placeholder(); 203 public static final int CAP_FSETID = placeholder(); 204 public static final int CAP_IPC_LOCK = placeholder(); 205 public static final int CAP_IPC_OWNER = placeholder(); 206 public static final int CAP_KILL = placeholder(); 207 public static final int CAP_LAST_CAP = placeholder(); 208 public static final int CAP_LEASE = placeholder(); 209 public static final int CAP_LINUX_IMMUTABLE = placeholder(); 210 public static final int CAP_MAC_ADMIN = placeholder(); 211 public static final int CAP_MAC_OVERRIDE = placeholder(); 212 public static final int CAP_MKNOD = placeholder(); 213 public static final int CAP_NET_ADMIN = placeholder(); 214 public static final int CAP_NET_BIND_SERVICE = placeholder(); 215 public static final int CAP_NET_BROADCAST = placeholder(); 216 public static final int CAP_NET_RAW = placeholder(); 217 public static final int CAP_SETFCAP = placeholder(); 218 public static final int CAP_SETGID = placeholder(); 219 public static final int CAP_SETPCAP = placeholder(); 220 public static final int CAP_SETUID = placeholder(); 221 public static final int CAP_SYS_ADMIN = placeholder(); 222 public static final int CAP_SYS_BOOT = placeholder(); 223 public static final int CAP_SYS_CHROOT = placeholder(); 224 public static final int CAP_SYSLOG = placeholder(); 225 public static final int CAP_SYS_MODULE = placeholder(); 226 public static final int CAP_SYS_NICE = placeholder(); 227 public static final int CAP_SYS_PACCT = placeholder(); 228 public static final int CAP_SYS_PTRACE = placeholder(); 229 public static final int CAP_SYS_RAWIO = placeholder(); 230 public static final int CAP_SYS_RESOURCE = placeholder(); 231 public static final int CAP_SYS_TIME = placeholder(); 232 public static final int CAP_SYS_TTY_CONFIG = placeholder(); 233 public static final int CAP_WAKE_ALARM = placeholder(); 234 public static final int E2BIG = placeholder(); 235 public static final int EACCES = placeholder(); 236 public static final int EADDRINUSE = placeholder(); 237 public static final int EADDRNOTAVAIL = placeholder(); 238 public static final int EAFNOSUPPORT = placeholder(); 239 public static final int EAGAIN = placeholder(); 240 public static final int EAI_AGAIN = placeholder(); 241 public static final int EAI_BADFLAGS = placeholder(); 242 public static final int EAI_FAIL = placeholder(); 243 public static final int EAI_FAMILY = placeholder(); 244 public static final int EAI_MEMORY = placeholder(); 245 public static final int EAI_NODATA = placeholder(); 246 public static final int EAI_NONAME = placeholder(); 247 public static final int EAI_OVERFLOW = placeholder(); 248 public static final int EAI_SERVICE = placeholder(); 249 public static final int EAI_SOCKTYPE = placeholder(); 250 public static final int EAI_SYSTEM = placeholder(); 251 public static final int EALREADY = placeholder(); 252 public static final int EBADF = placeholder(); 253 public static final int EBADMSG = placeholder(); 254 public static final int EBUSY = placeholder(); 255 public static final int ECANCELED = placeholder(); 256 public static final int ECHILD = placeholder(); 257 public static final int ECONNABORTED = placeholder(); 258 public static final int ECONNREFUSED = placeholder(); 259 public static final int ECONNRESET = placeholder(); 260 public static final int EDEADLK = placeholder(); 261 public static final int EDESTADDRREQ = placeholder(); 262 public static final int EDOM = placeholder(); 263 public static final int EDQUOT = placeholder(); 264 public static final int EEXIST = placeholder(); 265 public static final int EFAULT = placeholder(); 266 public static final int EFBIG = placeholder(); 267 public static final int EHOSTUNREACH = placeholder(); 268 public static final int EIDRM = placeholder(); 269 public static final int EILSEQ = placeholder(); 270 public static final int EINPROGRESS = placeholder(); 271 public static final int EINTR = placeholder(); 272 public static final int EINVAL = placeholder(); 273 public static final int EIO = placeholder(); 274 public static final int EISCONN = placeholder(); 275 public static final int EISDIR = placeholder(); 276 public static final int ELOOP = placeholder(); 277 public static final int EMFILE = placeholder(); 278 public static final int EMLINK = placeholder(); 279 public static final int EMSGSIZE = placeholder(); 280 public static final int EMULTIHOP = placeholder(); 281 public static final int ENAMETOOLONG = placeholder(); 282 public static final int ENETDOWN = placeholder(); 283 public static final int ENETRESET = placeholder(); 284 public static final int ENETUNREACH = placeholder(); 285 public static final int ENFILE = placeholder(); 286 public static final int ENOBUFS = placeholder(); 287 public static final int ENODATA = placeholder(); 288 public static final int ENODEV = placeholder(); 289 public static final int ENOENT = placeholder(); 290 public static final int ENOEXEC = placeholder(); 291 public static final int ENOLCK = placeholder(); 292 public static final int ENOLINK = placeholder(); 293 public static final int ENOMEM = placeholder(); 294 public static final int ENOMSG = placeholder(); 295 public static final int ENONET = placeholder(); 296 public static final int ENOPROTOOPT = placeholder(); 297 public static final int ENOSPC = placeholder(); 298 public static final int ENOSR = placeholder(); 299 public static final int ENOSTR = placeholder(); 300 public static final int ENOSYS = placeholder(); 301 public static final int ENOTCONN = placeholder(); 302 public static final int ENOTDIR = placeholder(); 303 public static final int ENOTEMPTY = placeholder(); 304 public static final int ENOTSOCK = placeholder(); 305 public static final int ENOTSUP = placeholder(); 306 public static final int ENOTTY = placeholder(); 307 public static final int ENXIO = placeholder(); 308 public static final int EOPNOTSUPP = placeholder(); 309 public static final int EOVERFLOW = placeholder(); 310 public static final int EPERM = placeholder(); 311 public static final int EPIPE = placeholder(); 312 public static final int EPROTO = placeholder(); 313 public static final int EPROTONOSUPPORT = placeholder(); 314 public static final int EPROTOTYPE = placeholder(); 315 public static final int ERANGE = placeholder(); 316 public static final int EROFS = placeholder(); 317 public static final int ESPIPE = placeholder(); 318 public static final int ESRCH = placeholder(); 319 public static final int ESTALE = placeholder(); 320 public static final int ETH_P_ALL = placeholder(); 321 public static final int ETH_P_ARP = placeholder(); 322 public static final int ETH_P_IP = placeholder(); 323 public static final int ETH_P_IPV6 = placeholder(); 324 public static final int ETIME = placeholder(); 325 public static final int ETIMEDOUT = placeholder(); 326 public static final int ETXTBSY = placeholder(); 327 /** 328 * "Too many users" error. 329 * See <a href="https://man7.org/linux/man-pages/man3/errno.3.html">errno(3)</a>. 330 * 331 * @hide 332 */ 333 @UnsupportedAppUsage 334 @SystemApi(client = MODULE_LIBRARIES) 335 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 336 public static final int EUSERS = placeholder(); 337 // On Linux, EWOULDBLOCK == EAGAIN. Use EAGAIN instead, to reduce confusion. 338 public static final int EXDEV = placeholder(); 339 public static final int EXIT_FAILURE = placeholder(); 340 public static final int EXIT_SUCCESS = placeholder(); 341 public static final int FD_CLOEXEC = placeholder(); 342 public static final int FIONREAD = placeholder(); 343 public static final int F_DUPFD = placeholder(); 344 public static final int F_DUPFD_CLOEXEC = placeholder(); 345 public static final int F_GETFD = placeholder(); 346 public static final int F_GETFL = placeholder(); 347 public static final int F_GETLK = placeholder(); 348 public static final int F_GETLK64 = placeholder(); 349 public static final int F_GETOWN = placeholder(); 350 public static final int F_OK = placeholder(); 351 public static final int F_RDLCK = placeholder(); 352 public static final int F_SETFD = placeholder(); 353 public static final int F_SETFL = placeholder(); 354 public static final int F_SETLK = placeholder(); 355 public static final int F_SETLK64 = placeholder(); 356 public static final int F_SETLKW = placeholder(); 357 public static final int F_SETLKW64 = placeholder(); 358 public static final int F_SETOWN = placeholder(); 359 public static final int F_UNLCK = placeholder(); 360 public static final int F_WRLCK = placeholder(); 361 public static final int ICMP_ECHO = placeholder(); 362 public static final int ICMP_ECHOREPLY = placeholder(); 363 public static final int ICMP6_ECHO_REQUEST = placeholder(); 364 public static final int ICMP6_ECHO_REPLY = placeholder(); 365 public static final int IFA_F_DADFAILED = placeholder(); 366 public static final int IFA_F_DEPRECATED = placeholder(); 367 public static final int IFA_F_HOMEADDRESS = placeholder(); 368 public static final int IFA_F_NODAD = placeholder(); 369 public static final int IFA_F_OPTIMISTIC = placeholder(); 370 public static final int IFA_F_PERMANENT = placeholder(); 371 public static final int IFA_F_SECONDARY = placeholder(); 372 public static final int IFA_F_TEMPORARY = placeholder(); 373 public static final int IFA_F_TENTATIVE = placeholder(); 374 public static final int IFF_ALLMULTI = placeholder(); 375 public static final int IFF_AUTOMEDIA = placeholder(); 376 public static final int IFF_BROADCAST = placeholder(); 377 public static final int IFF_DEBUG = placeholder(); 378 public static final int IFF_DYNAMIC = placeholder(); 379 public static final int IFF_LOOPBACK = placeholder(); 380 public static final int IFF_MASTER = placeholder(); 381 public static final int IFF_MULTICAST = placeholder(); 382 public static final int IFF_NOARP = placeholder(); 383 public static final int IFF_NOTRAILERS = placeholder(); 384 public static final int IFF_POINTOPOINT = placeholder(); 385 public static final int IFF_PORTSEL = placeholder(); 386 public static final int IFF_PROMISC = placeholder(); 387 public static final int IFF_RUNNING = placeholder(); 388 public static final int IFF_SLAVE = placeholder(); 389 public static final int IFF_UP = placeholder(); 390 public static final int IPPROTO_ICMP = placeholder(); 391 public static final int IPPROTO_ICMPV6 = placeholder(); 392 public static final int IPPROTO_IP = placeholder(); 393 public static final int IPPROTO_IPV6 = placeholder(); 394 public static final int IPPROTO_RAW = placeholder(); 395 public static final int IPPROTO_TCP = placeholder(); 396 public static final int IPPROTO_UDP = placeholder(); 397 public static final int IPV6_CHECKSUM = placeholder(); 398 public static final int IPV6_MULTICAST_HOPS = placeholder(); 399 public static final int IPV6_MULTICAST_IF = placeholder(); 400 public static final int IPV6_MULTICAST_LOOP = placeholder(); 401 public static final int IPV6_RECVDSTOPTS = placeholder(); 402 public static final int IPV6_RECVHOPLIMIT = placeholder(); 403 public static final int IPV6_RECVHOPOPTS = placeholder(); 404 public static final int IPV6_RECVPKTINFO = placeholder(); 405 public static final int IPV6_RECVRTHDR = placeholder(); 406 public static final int IPV6_RECVTCLASS = placeholder(); 407 public static final int IPV6_TCLASS = placeholder(); 408 public static final int IPV6_UNICAST_HOPS = placeholder(); 409 public static final int IPV6_V6ONLY = placeholder(); 410 /** @hide */ 411 @UnsupportedAppUsage 412 public static final int IP_MULTICAST_ALL = placeholder(); 413 public static final int IP_MULTICAST_IF = placeholder(); 414 public static final int IP_MULTICAST_LOOP = placeholder(); 415 public static final int IP_MULTICAST_TTL = placeholder(); 416 /** @hide */ 417 @UnsupportedAppUsage 418 public static final int IP_RECVTOS = placeholder(); 419 public static final int IP_TOS = placeholder(); 420 public static final int IP_TTL = placeholder(); 421 /** 422 * Version constant to be used in {@link StructCapUserHeader} with 423 * {@link Os#capset(StructCapUserHeader, StructCapUserData[])} and 424 * {@link Os#capget(StructCapUserHeader)}. 425 * 426 * See <a href="https://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>. 427 * 428 * @hide 429 */ 430 @UnsupportedAppUsage 431 @SystemApi(client = MODULE_LIBRARIES) 432 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 433 public static final int _LINUX_CAPABILITY_VERSION_3 = placeholder(); 434 public static final int MAP_FIXED = placeholder(); 435 public static final int MAP_ANONYMOUS = placeholder(); 436 /** 437 * Flag argument for {@code mmap(long, long, int, int, FileDescriptor, long)}. 438 * 439 * See <a href="http://man7.org/linux/man-pages/man2/mmap.2.html">mmap(2)</a>. 440 * 441 * @hide 442 */ 443 @UnsupportedAppUsage 444 @SystemApi(client = MODULE_LIBRARIES) 445 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 446 public static final int MAP_POPULATE = placeholder(); 447 public static final int MAP_PRIVATE = placeholder(); 448 public static final int MAP_SHARED = placeholder(); 449 public static final int MCAST_JOIN_GROUP = placeholder(); 450 public static final int MCAST_LEAVE_GROUP = placeholder(); 451 public static final int MCAST_JOIN_SOURCE_GROUP = placeholder(); 452 public static final int MCAST_LEAVE_SOURCE_GROUP = placeholder(); 453 public static final int MCAST_BLOCK_SOURCE = placeholder(); 454 public static final int MCAST_UNBLOCK_SOURCE = placeholder(); 455 public static final int MCL_CURRENT = placeholder(); 456 public static final int MCL_FUTURE = placeholder(); 457 public static final int MFD_CLOEXEC = placeholder(); 458 public static final int MSG_CTRUNC = placeholder(); 459 public static final int MSG_DONTROUTE = placeholder(); 460 public static final int MSG_EOR = placeholder(); 461 public static final int MSG_OOB = placeholder(); 462 public static final int MSG_PEEK = placeholder(); 463 public static final int MSG_TRUNC = placeholder(); 464 public static final int MSG_WAITALL = placeholder(); 465 public static final int MS_ASYNC = placeholder(); 466 public static final int MS_INVALIDATE = placeholder(); 467 public static final int MS_SYNC = placeholder(); 468 public static final int NETLINK_NETFILTER = placeholder(); 469 public static final int NETLINK_ROUTE = placeholder(); 470 /** 471 * SELinux enforces that only system_server and netd may use this netlink socket type. 472 */ 473 public static final int NETLINK_INET_DIAG = placeholder(); 474 public static final int NI_DGRAM = placeholder(); 475 public static final int NI_NAMEREQD = placeholder(); 476 public static final int NI_NOFQDN = placeholder(); 477 public static final int NI_NUMERICHOST = placeholder(); 478 public static final int NI_NUMERICSERV = placeholder(); 479 public static final int O_ACCMODE = placeholder(); 480 public static final int O_APPEND = placeholder(); 481 public static final int O_CLOEXEC = placeholder(); 482 public static final int O_CREAT = placeholder(); 483 /** 484 * Flag for {@code Os#open(String, int, int)}. 485 * 486 * When enabled, tries to minimize cache effects of the I/O to and from this 487 * file. In general this will degrade performance, but it is 488 * useful in special situations, such as when applications do 489 * their own caching. File I/O is done directly to/from 490 * user-space buffers. The {@link O_DIRECT} flag on its own makes an 491 * effort to transfer data synchronously, but does not give 492 * the guarantees of the {@link O_SYNC} flag that data and necessary 493 * metadata are transferred. To guarantee synchronous I/O, 494 * {@link O_SYNC} must be used in addition to {@link O_DIRECT}. 495 * 496 * See <a href="https://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>. 497 * 498 * @hide 499 */ 500 @UnsupportedAppUsage 501 @SystemApi(client = MODULE_LIBRARIES) 502 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 503 public static final int O_DIRECT = placeholder(); 504 public static final int O_EXCL = placeholder(); 505 public static final int O_NOCTTY = placeholder(); 506 public static final int O_NOFOLLOW = placeholder(); 507 public static final int O_NONBLOCK = placeholder(); 508 public static final int O_RDONLY = placeholder(); 509 public static final int O_RDWR = placeholder(); 510 public static final int O_SYNC = placeholder(); 511 public static final int O_DSYNC = placeholder(); 512 public static final int O_TRUNC = placeholder(); 513 public static final int O_WRONLY = placeholder(); 514 public static final int POLLERR = placeholder(); 515 public static final int POLLHUP = placeholder(); 516 public static final int POLLIN = placeholder(); 517 public static final int POLLNVAL = placeholder(); 518 public static final int POLLOUT = placeholder(); 519 public static final int POLLPRI = placeholder(); 520 public static final int POLLRDBAND = placeholder(); 521 public static final int POLLRDNORM = placeholder(); 522 public static final int POLLWRBAND = placeholder(); 523 public static final int POLLWRNORM = placeholder(); 524 /** 525 * Reads or changes the ambient capability set of the calling thread. 526 * Has to be used as a first argument for {@link Os#prctl(int, long, long, long, long)}. 527 * 528 * See <a href="https://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a>. 529 * 530 * @hide 531 */ 532 @UnsupportedAppUsage 533 @SystemApi(client = MODULE_LIBRARIES) 534 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 535 public static final int PR_CAP_AMBIENT = placeholder(); 536 /** 537 * The capability specified in {@code arg3} of {@link Os#prctl(int, long, long, long, long)} 538 * is added to the ambient set. The specified capability must already 539 * be present in both the permitted and the inheritable sets of the process. 540 * Has to be used as a second argument for {@link Os#prctl(int, long, long, long, long)}. 541 * 542 * See <a href="https://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a>. 543 * @hide 544 */ 545 @UnsupportedAppUsage 546 @SystemApi(client = MODULE_LIBRARIES) 547 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 548 public static final int PR_CAP_AMBIENT_RAISE = placeholder(); 549 public static final int PR_GET_DUMPABLE = placeholder(); 550 public static final int PR_SET_DUMPABLE = placeholder(); 551 public static final int PR_SET_NO_NEW_PRIVS = placeholder(); 552 public static final int PROT_EXEC = placeholder(); 553 public static final int PROT_NONE = placeholder(); 554 public static final int PROT_READ = placeholder(); 555 public static final int PROT_WRITE = placeholder(); 556 public static final int R_OK = placeholder(); 557 /** 558 * Specifies a value one greater than the maximum file 559 * descriptor number that can be opened by this process. 560 * 561 * <p>Attempts ({@link Os#open(String, int, int)}, {@link Os#pipe()}, 562 * {@link Os#dup(java.io.FileDescriptor)}, etc.) to exceed this 563 * limit yield the error {@link EMFILE}. 564 * 565 * See <a href="https://man7.org/linux/man-pages/man3/vlimit.3.html">getrlimit(2)</a>. 566 * 567 * @hide 568 */ 569 @UnsupportedAppUsage 570 @SystemApi(client = MODULE_LIBRARIES) 571 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 572 public static final int RLIMIT_NOFILE = placeholder(); 573 public static final int RT_SCOPE_HOST = placeholder(); 574 public static final int RT_SCOPE_LINK = placeholder(); 575 public static final int RT_SCOPE_NOWHERE = placeholder(); 576 public static final int RT_SCOPE_SITE = placeholder(); 577 public static final int RT_SCOPE_UNIVERSE = placeholder(); 578 /** 579 * Bitmask for IPv4 addresses add/delete events multicast groups mask. 580 * Used in {@link NetlinkSocketAddress}. 581 * 582 * See <a href="https://man7.org/linux/man-pages/man7/netlink.7.html">netlink(7)</a>. 583 * 584 * @hide 585 */ 586 @UnsupportedAppUsage 587 @SystemApi(client = MODULE_LIBRARIES) 588 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 589 public static final int RTMGRP_IPV4_IFADDR = placeholder(); 590 /** @hide */ 591 @UnsupportedAppUsage 592 public static final int RTMGRP_IPV4_MROUTE = placeholder(); 593 /** @hide */ 594 @UnsupportedAppUsage 595 public static final int RTMGRP_IPV4_ROUTE = placeholder(); 596 /** @hide */ 597 @UnsupportedAppUsage 598 public static final int RTMGRP_IPV4_RULE = placeholder(); 599 /** @hide */ 600 @UnsupportedAppUsage 601 public static final int RTMGRP_IPV6_IFADDR = placeholder(); 602 /** @hide */ 603 @UnsupportedAppUsage 604 public static final int RTMGRP_IPV6_IFINFO = placeholder(); 605 /** @hide */ 606 @UnsupportedAppUsage 607 public static final int RTMGRP_IPV6_MROUTE = placeholder(); 608 /** @hide */ 609 @UnsupportedAppUsage 610 public static final int RTMGRP_IPV6_PREFIX = placeholder(); 611 /** @hide */ 612 @UnsupportedAppUsage 613 public static final int RTMGRP_IPV6_ROUTE = placeholder(); 614 /** @hide */ 615 @UnsupportedAppUsage 616 public static final int RTMGRP_LINK = placeholder(); 617 public static final int RTMGRP_NEIGH = placeholder(); 618 /** @hide */ 619 @UnsupportedAppUsage 620 public static final int RTMGRP_NOTIFY = placeholder(); 621 /** @hide */ 622 @UnsupportedAppUsage 623 public static final int RTMGRP_TC = placeholder(); 624 public static final int SEEK_CUR = placeholder(); 625 public static final int SEEK_END = placeholder(); 626 public static final int SEEK_SET = placeholder(); 627 public static final int SHUT_RD = placeholder(); 628 public static final int SHUT_RDWR = placeholder(); 629 public static final int SHUT_WR = placeholder(); 630 public static final int SIGABRT = placeholder(); 631 public static final int SIGALRM = placeholder(); 632 public static final int SIGBUS = placeholder(); 633 public static final int SIGCHLD = placeholder(); 634 public static final int SIGCONT = placeholder(); 635 public static final int SIGFPE = placeholder(); 636 public static final int SIGHUP = placeholder(); 637 public static final int SIGILL = placeholder(); 638 public static final int SIGINT = placeholder(); 639 public static final int SIGIO = placeholder(); 640 public static final int SIGKILL = placeholder(); 641 public static final int SIGPIPE = placeholder(); 642 public static final int SIGPROF = placeholder(); 643 public static final int SIGPWR = placeholder(); 644 public static final int SIGQUIT = placeholder(); 645 public static final int SIGRTMAX = placeholder(); 646 public static final int SIGRTMIN = placeholder(); 647 public static final int SIGSEGV = placeholder(); 648 public static final int SIGSTKFLT = placeholder(); 649 public static final int SIGSTOP = placeholder(); 650 public static final int SIGSYS = placeholder(); 651 public static final int SIGTERM = placeholder(); 652 public static final int SIGTRAP = placeholder(); 653 public static final int SIGTSTP = placeholder(); 654 public static final int SIGTTIN = placeholder(); 655 public static final int SIGTTOU = placeholder(); 656 public static final int SIGURG = placeholder(); 657 public static final int SIGUSR1 = placeholder(); 658 public static final int SIGUSR2 = placeholder(); 659 public static final int SIGVTALRM = placeholder(); 660 public static final int SIGWINCH = placeholder(); 661 public static final int SIGXCPU = placeholder(); 662 public static final int SIGXFSZ = placeholder(); 663 public static final int SIOCGIFADDR = placeholder(); 664 public static final int SIOCGIFBRDADDR = placeholder(); 665 public static final int SIOCGIFDSTADDR = placeholder(); 666 public static final int SIOCGIFNETMASK = placeholder(); 667 668 /** 669 * Set the close-on-exec ({@code FD_CLOEXEC}) flag on the new file 670 * descriptor created by {@link Os#socket(int,int,int)} or 671 * {@link Os#socketpair(int,int,int,java.io.FileDescriptor,java.io.FileDescriptor)}. 672 * See the description of the O_CLOEXEC flag in 673 * <a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a> 674 * for reasons why this may be useful. 675 * 676 * <p>Applications wishing to make use of this flag on older API versions 677 * may use {@link #O_CLOEXEC} instead. On Android, {@code O_CLOEXEC} and 678 * {@code SOCK_CLOEXEC} are the same value. 679 */ 680 public static final int SOCK_CLOEXEC = placeholder(); 681 public static final int SOCK_DGRAM = placeholder(); 682 683 /** 684 * Set the O_NONBLOCK file status flag on the file descriptor 685 * created by {@link Os#socket(int,int,int)} or 686 * {@link Os#socketpair(int,int,int,java.io.FileDescriptor,java.io.FileDescriptor)}. 687 * 688 * <p>Applications wishing to make use of this flag on older API versions 689 * may use {@link #O_NONBLOCK} instead. On Android, {@code O_NONBLOCK} 690 * and {@code SOCK_NONBLOCK} are the same value. 691 */ 692 public static final int SOCK_NONBLOCK = placeholder(); 693 public static final int SOCK_RAW = placeholder(); 694 public static final int SOCK_SEQPACKET = placeholder(); 695 public static final int SOCK_STREAM = placeholder(); 696 public static final int SOL_SOCKET = placeholder(); 697 public static final int SOL_UDP = placeholder(); 698 public static final int SO_BINDTODEVICE = placeholder(); 699 public static final int SO_BROADCAST = placeholder(); 700 public static final int SO_DEBUG = placeholder(); 701 /** @hide */ 702 @UnsupportedAppUsage 703 public static final int SO_DOMAIN = placeholder(); 704 public static final int SO_DONTROUTE = placeholder(); 705 public static final int SO_ERROR = placeholder(); 706 public static final int SO_KEEPALIVE = placeholder(); 707 public static final int SO_LINGER = placeholder(); 708 public static final int SO_OOBINLINE = placeholder(); 709 public static final int SO_PASSCRED = placeholder(); 710 public static final int SO_PEERCRED = placeholder(); 711 /** @hide */ 712 @UnsupportedAppUsage 713 public static final int SO_PROTOCOL = placeholder(); 714 public static final int SO_RCVBUF = placeholder(); 715 public static final int SO_RCVLOWAT = placeholder(); 716 public static final int SO_RCVTIMEO = placeholder(); 717 public static final int SO_REUSEADDR = placeholder(); 718 public static final int SO_SNDBUF = placeholder(); 719 public static final int SO_SNDLOWAT = placeholder(); 720 public static final int SO_SNDTIMEO = placeholder(); 721 public static final int SO_TYPE = placeholder(); 722 /** 723 * Bitmask for flags argument of 724 * {@link splice(java.io.FileDescriptor, Int64Ref, FileDescriptor, Int64Ref, long, int)}. 725 * 726 * Attempt to move pages instead of copying. This is only a 727 * hint to the kernel: pages may still be copied if the 728 * kernel cannot move the pages from the pipe, or if the pipe 729 * buffers don't refer to full pages. 730 * 731 * See <a href="https://man7.org/linux/man-pages/man2/splice.2.html">splice(2)</a>. 732 * 733 * @hide 734 */ 735 @UnsupportedAppUsage 736 @SystemApi(client = MODULE_LIBRARIES) 737 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 738 public static final int SPLICE_F_MOVE = placeholder(); 739 /** @hide */ 740 @UnsupportedAppUsage 741 public static final int SPLICE_F_NONBLOCK = placeholder(); 742 /** 743 * Bitmask for flags argument of 744 * {@link splice(java.io.FileDescriptor, Int64Ref, FileDescriptor, Int64Ref, long, int)}. 745 * 746 * <p>Indicates that more data will be coming in a subsequent splice. This is 747 * a helpful hint when the {@code fdOut} refers to a socket. 748 * 749 * See <a href="https://man7.org/linux/man-pages/man2/splice.2.html">splice(2)</a>. 750 * 751 * @hide 752 */ 753 @UnsupportedAppUsage 754 @SystemApi(client = MODULE_LIBRARIES) 755 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 756 public static final int SPLICE_F_MORE = placeholder(); 757 public static final int STDERR_FILENO = placeholder(); 758 public static final int STDIN_FILENO = placeholder(); 759 public static final int STDOUT_FILENO = placeholder(); 760 public static final int ST_MANDLOCK = placeholder(); 761 public static final int ST_NOATIME = placeholder(); 762 public static final int ST_NODEV = placeholder(); 763 public static final int ST_NODIRATIME = placeholder(); 764 public static final int ST_NOEXEC = placeholder(); 765 public static final int ST_NOSUID = placeholder(); 766 public static final int ST_RDONLY = placeholder(); 767 public static final int ST_RELATIME = placeholder(); 768 public static final int ST_SYNCHRONOUS = placeholder(); 769 public static final int S_IFBLK = placeholder(); 770 public static final int S_IFCHR = placeholder(); 771 public static final int S_IFDIR = placeholder(); 772 public static final int S_IFIFO = placeholder(); 773 public static final int S_IFLNK = placeholder(); 774 public static final int S_IFMT = placeholder(); 775 public static final int S_IFREG = placeholder(); 776 public static final int S_IFSOCK = placeholder(); 777 public static final int S_IRGRP = placeholder(); 778 public static final int S_IROTH = placeholder(); 779 public static final int S_IRUSR = placeholder(); 780 public static final int S_IRWXG = placeholder(); 781 public static final int S_IRWXO = placeholder(); 782 public static final int S_IRWXU = placeholder(); 783 public static final int S_ISGID = placeholder(); 784 public static final int S_ISUID = placeholder(); 785 public static final int S_ISVTX = placeholder(); 786 public static final int S_IWGRP = placeholder(); 787 public static final int S_IWOTH = placeholder(); 788 public static final int S_IWUSR = placeholder(); 789 public static final int S_IXGRP = placeholder(); 790 public static final int S_IXOTH = placeholder(); 791 public static final int S_IXUSR = placeholder(); 792 public static final int TCP_NODELAY = placeholder(); 793 public static final int TCP_USER_TIMEOUT = placeholder(); 794 public static final int UDP_GRO = placeholder(); 795 public static final int UDP_SEGMENT = placeholder(); 796 /** 797 * Get the number of bytes in the output buffer. 798 * 799 * See <a href="https://man7.org/linux/man-pages/man2/ioctl.2.html">ioctl(2)</a>. 800 * 801 * @hide 802 */ 803 @UnsupportedAppUsage 804 @SystemApi(client = MODULE_LIBRARIES) 805 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 806 public static final int TIOCOUTQ = placeholder(); 807 /** 808 * Sockopt option to encapsulate ESP packets in UDP. 809 * 810 * @hide 811 */ 812 @UnsupportedAppUsage 813 @SystemApi(client = MODULE_LIBRARIES) 814 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 815 public static final int UDP_ENCAP = placeholder(); 816 /** @hide */ 817 @UnsupportedAppUsage 818 public static final int UDP_ENCAP_ESPINUDP_NON_IKE = placeholder(); 819 /** @hide */ 820 @UnsupportedAppUsage 821 @SystemApi(client = MODULE_LIBRARIES) 822 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 823 public static final int UDP_ENCAP_ESPINUDP = placeholder(); 824 /** @hide */ 825 @UnsupportedAppUsage 826 public static final int UNIX_PATH_MAX = placeholder(); 827 public static final int WCONTINUED = placeholder(); 828 public static final int WEXITED = placeholder(); 829 public static final int WNOHANG = placeholder(); 830 public static final int WNOWAIT = placeholder(); 831 public static final int WSTOPPED = placeholder(); 832 public static final int WUNTRACED = placeholder(); 833 public static final int W_OK = placeholder(); 834 /** 835 * {@code flags} option for {@link Os#setxattr(String, String, byte[], int)}. 836 * 837 * <p>Performs a pure create, which fails if the named attribute exists already. 838 * 839 * See <a href="http://man7.org/linux/man-pages/man2/setxattr.2.html">setxattr(2)</a>. 840 * 841 * @hide 842 */ 843 @UnsupportedAppUsage 844 @SystemApi(client = MODULE_LIBRARIES) 845 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 846 public static final int XATTR_CREATE = placeholder(); 847 /** 848 * {@code flags} option for {@link Os#setxattr(String, String, byte[], int)}. 849 * 850 * <p>Perform a pure replace operation, which fails if the named attribute 851 * does not already exist. 852 * 853 * See <a href="http://man7.org/linux/man-pages/man2/setxattr.2.html">setxattr(2)</a>. 854 * 855 * @hide 856 */ 857 @UnsupportedAppUsage 858 @SystemApi(client = MODULE_LIBRARIES) 859 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 860 public static final int XATTR_REPLACE = placeholder(); 861 public static final int X_OK = placeholder(); 862 public static final int _SC_2_CHAR_TERM = placeholder(); 863 public static final int _SC_2_C_BIND = placeholder(); 864 public static final int _SC_2_C_DEV = placeholder(); 865 public static final int _SC_2_C_VERSION = placeholder(); 866 public static final int _SC_2_FORT_DEV = placeholder(); 867 public static final int _SC_2_FORT_RUN = placeholder(); 868 public static final int _SC_2_LOCALEDEF = placeholder(); 869 public static final int _SC_2_SW_DEV = placeholder(); 870 public static final int _SC_2_UPE = placeholder(); 871 public static final int _SC_2_VERSION = placeholder(); 872 public static final int _SC_AIO_LISTIO_MAX = placeholder(); 873 public static final int _SC_AIO_MAX = placeholder(); 874 public static final int _SC_AIO_PRIO_DELTA_MAX = placeholder(); 875 public static final int _SC_ARG_MAX = placeholder(); 876 public static final int _SC_ASYNCHRONOUS_IO = placeholder(); 877 public static final int _SC_ATEXIT_MAX = placeholder(); 878 public static final int _SC_AVPHYS_PAGES = placeholder(); 879 public static final int _SC_BC_BASE_MAX = placeholder(); 880 public static final int _SC_BC_DIM_MAX = placeholder(); 881 public static final int _SC_BC_SCALE_MAX = placeholder(); 882 public static final int _SC_BC_STRING_MAX = placeholder(); 883 public static final int _SC_CHILD_MAX = placeholder(); 884 public static final int _SC_CLK_TCK = placeholder(); 885 public static final int _SC_COLL_WEIGHTS_MAX = placeholder(); 886 public static final int _SC_DELAYTIMER_MAX = placeholder(); 887 public static final int _SC_EXPR_NEST_MAX = placeholder(); 888 public static final int _SC_FSYNC = placeholder(); 889 public static final int _SC_GETGR_R_SIZE_MAX = placeholder(); 890 public static final int _SC_GETPW_R_SIZE_MAX = placeholder(); 891 public static final int _SC_IOV_MAX = placeholder(); 892 public static final int _SC_JOB_CONTROL = placeholder(); 893 public static final int _SC_LINE_MAX = placeholder(); 894 public static final int _SC_LOGIN_NAME_MAX = placeholder(); 895 public static final int _SC_MAPPED_FILES = placeholder(); 896 public static final int _SC_MEMLOCK = placeholder(); 897 public static final int _SC_MEMLOCK_RANGE = placeholder(); 898 public static final int _SC_MEMORY_PROTECTION = placeholder(); 899 public static final int _SC_MESSAGE_PASSING = placeholder(); 900 public static final int _SC_MQ_OPEN_MAX = placeholder(); 901 public static final int _SC_MQ_PRIO_MAX = placeholder(); 902 public static final int _SC_NGROUPS_MAX = placeholder(); 903 public static final int _SC_NPROCESSORS_CONF = placeholder(); 904 public static final int _SC_NPROCESSORS_ONLN = placeholder(); 905 public static final int _SC_OPEN_MAX = placeholder(); 906 public static final int _SC_PAGESIZE = placeholder(); 907 public static final int _SC_PAGE_SIZE = placeholder(); 908 public static final int _SC_PASS_MAX = placeholder(); 909 public static final int _SC_PHYS_PAGES = placeholder(); 910 public static final int _SC_PRIORITIZED_IO = placeholder(); 911 public static final int _SC_PRIORITY_SCHEDULING = placeholder(); 912 public static final int _SC_REALTIME_SIGNALS = placeholder(); 913 public static final int _SC_RE_DUP_MAX = placeholder(); 914 public static final int _SC_RTSIG_MAX = placeholder(); 915 public static final int _SC_SAVED_IDS = placeholder(); 916 public static final int _SC_SEMAPHORES = placeholder(); 917 public static final int _SC_SEM_NSEMS_MAX = placeholder(); 918 public static final int _SC_SEM_VALUE_MAX = placeholder(); 919 public static final int _SC_SHARED_MEMORY_OBJECTS = placeholder(); 920 public static final int _SC_SIGQUEUE_MAX = placeholder(); 921 public static final int _SC_STREAM_MAX = placeholder(); 922 public static final int _SC_SYNCHRONIZED_IO = placeholder(); 923 public static final int _SC_THREADS = placeholder(); 924 public static final int _SC_THREAD_ATTR_STACKADDR = placeholder(); 925 public static final int _SC_THREAD_ATTR_STACKSIZE = placeholder(); 926 public static final int _SC_THREAD_DESTRUCTOR_ITERATIONS = placeholder(); 927 public static final int _SC_THREAD_KEYS_MAX = placeholder(); 928 public static final int _SC_THREAD_PRIORITY_SCHEDULING = placeholder(); 929 public static final int _SC_THREAD_PRIO_INHERIT = placeholder(); 930 public static final int _SC_THREAD_PRIO_PROTECT = placeholder(); 931 public static final int _SC_THREAD_SAFE_FUNCTIONS = placeholder(); 932 public static final int _SC_THREAD_STACK_MIN = placeholder(); 933 public static final int _SC_THREAD_THREADS_MAX = placeholder(); 934 public static final int _SC_TIMERS = placeholder(); 935 public static final int _SC_TIMER_MAX = placeholder(); 936 public static final int _SC_TTY_NAME_MAX = placeholder(); 937 public static final int _SC_TZNAME_MAX = placeholder(); 938 public static final int _SC_VERSION = placeholder(); 939 public static final int _SC_XBS5_ILP32_OFF32 = placeholder(); 940 public static final int _SC_XBS5_ILP32_OFFBIG = placeholder(); 941 public static final int _SC_XBS5_LP64_OFF64 = placeholder(); 942 public static final int _SC_XBS5_LPBIG_OFFBIG = placeholder(); 943 public static final int _SC_XOPEN_CRYPT = placeholder(); 944 public static final int _SC_XOPEN_ENH_I18N = placeholder(); 945 public static final int _SC_XOPEN_LEGACY = placeholder(); 946 public static final int _SC_XOPEN_REALTIME = placeholder(); 947 public static final int _SC_XOPEN_REALTIME_THREADS = placeholder(); 948 public static final int _SC_XOPEN_SHM = placeholder(); 949 public static final int _SC_XOPEN_UNIX = placeholder(); 950 public static final int _SC_XOPEN_VERSION = placeholder(); 951 public static final int _SC_XOPEN_XCU_VERSION = placeholder(); 952 953 /** 954 * Returns the string name of a getaddrinfo(3) error value. 955 * For example, "EAI_AGAIN". 956 */ gaiName(int error)957 public static String gaiName(int error) { 958 if (error == EAI_AGAIN) { 959 return "EAI_AGAIN"; 960 } 961 if (error == EAI_BADFLAGS) { 962 return "EAI_BADFLAGS"; 963 } 964 if (error == EAI_FAIL) { 965 return "EAI_FAIL"; 966 } 967 if (error == EAI_FAMILY) { 968 return "EAI_FAMILY"; 969 } 970 if (error == EAI_MEMORY) { 971 return "EAI_MEMORY"; 972 } 973 if (error == EAI_NODATA) { 974 return "EAI_NODATA"; 975 } 976 if (error == EAI_NONAME) { 977 return "EAI_NONAME"; 978 } 979 if (error == EAI_OVERFLOW) { 980 return "EAI_OVERFLOW"; 981 } 982 if (error == EAI_SERVICE) { 983 return "EAI_SERVICE"; 984 } 985 if (error == EAI_SOCKTYPE) { 986 return "EAI_SOCKTYPE"; 987 } 988 if (error == EAI_SYSTEM) { 989 return "EAI_SYSTEM"; 990 } 991 return null; 992 } 993 994 /** 995 * Returns the string name of an errno value. 996 * For example, "EACCES". See {@link Os#strerror} for human-readable errno descriptions. 997 */ errnoName(int errno)998 public static String errnoName(int errno) { 999 if (errno == E2BIG) { 1000 return "E2BIG"; 1001 } 1002 if (errno == EACCES) { 1003 return "EACCES"; 1004 } 1005 if (errno == EADDRINUSE) { 1006 return "EADDRINUSE"; 1007 } 1008 if (errno == EADDRNOTAVAIL) { 1009 return "EADDRNOTAVAIL"; 1010 } 1011 if (errno == EAFNOSUPPORT) { 1012 return "EAFNOSUPPORT"; 1013 } 1014 if (errno == EAGAIN) { 1015 return "EAGAIN"; 1016 } 1017 if (errno == EALREADY) { 1018 return "EALREADY"; 1019 } 1020 if (errno == EBADF) { 1021 return "EBADF"; 1022 } 1023 if (errno == EBADMSG) { 1024 return "EBADMSG"; 1025 } 1026 if (errno == EBUSY) { 1027 return "EBUSY"; 1028 } 1029 if (errno == ECANCELED) { 1030 return "ECANCELED"; 1031 } 1032 if (errno == ECHILD) { 1033 return "ECHILD"; 1034 } 1035 if (errno == ECONNABORTED) { 1036 return "ECONNABORTED"; 1037 } 1038 if (errno == ECONNREFUSED) { 1039 return "ECONNREFUSED"; 1040 } 1041 if (errno == ECONNRESET) { 1042 return "ECONNRESET"; 1043 } 1044 if (errno == EDEADLK) { 1045 return "EDEADLK"; 1046 } 1047 if (errno == EDESTADDRREQ) { 1048 return "EDESTADDRREQ"; 1049 } 1050 if (errno == EDOM) { 1051 return "EDOM"; 1052 } 1053 if (errno == EDQUOT) { 1054 return "EDQUOT"; 1055 } 1056 if (errno == EEXIST) { 1057 return "EEXIST"; 1058 } 1059 if (errno == EFAULT) { 1060 return "EFAULT"; 1061 } 1062 if (errno == EFBIG) { 1063 return "EFBIG"; 1064 } 1065 if (errno == EHOSTUNREACH) { 1066 return "EHOSTUNREACH"; 1067 } 1068 if (errno == EIDRM) { 1069 return "EIDRM"; 1070 } 1071 if (errno == EILSEQ) { 1072 return "EILSEQ"; 1073 } 1074 if (errno == EINPROGRESS) { 1075 return "EINPROGRESS"; 1076 } 1077 if (errno == EINTR) { 1078 return "EINTR"; 1079 } 1080 if (errno == EINVAL) { 1081 return "EINVAL"; 1082 } 1083 if (errno == EIO) { 1084 return "EIO"; 1085 } 1086 if (errno == EISCONN) { 1087 return "EISCONN"; 1088 } 1089 if (errno == EISDIR) { 1090 return "EISDIR"; 1091 } 1092 if (errno == ELOOP) { 1093 return "ELOOP"; 1094 } 1095 if (errno == EMFILE) { 1096 return "EMFILE"; 1097 } 1098 if (errno == EMLINK) { 1099 return "EMLINK"; 1100 } 1101 if (errno == EMSGSIZE) { 1102 return "EMSGSIZE"; 1103 } 1104 if (errno == EMULTIHOP) { 1105 return "EMULTIHOP"; 1106 } 1107 if (errno == ENAMETOOLONG) { 1108 return "ENAMETOOLONG"; 1109 } 1110 if (errno == ENETDOWN) { 1111 return "ENETDOWN"; 1112 } 1113 if (errno == ENETRESET) { 1114 return "ENETRESET"; 1115 } 1116 if (errno == ENETUNREACH) { 1117 return "ENETUNREACH"; 1118 } 1119 if (errno == ENFILE) { 1120 return "ENFILE"; 1121 } 1122 if (errno == ENOBUFS) { 1123 return "ENOBUFS"; 1124 } 1125 if (errno == ENODATA) { 1126 return "ENODATA"; 1127 } 1128 if (errno == ENODEV) { 1129 return "ENODEV"; 1130 } 1131 if (errno == ENOENT) { 1132 return "ENOENT"; 1133 } 1134 if (errno == ENOEXEC) { 1135 return "ENOEXEC"; 1136 } 1137 if (errno == ENOLCK) { 1138 return "ENOLCK"; 1139 } 1140 if (errno == ENOLINK) { 1141 return "ENOLINK"; 1142 } 1143 if (errno == ENOMEM) { 1144 return "ENOMEM"; 1145 } 1146 if (errno == ENOMSG) { 1147 return "ENOMSG"; 1148 } 1149 if (errno == ENONET) { 1150 return "ENONET"; 1151 } 1152 if (errno == ENOPROTOOPT) { 1153 return "ENOPROTOOPT"; 1154 } 1155 if (errno == ENOSPC) { 1156 return "ENOSPC"; 1157 } 1158 if (errno == ENOSR) { 1159 return "ENOSR"; 1160 } 1161 if (errno == ENOSTR) { 1162 return "ENOSTR"; 1163 } 1164 if (errno == ENOSYS) { 1165 return "ENOSYS"; 1166 } 1167 if (errno == ENOTCONN) { 1168 return "ENOTCONN"; 1169 } 1170 if (errno == ENOTDIR) { 1171 return "ENOTDIR"; 1172 } 1173 if (errno == ENOTEMPTY) { 1174 return "ENOTEMPTY"; 1175 } 1176 if (errno == ENOTSOCK) { 1177 return "ENOTSOCK"; 1178 } 1179 if (errno == ENOTSUP) { 1180 return "ENOTSUP"; 1181 } 1182 if (errno == ENOTTY) { 1183 return "ENOTTY"; 1184 } 1185 if (errno == ENXIO) { 1186 return "ENXIO"; 1187 } 1188 if (errno == EOPNOTSUPP) { 1189 return "EOPNOTSUPP"; 1190 } 1191 if (errno == EOVERFLOW) { 1192 return "EOVERFLOW"; 1193 } 1194 if (errno == EPERM) { 1195 return "EPERM"; 1196 } 1197 if (errno == EPIPE) { 1198 return "EPIPE"; 1199 } 1200 if (errno == EPROTO) { 1201 return "EPROTO"; 1202 } 1203 if (errno == EPROTONOSUPPORT) { 1204 return "EPROTONOSUPPORT"; 1205 } 1206 if (errno == EPROTOTYPE) { 1207 return "EPROTOTYPE"; 1208 } 1209 if (errno == ERANGE) { 1210 return "ERANGE"; 1211 } 1212 if (errno == EROFS) { 1213 return "EROFS"; 1214 } 1215 if (errno == ESPIPE) { 1216 return "ESPIPE"; 1217 } 1218 if (errno == ESRCH) { 1219 return "ESRCH"; 1220 } 1221 if (errno == ESTALE) { 1222 return "ESTALE"; 1223 } 1224 if (errno == ETIME) { 1225 return "ETIME"; 1226 } 1227 if (errno == ETIMEDOUT) { 1228 return "ETIMEDOUT"; 1229 } 1230 if (errno == ETXTBSY) { 1231 return "ETXTBSY"; 1232 } 1233 if (errno == EXDEV) { 1234 return "EXDEV"; 1235 } 1236 return null; 1237 } 1238 1239 @UnsupportedAppUsage initConstants()1240 private static native void initConstants(); 1241 1242 // A hack to avoid these constants being inlined by javac... 1243 @UnsupportedAppUsage placeholder()1244 private static int placeholder() { return 0; } 1245 // ...because we want to initialize them at runtime. 1246 static { initConstants()1247 initConstants(); 1248 } 1249 } 1250