2009-03-04 04:28:35 +01:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
|
* distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
2014-08-19 20:16:41 +02:00
|
|
|
|
|
2018-08-28 21:17:20 +02:00
|
|
|
|
#pragma once
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/select.h>
|
|
|
|
|
|
2016-04-07 23:16:30 +02:00
|
|
|
|
#include <bits/fcntl.h>
|
Make getentropy available from <unistd.h>
getentropy is originally an OpenBSD-ism, where it was in <unistd.h> from
day one:
https://man.openbsd.org/OpenBSD-5.6/getentropy
FreeBSD's and Linux's current man pages also document it this way:
https://man7.org/linux/man-pages/man3/getentropy.3.html
https://man.freebsd.org/cgi/man.cgi?query=getentropy&sektion=3&format=html
The man7.org URL is even cited by bionic itself in the comments, though
glibc originally put it in <sys/random.h> and added to <unistd.h> very
shortly afterwards:
https://sourceware.org/bugzilla/show_bug.cgi?id=17252#c9
The cited man page (maintained separately from glibc) originally
documented <sys/random.h>...
https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man3/getentropy.3?id=b0265728162cdcafb8e7d7f1372e8de1a4c963ed
But similarly fixed it to <unistd.h> three months later:
https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man3/getentropy.3?id=9cf011f94b56e8832c5a5d8cf66d4a115d34b9cc
musl matches the BSDs in putting it in <unistd.h>, but not
<sys/random.h>.
https://git.musl-libc.org/cgit/musl/tree/include/unistd.h?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc#n183
POSIX will likely place it there too:
https://www.austingroupbugs.net/view.php?id=1134
macOS and Fuchsia place it in <sys/random.h> and not <unistd.h>, though
given the rest of this precedent, they're clearly outliers. (Note iOS
does *not* have getentropy, just macOS. The system has it, but it's not
exposed as public API. See https://dev.gnupg.org/T5375 and
https://github.com/openssl/openssl/pull/15924.)
Use the more standard location in bionic and put getentropy in
<unistd.h>. This will improve portability and avoid needing workarounds
in BoringSSL. For compatibility, keep it also available in
<sys/random.h> by using a <bits/getentropy.h> header.
BYPASS_INCLUSIVE_LANGUAGE_REASON=Above URLs are not hosted by Android and reference the name of a command-line utility, short for 'manual', as in instruction manual
Bug: 290898063
Test: treehugger
Change-Id: Id2d6b6ea09d814e5ba2cb117a7af2c74861148fb
2023-07-16 01:24:32 +02:00
|
|
|
|
#include <bits/getentropy.h>
|
2016-04-08 01:37:49 +02:00
|
|
|
|
#include <bits/getopt.h>
|
2016-04-07 23:19:03 +02:00
|
|
|
|
#include <bits/ioctl.h>
|
2016-01-26 03:06:24 +01:00
|
|
|
|
#include <bits/lockf.h>
|
|
|
|
|
#include <bits/posix_limits.h>
|
2016-08-12 19:16:34 +02:00
|
|
|
|
#include <bits/seek_constants.h>
|
2016-04-08 01:33:30 +02:00
|
|
|
|
#include <bits/sysconf.h>
|
2015-02-02 23:02:09 +01:00
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
|
|
2015-02-02 23:02:09 +01:00
|
|
|
|
#define F_OK 0
|
|
|
|
|
#define X_OK 1
|
|
|
|
|
#define W_OK 2
|
|
|
|
|
#define R_OK 4
|
|
|
|
|
|
2014-09-22 23:49:07 +02:00
|
|
|
|
#define _PC_FILESIZEBITS 0
|
|
|
|
|
#define _PC_LINK_MAX 1
|
|
|
|
|
#define _PC_MAX_CANON 2
|
|
|
|
|
#define _PC_MAX_INPUT 3
|
|
|
|
|
#define _PC_NAME_MAX 4
|
|
|
|
|
#define _PC_PATH_MAX 5
|
|
|
|
|
#define _PC_PIPE_BUF 6
|
|
|
|
|
#define _PC_2_SYMLINKS 7
|
|
|
|
|
#define _PC_ALLOC_SIZE_MIN 8
|
|
|
|
|
#define _PC_REC_INCR_XFER_SIZE 9
|
|
|
|
|
#define _PC_REC_MAX_XFER_SIZE 10
|
|
|
|
|
#define _PC_REC_MIN_XFER_SIZE 11
|
|
|
|
|
#define _PC_REC_XFER_ALIGN 12
|
|
|
|
|
#define _PC_SYMLINK_MAX 13
|
|
|
|
|
#define _PC_CHOWN_RESTRICTED 14
|
|
|
|
|
#define _PC_NO_TRUNC 15
|
|
|
|
|
#define _PC_VDISABLE 16
|
|
|
|
|
#define _PC_ASYNC_IO 17
|
|
|
|
|
#define _PC_PRIO_IO 18
|
|
|
|
|
#define _PC_SYNC_IO 19
|
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
extern char* _Nullable * _Nullable environ;
|
2014-04-23 02:41:00 +02:00
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
|
__noreturn void _exit(int __status);
|
|
|
|
|
|
2024-02-25 00:55:58 +01:00
|
|
|
|
/**
|
|
|
|
|
* [fork(2)](http://man7.org/linux/man-pages/man2/fork.2.html) creates a new
|
|
|
|
|
* process. fork() runs any handlers set by pthread_atfork().
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 in the child, the pid of the child in the parent,
|
|
|
|
|
* and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
pid_t fork(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* _Fork() creates a new process. _Fork() differs from fork() in that it does
|
2024-03-04 23:24:01 +01:00
|
|
|
|
* not run any handlers set by pthread_atfork(). In addition to any user-defined
|
|
|
|
|
* ones, bionic uses pthread_atfork() handlers to ensure consistency of its own
|
|
|
|
|
* state, so the child should only call
|
|
|
|
|
* [POSIX async-safe](https://man7.org/linux/man-pages/man7/signal-safety.7.html)
|
|
|
|
|
* functions.
|
2024-02-25 00:55:58 +01:00
|
|
|
|
*
|
|
|
|
|
* Returns 0 in the child, the pid of the child in the parent,
|
|
|
|
|
* and returns -1 and sets `errno` on failure.
|
|
|
|
|
*
|
|
|
|
|
* Available since API level 35.
|
|
|
|
|
*/
|
|
|
|
|
pid_t _Fork(void) __INTRODUCED_IN(35);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [vfork(2)](http://man7.org/linux/man-pages/man2/vfork.2.html) creates a new
|
|
|
|
|
* process. vfork() differs from fork() in that it does not run any handlers
|
|
|
|
|
* set by pthread_atfork(), and the parent is suspended until the child calls
|
|
|
|
|
* exec() or exits.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 in the child, the pid of the child in the parent,
|
|
|
|
|
* and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
pid_t vfork(void) __returns_twice;
|
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
|
pid_t getpid(void);
|
2016-09-28 21:29:52 +02:00
|
|
|
|
pid_t gettid(void) __attribute_const__;
|
2016-07-23 03:57:12 +02:00
|
|
|
|
pid_t getpgid(pid_t __pid);
|
|
|
|
|
int setpgid(pid_t __pid, pid_t __pgid);
|
|
|
|
|
pid_t getppid(void);
|
|
|
|
|
pid_t getpgrp(void);
|
|
|
|
|
int setpgrp(void);
|
2023-06-16 21:39:33 +02:00
|
|
|
|
pid_t getsid(pid_t __pid);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
pid_t setsid(void);
|
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int execv(const char* _Nonnull __path, char* _Nullable const* _Nullable __argv);
|
|
|
|
|
int execvp(const char* _Nonnull __file, char* _Nullable const* _Nullable __argv);
|
2023-06-16 21:39:33 +02:00
|
|
|
|
int execvpe(const char* _Nonnull __file, char* _Nullable const* _Nullable __argv, char* _Nullable const* _Nullable __envp);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int execve(const char* _Nonnull __file, char* _Nullable const* _Nullable __argv, char* _Nullable const* _Nullable __envp);
|
|
|
|
|
int execl(const char* _Nonnull __path, const char* _Nullable __arg0, ...) __attribute__((__sentinel__));
|
|
|
|
|
int execlp(const char* _Nonnull __file, const char* _Nullable __arg0, ...) __attribute__((__sentinel__));
|
|
|
|
|
int execle(const char* _Nonnull __path, const char* _Nullable __arg0, ... /*, char* const* __envp */)
|
2016-08-11 00:18:29 +02:00
|
|
|
|
__attribute__((__sentinel__(1)));
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int fexecve(int __fd, char* _Nullable const* _Nullable __argv, char* _Nullable const* _Nullable __envp) __INTRODUCED_IN(28);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
|
|
|
|
|
int nice(int __incr);
|
|
|
|
|
|
2018-08-28 21:17:20 +02:00
|
|
|
|
/**
|
|
|
|
|
* [setegid(2)](http://man7.org/linux/man-pages/man2/setegid.2.html) sets
|
|
|
|
|
* the effective group ID.
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int setegid(gid_t __gid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [seteuid(2)](http://man7.org/linux/man-pages/man2/seteuid.2.html) sets
|
|
|
|
|
* the effective user ID.
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int seteuid(uid_t __uid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setgid(2)](http://man7.org/linux/man-pages/man2/setgid.2.html) sets
|
|
|
|
|
* the group ID.
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int setgid(gid_t __gid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setregid(2)](http://man7.org/linux/man-pages/man2/setregid.2.html) sets
|
|
|
|
|
* the real and effective group IDs (use -1 to leave an ID unchanged).
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int setregid(gid_t __rgid, gid_t __egid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setresgid(2)](http://man7.org/linux/man-pages/man2/setresgid.2.html) sets
|
|
|
|
|
* the real, effective, and saved group IDs (use -1 to leave an ID unchanged).
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int setresgid(gid_t __rgid, gid_t __egid, gid_t __sgid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setresuid(2)](http://man7.org/linux/man-pages/man2/setresuid.2.html) sets
|
|
|
|
|
* the real, effective, and saved user IDs (use -1 to leave an ID unchanged).
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int setresuid(uid_t __ruid, uid_t __euid, uid_t __suid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setreuid(2)](http://man7.org/linux/man-pages/man2/setreuid.2.html) sets
|
|
|
|
|
* the real and effective group IDs (use -1 to leave an ID unchanged).
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int setreuid(uid_t __ruid, uid_t __euid);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setuid(2)](http://man7.org/linux/man-pages/man2/setuid.2.html) sets
|
|
|
|
|
* the user ID.
|
|
|
|
|
*
|
|
|
|
|
* On Android, this function only affects the calling thread, not all threads
|
|
|
|
|
* in the process.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int setuid(uid_t __uid);
|
2018-08-28 21:17:20 +02:00
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
|
uid_t getuid(void);
|
|
|
|
|
uid_t geteuid(void);
|
|
|
|
|
gid_t getgid(void);
|
|
|
|
|
gid_t getegid(void);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int getgroups(int __size, gid_t* _Nullable __list);
|
|
|
|
|
int setgroups(size_t __size, const gid_t* _Nullable __list);
|
|
|
|
|
int getresuid(uid_t* _Nonnull __ruid, uid_t* _Nonnull __euid, uid_t* _Nonnull __suid);
|
|
|
|
|
int getresgid(gid_t* _Nonnull __rgid, gid_t* _Nonnull __egid, gid_t* _Nonnull __sgid);
|
|
|
|
|
char* _Nullable getlogin(void);
|
|
|
|
|
int getlogin_r(char* _Nonnull __buffer, size_t __buffer_size) __INTRODUCED_IN(28);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
|
|
|
|
|
long fpathconf(int __fd, int __name);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
long pathconf(const char* _Nonnull __path, int __name);
|
|
|
|
|
|
|
|
|
|
int access(const char* _Nonnull __path, int __mode);
|
|
|
|
|
int faccessat(int __dirfd, const char* _Nonnull __path, int __mode, int __flags);
|
|
|
|
|
int link(const char* _Nonnull __old_path, const char* _Nonnull __new_path);
|
2023-06-16 21:39:33 +02:00
|
|
|
|
int linkat(int __old_dir_fd, const char* _Nonnull __old_path, int __new_dir_fd, const char* _Nonnull __new_path, int __flags);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int unlink(const char* _Nonnull __path);
|
|
|
|
|
int unlinkat(int __dirfd, const char* _Nonnull __path, int __flags);
|
|
|
|
|
int chdir(const char* _Nonnull __path);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int fchdir(int __fd);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int rmdir(const char* _Nonnull __path);
|
|
|
|
|
int pipe(int __fds[_Nonnull 2]);
|
2014-08-19 01:04:03 +02:00
|
|
|
|
#if defined(__USE_GNU)
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int pipe2(int __fds[_Nonnull 2], int __flags);
|
2010-09-27 17:33:08 +02:00
|
|
|
|
#endif
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int chroot(const char* _Nonnull __path);
|
|
|
|
|
int symlink(const char* _Nonnull __old_path, const char* _Nonnull __new_path);
|
2023-06-16 21:39:33 +02:00
|
|
|
|
int symlinkat(const char* _Nonnull __old_path, int __new_dir_fd, const char* _Nonnull __new_path);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
ssize_t readlink(const char* _Nonnull __path, char* _Nonnull __buf, size_t __buf_size);
|
2023-06-16 21:39:33 +02:00
|
|
|
|
ssize_t readlinkat(int __dir_fd, const char* _Nonnull __path, char* _Nonnull __buf, size_t __buf_size);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int chown(const char* _Nonnull __path, uid_t __owner, gid_t __group);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int fchown(int __fd, uid_t __owner, gid_t __group);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int fchownat(int __dir_fd, const char* _Nonnull __path, uid_t __owner, gid_t __group, int __flags);
|
|
|
|
|
int lchown(const char* _Nonnull __path, uid_t __owner, gid_t __group);
|
|
|
|
|
char* _Nullable getcwd(char* _Nullable __buf, size_t __size);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
|
2016-11-30 00:16:08 +01:00
|
|
|
|
void sync(void);
|
2017-08-25 01:31:49 +02:00
|
|
|
|
#if defined(__USE_GNU)
|
2018-01-30 17:54:12 +01:00
|
|
|
|
int syncfs(int __fd) __INTRODUCED_IN(28);
|
2017-08-25 01:31:49 +02:00
|
|
|
|
#endif
|
2016-07-23 03:57:12 +02:00
|
|
|
|
|
|
|
|
|
int close(int __fd);
|
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
/**
|
|
|
|
|
* [read(2)](https://man7.org/linux/man-pages/man2/read.2.html) reads
|
|
|
|
|
* up to `__count` bytes from file descriptor `__fd` into `__buf`.
|
|
|
|
|
*
|
|
|
|
|
* Note: `__buf` is not normally nullable, but may be null in the
|
|
|
|
|
* special case of a zero-length read(), which while not generally
|
|
|
|
|
* useful may be meaningful to some device drivers.
|
|
|
|
|
*
|
|
|
|
|
* Returns the number of bytes read on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
ssize_t read(int __fd, void* __BIONIC_COMPLICATED_NULLNESS __buf, size_t __count);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [write(2)](https://man7.org/linux/man-pages/man2/write.2.html) writes
|
|
|
|
|
* up to `__count` bytes to file descriptor `__fd` from `__buf`.
|
|
|
|
|
*
|
|
|
|
|
* Note: `__buf` is not normally nullable, but may be null in the
|
|
|
|
|
* special case of a zero-length write(), which while not generally
|
|
|
|
|
* useful may be meaningful to some device drivers.
|
|
|
|
|
*
|
|
|
|
|
* Returns the number of bytes written on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
ssize_t write(int __fd, const void* __BIONIC_COMPLICATED_NULLNESS __buf, size_t __count);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
|
2017-08-26 00:07:05 +02:00
|
|
|
|
int dup(int __old_fd);
|
|
|
|
|
int dup2(int __old_fd, int __new_fd);
|
2023-06-16 21:39:33 +02:00
|
|
|
|
int dup3(int __old_fd, int __new_fd, int __flags);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int fsync(int __fd);
|
2019-10-04 01:09:04 +02:00
|
|
|
|
int fdatasync(int __fd);
|
2015-02-07 07:28:49 +01:00
|
|
|
|
|
2023-10-05 01:36:14 +02:00
|
|
|
|
/* See https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md */
|
2017-07-06 00:23:50 +02:00
|
|
|
|
#if defined(__USE_FILE_OFFSET64)
|
2023-06-16 21:39:33 +02:00
|
|
|
|
int truncate(const char* _Nonnull __path, off_t __length) __RENAME(truncate64);
|
2017-11-28 23:47:17 +01:00
|
|
|
|
off_t lseek(int __fd, off_t __offset, int __whence) __RENAME(lseek64);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
ssize_t pread(int __fd, void* _Nonnull __buf, size_t __count, off_t __offset) __RENAME(pread64);
|
|
|
|
|
ssize_t pwrite(int __fd, const void* _Nonnull __buf, size_t __count, off_t __offset) __RENAME(pwrite64);
|
2019-10-04 05:35:38 +02:00
|
|
|
|
int ftruncate(int __fd, off_t __length) __RENAME(ftruncate64);
|
2015-09-04 21:59:53 +02:00
|
|
|
|
#else
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int truncate(const char* _Nonnull __path, off_t __length);
|
2017-11-28 23:47:17 +01:00
|
|
|
|
off_t lseek(int __fd, off_t __offset, int __whence);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
ssize_t pread(int __fd, void* _Nonnull __buf, size_t __count, off_t __offset);
|
|
|
|
|
ssize_t pwrite(int __fd, const void* _Nonnull __buf, size_t __count, off_t __offset);
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int ftruncate(int __fd, off_t __length);
|
2015-09-04 21:59:53 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2023-06-16 21:39:33 +02:00
|
|
|
|
int truncate64(const char* _Nonnull __path, off64_t __length);
|
2017-11-28 23:47:17 +01:00
|
|
|
|
off64_t lseek64(int __fd, off64_t __offset, int __whence);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
ssize_t pread64(int __fd, void* _Nonnull __buf, size_t __count, off64_t __offset);
|
|
|
|
|
ssize_t pwrite64(int __fd, const void* _Nonnull __buf, size_t __count, off64_t __offset);
|
2019-10-04 05:35:38 +02:00
|
|
|
|
int ftruncate64(int __fd, off64_t __length);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int pause(void);
|
|
|
|
|
unsigned int alarm(unsigned int __seconds);
|
|
|
|
|
unsigned int sleep(unsigned int __seconds);
|
2017-08-26 00:07:05 +02:00
|
|
|
|
int usleep(useconds_t __microseconds);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int gethostname(char* _Nonnull _buf, size_t __buf_size);
|
|
|
|
|
int sethostname(const char* _Nonnull __name, size_t __n) __INTRODUCED_IN(23);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int brk(void* _Nonnull __addr);
|
|
|
|
|
void* _Nullable sbrk(ptrdiff_t __increment);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int isatty(int __fd);
|
2023-01-10 01:18:05 +01:00
|
|
|
|
char* _Nullable ttyname(int __fd);
|
|
|
|
|
int ttyname_r(int __fd, char* _Nonnull __buf, size_t __buf_size);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int acct(const char* _Nullable __path);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2024-03-27 22:23:42 +01:00
|
|
|
|
/**
|
|
|
|
|
* [getpagesize(2)](https://man7.org/linux/man-pages/man2/getpagesize.2.html)
|
|
|
|
|
* returns the system's page size. This is slightly faster than going via
|
|
|
|
|
* sysconf().
|
|
|
|
|
*
|
|
|
|
|
* Returns the system's page size in bytes.
|
|
|
|
|
*/
|
2023-06-23 20:29:51 +02:00
|
|
|
|
int getpagesize(void) __attribute_const__;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2015-09-04 21:59:53 +02:00
|
|
|
|
long syscall(long __number, ...);
|
2015-02-20 07:49:44 +01:00
|
|
|
|
|
2017-08-26 00:07:05 +02:00
|
|
|
|
int daemon(int __no_chdir, int __no_close);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2020-02-14 00:56:31 +01:00
|
|
|
|
#if defined(__arm__)
|
2016-07-23 03:57:12 +02:00
|
|
|
|
int cacheflush(long __addr, long __nbytes, long __cache);
|
2014-02-11 03:37:02 +01:00
|
|
|
|
/* __attribute__((deprecated("use __builtin___clear_cache instead"))); */
|
|
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
|
pid_t tcgetpgrp(int __fd);
|
|
|
|
|
int tcsetpgrp(int __fd, pid_t __pid);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
2009-10-05 22:19:05 +02:00
|
|
|
|
/* Used to retry syscalls that can return EINTR. */
|
|
|
|
|
#define TEMP_FAILURE_RETRY(exp) ({ \
|
2014-05-22 05:33:28 +02:00
|
|
|
|
__typeof__(exp) _rc; \
|
2009-10-05 22:19:05 +02:00
|
|
|
|
do { \
|
|
|
|
|
_rc = (exp); \
|
|
|
|
|
} while (_rc == -1 && errno == EINTR); \
|
|
|
|
|
_rc; })
|
|
|
|
|
|
2023-01-10 01:18:05 +01:00
|
|
|
|
int getdomainname(char* _Nonnull __buf, size_t __buf_size) __INTRODUCED_IN(26);
|
|
|
|
|
int setdomainname(const char* _Nonnull __name, size_t __n) __INTRODUCED_IN(26);
|
2016-03-03 17:37:53 +01:00
|
|
|
|
|
2022-04-22 20:08:09 +02:00
|
|
|
|
/**
|
|
|
|
|
* [copy_file_range(2)](https://man7.org/linux/man-pages/man2/copy_file_range.2.html) copies
|
|
|
|
|
* a range of data from one file descriptor to another.
|
|
|
|
|
*
|
|
|
|
|
* Available since API level 34.
|
2022-11-30 20:53:33 +01:00
|
|
|
|
*
|
|
|
|
|
* Returns the number of bytes copied on success, and returns -1 and sets
|
|
|
|
|
* `errno` on failure.
|
2022-04-22 20:08:09 +02:00
|
|
|
|
*/
|
2023-01-10 01:18:05 +01:00
|
|
|
|
ssize_t copy_file_range(int __fd_in, off64_t* _Nullable __off_in, int __fd_out, off64_t* _Nullable __off_out, size_t __length, unsigned int __flags) __INTRODUCED_IN(34);
|
2022-04-22 20:08:09 +02:00
|
|
|
|
|
2019-06-14 23:19:22 +02:00
|
|
|
|
#if __ANDROID_API__ >= 28
|
2023-01-10 01:18:05 +01:00
|
|
|
|
void swab(const void* _Nonnull __src, void* _Nonnull __dst, ssize_t __byte_count) __INTRODUCED_IN(28);
|
2019-06-14 23:19:22 +02:00
|
|
|
|
#endif
|
2017-10-18 22:34:32 +02:00
|
|
|
|
|
2022-01-21 20:19:55 +01:00
|
|
|
|
/**
|
|
|
|
|
* [close_range(2)](https://man7.org/linux/man-pages/man2/close_range.2.html)
|
|
|
|
|
* performs an action (which depends on value of flags) on an inclusive range
|
|
|
|
|
* of file descriptors.
|
|
|
|
|
*
|
|
|
|
|
* Available since API level 34.
|
|
|
|
|
*
|
|
|
|
|
* Note: there is no emulation on too old kernels, hence this will fail with
|
|
|
|
|
* -1/ENOSYS on pre-5.9 kernels, -1/EINVAL for unsupported flags. In particular
|
|
|
|
|
* CLOSE_RANGE_CLOEXEC requires 5.11, though support was backported to Android
|
|
|
|
|
* Common Kernel 5.10-T.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
|
*/
|
|
|
|
|
int close_range(unsigned int __min_fd, unsigned int __max_fd, int __flags) __INTRODUCED_IN(34);
|
|
|
|
|
|
2017-07-25 00:05:05 +02:00
|
|
|
|
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
|
2018-08-28 21:17:20 +02:00
|
|
|
|
#define _UNISTD_H_
|
2017-07-25 00:05:05 +02:00
|
|
|
|
#include <bits/fortify/unistd.h>
|
2018-08-28 21:17:20 +02:00
|
|
|
|
#undef _UNISTD_H_
|
2017-02-09 09:00:31 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
|
__END_DECLS
|
2019-06-14 23:19:22 +02:00
|
|
|
|
|
|
|
|
|
#include <android/legacy_unistd_inlines.h>
|