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