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 libcore.io; 18 19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 20 21 import android.system.ErrnoException; 22 import android.system.GaiException; 23 import android.system.Int32Ref; 24 import android.system.Int64Ref; 25 import android.system.StructAddrinfo; 26 import android.system.StructCapUserData; 27 import android.system.StructCapUserHeader; 28 import android.system.StructGroupReq; 29 import android.system.StructIfaddrs; 30 import android.system.StructLinger; 31 import android.system.StructMsghdr; 32 import android.system.StructPasswd; 33 import android.system.StructPollfd; 34 import android.system.StructRlimit; 35 import android.system.StructStat; 36 import android.system.StructStatVfs; 37 import android.system.StructTimeval; 38 import android.system.StructUcred; 39 import android.system.StructUtsname; 40 41 import android.annotation.SystemApi; 42 import android.compat.annotation.UnsupportedAppUsage; 43 import java.io.FileDescriptor; 44 import java.io.InterruptedIOException; 45 import java.net.InetAddress; 46 import java.net.InetSocketAddress; 47 import java.net.SocketAddress; 48 import java.net.SocketException; 49 import java.nio.ByteBuffer; 50 51 /** 52 * Linux-like operating system. The user of this interface has access to various methods 53 * that expose basic operating system functionality, like file and file descriptors operations 54 * (open, close, read, write), socket operations (connect, bind, send*, recv*), process 55 * operations (exec*, getpid), filesystem operations (mkdir, unlink, chmod, chown) and others. 56 * 57 * @see Linux 58 * 59 * @hide 60 */ 61 @SystemApi(client = MODULE_LIBRARIES) 62 public interface Os { 63 64 /** 65 * @hide 66 */ accept(FileDescriptor fd, SocketAddress peerAddress)67 public FileDescriptor accept(FileDescriptor fd, SocketAddress peerAddress) throws ErrnoException, SocketException; 68 69 /** 70 * @hide 71 */ access(String path, int mode)72 public boolean access(String path, int mode) throws ErrnoException; 73 74 /** 75 * @hide 76 */ android_getaddrinfo(String node, StructAddrinfo hints, int netId)77 public InetAddress[] android_getaddrinfo(String node, StructAddrinfo hints, int netId) throws GaiException; 78 79 /** 80 * @hide 81 */ bind(FileDescriptor fd, InetAddress address, int port)82 public void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException; 83 84 /** 85 * @hide 86 */ bind(FileDescriptor fd, SocketAddress address)87 public void bind(FileDescriptor fd, SocketAddress address) throws ErrnoException, SocketException; 88 89 /** 90 * @hide 91 */ capget(StructCapUserHeader hdr)92 public StructCapUserData[] capget(StructCapUserHeader hdr) throws ErrnoException; 93 94 /** 95 * @hide 96 */ capset(StructCapUserHeader hdr, StructCapUserData[] data)97 public void capset(StructCapUserHeader hdr, StructCapUserData[] data) throws ErrnoException; 98 99 /** 100 * @hide 101 */ 102 @UnsupportedAppUsage chmod(String path, int mode)103 public void chmod(String path, int mode) throws ErrnoException; 104 105 /** 106 * @hide 107 */ chown(String path, int uid, int gid)108 public void chown(String path, int uid, int gid) throws ErrnoException; 109 110 /** 111 * @hide 112 */ 113 @UnsupportedAppUsage close(FileDescriptor fd)114 public void close(FileDescriptor fd) throws ErrnoException; 115 116 /** 117 * @hide 118 */ android_fdsan_exchange_owner_tag(FileDescriptor fd, long previousOwnerId, long newOwnerId)119 public void android_fdsan_exchange_owner_tag(FileDescriptor fd, long previousOwnerId, long newOwnerId); 120 121 /** 122 * @hide 123 */ android_fdsan_get_owner_tag(FileDescriptor fd)124 public long android_fdsan_get_owner_tag(FileDescriptor fd); 125 126 /** 127 * @hide 128 */ android_fdsan_get_tag_type(long tag)129 public String android_fdsan_get_tag_type(long tag); 130 131 /** 132 * @hide 133 */ android_fdsan_get_tag_value(long tag)134 public long android_fdsan_get_tag_value(long tag); 135 136 137 /** 138 * @hide 139 */ 140 @UnsupportedAppUsage connect(FileDescriptor fd, InetAddress address, int port)141 public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException; 142 143 /** 144 * @hide 145 */ connect(FileDescriptor fd, SocketAddress address)146 public void connect(FileDescriptor fd, SocketAddress address) throws ErrnoException, SocketException; 147 148 /** 149 * @hide 150 */ dup(FileDescriptor oldFd)151 public FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException; 152 153 /** 154 * @hide 155 */ dup2(FileDescriptor oldFd, int newFd)156 public FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException; 157 158 /** 159 * @hide 160 */ environ()161 public String[] environ(); 162 163 /** 164 * @hide 165 */ execv(String filename, String[] argv)166 public void execv(String filename, String[] argv) throws ErrnoException; 167 168 /** 169 * @hide 170 */ execve(String filename, String[] argv, String[] envp)171 public void execve(String filename, String[] argv, String[] envp) throws ErrnoException; 172 173 /** 174 * @hide 175 */ fchmod(FileDescriptor fd, int mode)176 public void fchmod(FileDescriptor fd, int mode) throws ErrnoException; 177 178 /** 179 * @hide 180 */ fchown(FileDescriptor fd, int uid, int gid)181 public void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException; 182 183 /** 184 * @hide 185 */ fcntlInt(FileDescriptor fd, int cmd, int arg)186 public int fcntlInt(FileDescriptor fd, int cmd, int arg) throws ErrnoException; 187 188 /** 189 * @hide 190 */ fcntlVoid(FileDescriptor fd, int cmd)191 public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException; 192 193 /** 194 * @hide 195 */ fdatasync(FileDescriptor fd)196 public void fdatasync(FileDescriptor fd) throws ErrnoException; 197 198 /** 199 * @hide 200 */ fstat(FileDescriptor fd)201 public StructStat fstat(FileDescriptor fd) throws ErrnoException; 202 203 /** 204 * @hide 205 */ fstatvfs(FileDescriptor fd)206 public StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException; 207 208 /** 209 * @hide 210 */ fsync(FileDescriptor fd)211 public void fsync(FileDescriptor fd) throws ErrnoException; 212 213 /** 214 * @hide 215 */ ftruncate(FileDescriptor fd, long length)216 public void ftruncate(FileDescriptor fd, long length) throws ErrnoException; 217 218 /** 219 * @hide 220 */ 221 @UnsupportedAppUsage gai_strerror(int error)222 public String gai_strerror(int error); 223 224 /** 225 * @hide 226 */ getegid()227 public int getegid(); 228 229 /** 230 * @hide 231 */ geteuid()232 public int geteuid(); 233 234 /** 235 * @hide 236 */ getgid()237 public int getgid(); 238 239 /** 240 * @hide 241 */ getenv(String name)242 public String getenv(String name); 243 244 /* TODO: break into getnameinfoHost and getnameinfoService? */ 245 /** 246 * @hide 247 */ getnameinfo(InetAddress address, int flags)248 public String getnameinfo(InetAddress address, int flags) throws GaiException; 249 250 /** 251 * @hide 252 */ getpeername(FileDescriptor fd)253 public SocketAddress getpeername(FileDescriptor fd) throws ErrnoException; 254 255 /** 256 * @hide 257 */ getpgid(int pid)258 public int getpgid(int pid) throws ErrnoException; 259 260 /** 261 * @hide 262 */ getpid()263 public int getpid(); 264 265 /** 266 * @hide 267 */ getppid()268 public int getppid(); 269 270 /** 271 * @hide 272 */ getpwnam(String name)273 public StructPasswd getpwnam(String name) throws ErrnoException; 274 275 /** 276 * @hide 277 */ getpwuid(int uid)278 public StructPasswd getpwuid(int uid) throws ErrnoException; 279 280 /** 281 * @hide 282 */ getrlimit(int resource)283 public StructRlimit getrlimit(int resource) throws ErrnoException; 284 285 /** 286 * @hide 287 */ getsockname(FileDescriptor fd)288 public SocketAddress getsockname(FileDescriptor fd) throws ErrnoException; 289 290 /** 291 * @hide 292 */ getsockoptByte(FileDescriptor fd, int level, int option)293 public int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException; 294 295 /** 296 * @hide 297 */ getsockoptInAddr(FileDescriptor fd, int level, int option)298 public InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException; 299 300 /** 301 * @hide 302 */ getsockoptInt(FileDescriptor fd, int level, int option)303 public int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException; 304 305 /** 306 * @hide 307 */ getsockoptLinger(FileDescriptor fd, int level, int option)308 public StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException; 309 310 /** 311 * @hide 312 */ getsockoptTimeval(FileDescriptor fd, int level, int option)313 public StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException; 314 315 /** 316 * @hide 317 */ getsockoptUcred(FileDescriptor fd, int level, int option)318 public StructUcred getsockoptUcred(FileDescriptor fd, int level, int option) throws ErrnoException; 319 320 /** 321 * @hide 322 */ gettid()323 public int gettid(); 324 325 /** 326 * @hide 327 */ getuid()328 public int getuid(); 329 330 /** 331 * @hide 332 */ getxattr(String path, String name)333 public byte[] getxattr(String path, String name) throws ErrnoException; 334 335 /** 336 * @hide 337 */ getifaddrs()338 public StructIfaddrs[] getifaddrs() throws ErrnoException; 339 340 /** 341 * @hide 342 */ if_indextoname(int index)343 public String if_indextoname(int index); 344 345 /** 346 * @hide 347 */ if_nametoindex(String name)348 public int if_nametoindex(String name); 349 350 /** 351 * @hide 352 */ inet_pton(int family, String address)353 public InetAddress inet_pton(int family, String address); 354 355 /** 356 * @hide 357 */ ioctlFlags(FileDescriptor fd, String interfaceName)358 public int ioctlFlags(FileDescriptor fd, String interfaceName) throws ErrnoException; 359 360 /** 361 * @hide 362 */ ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName)363 public InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException; 364 365 /** 366 * @hide 367 */ ioctlInt(FileDescriptor fd, int cmd)368 public int ioctlInt(FileDescriptor fd, int cmd) throws ErrnoException; 369 370 /** 371 * @hide 372 */ ioctlMTU(FileDescriptor fd, String interfaceName)373 public int ioctlMTU(FileDescriptor fd, String interfaceName) throws ErrnoException; 374 375 /** 376 * @hide 377 */ isatty(FileDescriptor fd)378 public boolean isatty(FileDescriptor fd); 379 380 /** 381 * @hide 382 */ kill(int pid, int signal)383 public void kill(int pid, int signal) throws ErrnoException; 384 385 /** 386 * @hide 387 */ lchown(String path, int uid, int gid)388 public void lchown(String path, int uid, int gid) throws ErrnoException; 389 390 /** 391 * @hide 392 */ link(String oldPath, String newPath)393 public void link(String oldPath, String newPath) throws ErrnoException; 394 395 /** 396 * @hide 397 */ listen(FileDescriptor fd, int backlog)398 public void listen(FileDescriptor fd, int backlog) throws ErrnoException; 399 400 /** 401 * @hide 402 */ listxattr(String path)403 public String[] listxattr(String path) throws ErrnoException; 404 405 /** 406 * @hide 407 */ lseek(FileDescriptor fd, long offset, int whence)408 public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException; 409 410 /** 411 * @hide 412 */ lstat(String path)413 public StructStat lstat(String path) throws ErrnoException; 414 415 /** 416 * @hide 417 */ memfd_create(String name, int flags)418 public FileDescriptor memfd_create(String name, int flags) throws ErrnoException; 419 420 /** 421 * @hide 422 */ mincore(long address, long byteCount, byte[] vector)423 public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException; 424 425 /** 426 * @hide 427 */ mkdir(String path, int mode)428 public void mkdir(String path, int mode) throws ErrnoException; 429 430 /** 431 * @hide 432 */ mkfifo(String path, int mode)433 public void mkfifo(String path, int mode) throws ErrnoException; 434 435 /** 436 * @hide 437 */ mlock(long address, long byteCount)438 public void mlock(long address, long byteCount) throws ErrnoException; 439 440 /** 441 * @hide 442 */ 443 @UnsupportedAppUsage mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset)444 public long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException; 445 446 /** 447 * @hide 448 */ msync(long address, long byteCount, int flags)449 public void msync(long address, long byteCount, int flags) throws ErrnoException; 450 451 /** 452 * @hide 453 */ munlock(long address, long byteCount)454 public void munlock(long address, long byteCount) throws ErrnoException; 455 456 /** 457 * @hide 458 */ 459 @UnsupportedAppUsage munmap(long address, long byteCount)460 public void munmap(long address, long byteCount) throws ErrnoException; 461 462 /** 463 * @hide 464 */ 465 @UnsupportedAppUsage open(String path, int flags, int mode)466 public FileDescriptor open(String path, int flags, int mode) throws ErrnoException; 467 468 /** 469 * @hide 470 */ pipe2(int flags)471 public FileDescriptor[] pipe2(int flags) throws ErrnoException; 472 473 /* TODO: if we used the non-standard ppoll(2) behind the scenes, we could take a long timeout. */ 474 /** 475 * @hide 476 */ poll(StructPollfd[] fds, int timeoutMs)477 public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException; 478 479 /** 480 * @hide 481 */ posix_fallocate(FileDescriptor fd, long offset, long length)482 public void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException; 483 484 /** 485 * @hide 486 */ prctl(int option, long arg2, long arg3, long arg4, long arg5)487 public int prctl(int option, long arg2, long arg3, long arg4, long arg5) throws ErrnoException; 488 489 /** 490 * @hide 491 */ pread(FileDescriptor fd, ByteBuffer buffer, long offset)492 public int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException; 493 494 /** 495 * @hide 496 */ pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset)497 public int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException; 498 499 /** 500 * @hide 501 */ pwrite(FileDescriptor fd, ByteBuffer buffer, long offset)502 public int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException; 503 504 /** 505 * @hide 506 */ pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset)507 public int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException; 508 509 /** 510 * @hide 511 */ read(FileDescriptor fd, ByteBuffer buffer)512 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException; 513 514 /** 515 * @hide 516 */ 517 @UnsupportedAppUsage read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount)518 public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException; 519 520 /** 521 * @hide 522 */ readlink(String path)523 public String readlink(String path) throws ErrnoException; 524 525 /** 526 * @hide 527 */ realpath(String path)528 public String realpath(String path) throws ErrnoException; 529 530 /** 531 * @hide 532 */ readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts)533 public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException; 534 535 /** 536 * @hide 537 */ recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress)538 public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException; 539 540 /** 541 * @hide 542 */ recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress)543 public int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException; 544 545 /** 546 * @hide 547 */ recvmsg(FileDescriptor fd, StructMsghdr msg, int flags)548 public int recvmsg(FileDescriptor fd, StructMsghdr msg, int flags) throws ErrnoException, SocketException; 549 550 /** 551 * @hide 552 */ 553 @UnsupportedAppUsage remove(String path)554 public void remove(String path) throws ErrnoException; 555 556 /** 557 * @hide 558 */ removexattr(String path, String name)559 public void removexattr(String path, String name) throws ErrnoException; 560 561 /** 562 * @hide 563 */ rename(String oldPath, String newPath)564 public void rename(String oldPath, String newPath) throws ErrnoException; 565 566 /** 567 * @hide 568 */ sendmsg(FileDescriptor fd, StructMsghdr msg, int flags)569 public int sendmsg(FileDescriptor fd, StructMsghdr msg, int flags) throws ErrnoException, SocketException; 570 571 /** 572 * @hide 573 */ sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port)574 public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException; 575 576 /** 577 * @hide 578 */ sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port)579 public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException; 580 581 /** 582 * @hide 583 */ sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, SocketAddress address)584 public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, SocketAddress address) throws ErrnoException, SocketException; 585 586 /** 587 * @hide 588 */ sendfile(FileDescriptor outFd, FileDescriptor inFd, Int64Ref offset, long byteCount)589 public long sendfile(FileDescriptor outFd, FileDescriptor inFd, Int64Ref offset, long byteCount) throws ErrnoException; 590 591 /** 592 * @hide 593 */ setegid(int egid)594 public void setegid(int egid) throws ErrnoException; 595 596 /** 597 * @hide 598 */ 599 @UnsupportedAppUsage setenv(String name, String value, boolean overwrite)600 public void setenv(String name, String value, boolean overwrite) throws ErrnoException; 601 602 /** 603 * @hide 604 */ seteuid(int euid)605 public void seteuid(int euid) throws ErrnoException; 606 607 /** 608 * @hide 609 */ setgid(int gid)610 public void setgid(int gid) throws ErrnoException; 611 612 /** 613 * @hide 614 */ setpgid(int pid, int pgid)615 public void setpgid(int pid, int pgid) throws ErrnoException; 616 617 /** 618 * @hide 619 */ setregid(int rgid, int egid)620 public void setregid(int rgid, int egid) throws ErrnoException; 621 622 /** 623 * @hide 624 */ setreuid(int ruid, int euid)625 public void setreuid(int ruid, int euid) throws ErrnoException; 626 627 /** 628 * @hide 629 */ setsid()630 public int setsid() throws ErrnoException; 631 632 /** 633 * @hide 634 */ setsockoptByte(FileDescriptor fd, int level, int option, int value)635 public void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException; 636 637 /** 638 * @hide 639 */ setsockoptIfreq(FileDescriptor fd, int level, int option, String value)640 public void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException; 641 642 /** 643 * @hide 644 */ setsockoptInt(FileDescriptor fd, int level, int option, int value)645 public void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException; 646 647 /** 648 * @hide 649 */ setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value)650 public void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException; 651 652 /** 653 * @hide 654 */ setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value)655 public void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException; 656 657 /** 658 * @hide 659 */ setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value)660 public void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException; 661 662 /** 663 * @hide 664 */ 665 @UnsupportedAppUsage setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value)666 public void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException; 667 668 /** 669 * @hide 670 */ setuid(int uid)671 public void setuid(int uid) throws ErrnoException; 672 673 /** 674 * @hide 675 */ setxattr(String path, String name, byte[] value, int flags)676 public void setxattr(String path, String name, byte[] value, int flags) throws ErrnoException; 677 678 /** 679 * @hide 680 */ shutdown(FileDescriptor fd, int how)681 public void shutdown(FileDescriptor fd, int how) throws ErrnoException; 682 683 /** 684 * @hide 685 */ socket(int domain, int type, int protocol)686 public FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException; 687 688 /** 689 * @hide 690 */ socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2)691 public void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException; 692 693 /** 694 * @hide 695 */ splice(FileDescriptor fdIn, Int64Ref offIn, FileDescriptor fdOut, Int64Ref offOut, long len, int flags)696 public long splice(FileDescriptor fdIn, Int64Ref offIn, FileDescriptor fdOut, Int64Ref offOut, long len, int flags) throws ErrnoException; 697 698 /** 699 * @hide 700 */ 701 @UnsupportedAppUsage stat(String path)702 public StructStat stat(String path) throws ErrnoException; 703 704 /** 705 * @hide 706 */ statvfs(String path)707 public StructStatVfs statvfs(String path) throws ErrnoException; 708 709 /** 710 * @hide 711 */ 712 @UnsupportedAppUsage strerror(int errno)713 public String strerror(int errno); 714 715 /** 716 * @hide 717 */ strsignal(int signal)718 public String strsignal(int signal); 719 720 /** 721 * @hide 722 */ symlink(String oldPath, String newPath)723 public void symlink(String oldPath, String newPath) throws ErrnoException; 724 725 /** 726 * @hide 727 */ 728 @UnsupportedAppUsage sysconf(int name)729 public long sysconf(int name); 730 731 /** 732 * @hide 733 */ tcdrain(FileDescriptor fd)734 public void tcdrain(FileDescriptor fd) throws ErrnoException; 735 736 /** 737 * @hide 738 */ tcsendbreak(FileDescriptor fd, int duration)739 public void tcsendbreak(FileDescriptor fd, int duration) throws ErrnoException; 740 741 /** 742 * @hide 743 */ umask(int mask)744 public int umask(int mask); 745 746 /** 747 * @hide 748 */ uname()749 public StructUtsname uname(); 750 751 /** 752 * @hide 753 */ unlink(String pathname)754 public void unlink(String pathname) throws ErrnoException; 755 756 /** 757 * @hide 758 */ unsetenv(String name)759 public void unsetenv(String name) throws ErrnoException; 760 761 /** 762 * @hide 763 */ waitpid(int pid, Int32Ref status, int options)764 public int waitpid(int pid, Int32Ref status, int options) throws ErrnoException; 765 766 /** 767 * @hide 768 */ write(FileDescriptor fd, ByteBuffer buffer)769 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException; 770 771 /** 772 * @hide 773 */ write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount)774 public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException; 775 776 /** 777 * @hide 778 */ writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts)779 public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException; 780 781 /** 782 * Atomically sets the system's default {@link Os} implementation to be 783 * {@code update} if the current value {@code == expect}. 784 * 785 * @param expect the expected value. 786 * @param update the new value to set; must not be null. 787 * @return whether the update was successful. 788 * 789 * @hide 790 */ 791 @SystemApi(client = MODULE_LIBRARIES) compareAndSetDefault(Os expect, Os update)792 public static boolean compareAndSetDefault(Os expect, Os update) { 793 return Libcore.compareAndSetOs(expect, update); 794 } 795 796 /** 797 * @return the system's default {@link Os} implementation currently in use. 798 * 799 * @hide 800 */ 801 @SystemApi(client = MODULE_LIBRARIES) getDefault()802 public static Os getDefault() { 803 return Libcore.getOs(); 804 } 805 } 806