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.
|
|
|
|
*/
|
|
|
|
#ifndef _UNISTD_H_
|
|
|
|
#define _UNISTD_H_
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/sysconf.h>
|
|
|
|
#include <linux/capability.h>
|
|
|
|
#include <pathconf.h>
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
/* Standard file descriptor numbers. */
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
|
|
|
|
/* Values for whence in fseek and lseek */
|
|
|
|
#define SEEK_SET 0
|
|
|
|
#define SEEK_CUR 1
|
|
|
|
#define SEEK_END 2
|
|
|
|
|
|
|
|
extern char **environ;
|
|
|
|
extern __noreturn void _exit(int);
|
|
|
|
|
|
|
|
extern pid_t fork(void);
|
|
|
|
extern pid_t vfork(void);
|
|
|
|
extern pid_t getpid(void);
|
|
|
|
extern pid_t gettid(void);
|
|
|
|
extern pid_t getpgid(pid_t);
|
|
|
|
extern int setpgid(pid_t, pid_t);
|
|
|
|
extern pid_t getppid(void);
|
|
|
|
extern pid_t getpgrp(void);
|
|
|
|
extern int setpgrp(void);
|
2012-08-29 10:48:35 +02:00
|
|
|
extern pid_t getsid(pid_t);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern pid_t setsid(void);
|
|
|
|
|
|
|
|
extern int execv(const char *, char * const *);
|
|
|
|
extern int execvp(const char *, char * const *);
|
|
|
|
extern int execve(const char *, char * const *, char * const *);
|
|
|
|
extern int execl(const char *, const char *, ...);
|
|
|
|
extern int execlp(const char *, const char *, ...);
|
|
|
|
extern int execle(const char *, const char *, ...);
|
|
|
|
extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
|
|
|
|
extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
|
2011-05-26 02:46:41 +02:00
|
|
|
|
|
|
|
/* IMPORTANT: See comment under <sys/prctl.h> about this declaration */
|
|
|
|
extern int prctl(int option, ...);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern int nice(int);
|
|
|
|
|
|
|
|
extern int setuid(uid_t);
|
|
|
|
extern uid_t getuid(void);
|
|
|
|
extern int seteuid(uid_t);
|
|
|
|
extern uid_t geteuid(void);
|
|
|
|
extern int setgid(gid_t);
|
|
|
|
extern gid_t getgid(void);
|
|
|
|
extern int setegid(gid_t);
|
|
|
|
extern gid_t getegid(void);
|
|
|
|
extern int getgroups(int, gid_t *);
|
|
|
|
extern int setgroups(size_t, const gid_t *);
|
|
|
|
extern int setreuid(uid_t, uid_t);
|
|
|
|
extern int setregid(gid_t, gid_t);
|
|
|
|
extern int setresuid(uid_t, uid_t, uid_t);
|
|
|
|
extern int setresgid(gid_t, gid_t, gid_t);
|
|
|
|
extern int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
|
|
|
|
extern int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
|
|
|
|
extern int issetugid(void);
|
|
|
|
extern char* getlogin(void);
|
2010-01-14 02:48:34 +01:00
|
|
|
extern char* getusershell(void);
|
|
|
|
extern void setusershell(void);
|
|
|
|
extern void endusershell(void);
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Macros for access() */
|
|
|
|
#define R_OK 4 /* Read */
|
|
|
|
#define W_OK 2 /* Write */
|
|
|
|
#define X_OK 1 /* Execute */
|
|
|
|
#define F_OK 0 /* Existence */
|
|
|
|
|
|
|
|
extern int access(const char *, int);
|
2012-04-13 23:56:25 +02:00
|
|
|
extern int faccessat(int, const char *, int, int);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern int link(const char *, const char *);
|
|
|
|
extern int unlink(const char *);
|
|
|
|
extern int chdir(const char *);
|
|
|
|
extern int fchdir(int);
|
|
|
|
extern int rmdir(const char *);
|
|
|
|
extern int pipe(int *);
|
2010-09-27 17:33:08 +02:00
|
|
|
#ifdef _GNU_SOURCE /* GLibc compatibility */
|
|
|
|
extern int pipe2(int *, int);
|
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
extern int chroot(const char *);
|
|
|
|
extern int symlink(const char *, const char *);
|
|
|
|
extern int readlink(const char *, char *, size_t);
|
|
|
|
extern int chown(const char *, uid_t, gid_t);
|
|
|
|
extern int fchown(int, uid_t, gid_t);
|
|
|
|
extern int lchown(const char *, uid_t, gid_t);
|
2010-06-11 23:37:34 +02:00
|
|
|
extern int truncate(const char *, off_t);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern char *getcwd(char *, size_t);
|
|
|
|
|
|
|
|
extern int sync(void);
|
|
|
|
|
|
|
|
extern int close(int);
|
|
|
|
extern off_t lseek(int, off_t, int);
|
2010-08-06 20:45:43 +02:00
|
|
|
extern off64_t lseek64(int, off64_t, int);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern ssize_t read(int, void *, size_t);
|
|
|
|
extern ssize_t write(int, const void *, size_t);
|
|
|
|
extern ssize_t pread(int, void *, size_t, off_t);
|
2010-11-24 22:10:49 +01:00
|
|
|
extern ssize_t pread64(int, void *, size_t, off64_t);
|
2010-08-11 18:28:26 +02:00
|
|
|
extern ssize_t pwrite(int, const void *, size_t, off_t);
|
2010-11-24 22:10:49 +01:00
|
|
|
extern ssize_t pwrite64(int, const void *, size_t, off64_t);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern int dup(int);
|
|
|
|
extern int dup2(int, int);
|
|
|
|
extern int fcntl(int, int, ...);
|
|
|
|
extern int ioctl(int, int, ...);
|
|
|
|
extern int flock(int, int);
|
|
|
|
extern int fsync(int);
|
|
|
|
extern int fdatasync(int);
|
|
|
|
extern int ftruncate(int, off_t);
|
2010-12-16 16:47:14 +01:00
|
|
|
extern int ftruncate64(int, off64_t);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern int pause(void);
|
|
|
|
extern unsigned int alarm(unsigned int);
|
|
|
|
extern unsigned int sleep(unsigned int);
|
2009-12-15 02:07:19 +01:00
|
|
|
extern int usleep(unsigned long);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern int gethostname(char *, size_t);
|
|
|
|
|
|
|
|
extern int getdtablesize(void);
|
|
|
|
|
|
|
|
extern void *__brk(void *);
|
|
|
|
extern int brk(void *);
|
|
|
|
extern void *sbrk(ptrdiff_t);
|
|
|
|
|
|
|
|
extern int getopt(int, char * const *, const char *);
|
|
|
|
extern char *optarg;
|
|
|
|
extern int optind, opterr, optopt;
|
|
|
|
|
|
|
|
extern int isatty(int);
|
2010-01-14 02:48:34 +01:00
|
|
|
extern char* ttyname(int);
|
|
|
|
extern int ttyname_r(int, char*, size_t);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern int acct(const char* filepath);
|
|
|
|
|
|
|
|
static __inline__ int getpagesize(void) {
|
|
|
|
extern unsigned int __page_size;
|
|
|
|
return __page_size;
|
|
|
|
}
|
|
|
|
static __inline__ int __getpageshift(void) {
|
|
|
|
extern unsigned int __page_shift;
|
|
|
|
return __page_shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int sysconf(int name);
|
|
|
|
|
|
|
|
extern int daemon(int, int);
|
|
|
|
|
|
|
|
/* A special syscall that is only available on the ARM, not x86 function. */
|
|
|
|
extern int cacheflush(long start, long end, long flags);
|
|
|
|
|
|
|
|
extern pid_t tcgetpgrp(int fd);
|
|
|
|
extern int tcsetpgrp(int fd, pid_t _pid);
|
|
|
|
|
2010-10-09 17:56:55 +02:00
|
|
|
#if 0 /* MISSING FROM BIONIC */
|
|
|
|
extern int execvpe(const char *, char * const *, char * const *);
|
|
|
|
extern int execlpe(const char *, const char *, ...);
|
|
|
|
extern int getfsuid(uid_t);
|
|
|
|
extern int setfsuid(uid_t);
|
|
|
|
extern int getlogin_r(char* name, size_t namesize);
|
|
|
|
extern int sethostname(const char *, size_t);
|
|
|
|
extern int getdomainname(char *, size_t);
|
|
|
|
extern int setdomainname(const char *, size_t);
|
|
|
|
#endif /* MISSING */
|
|
|
|
|
2009-10-05 22:19:05 +02:00
|
|
|
/* Used to retry syscalls that can return EINTR. */
|
|
|
|
#define TEMP_FAILURE_RETRY(exp) ({ \
|
|
|
|
typeof (exp) _rc; \
|
|
|
|
do { \
|
|
|
|
_rc = (exp); \
|
|
|
|
} while (_rc == -1 && errno == EINTR); \
|
|
|
|
_rc; })
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* _UNISTD_H_ */
|