summaryrefslogtreecommitdiff
path: root/include/unistd.h
blob: 8c7eae4fcf7713c6cc6394837751849e61553cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef UNISTD_H
#define UNISTD_H

#include <sys/types.h>
#include <stdint.h>
#include <stddef.h>

#define STDIN_FILENO    0
#define STDOUT_FILENO   1
#define STDERR_FILENO   2

#define SEEK_SET        0
#define SEEK_CUR        1
#define SEEK_END        2
#define SEEK_DATA       3
#define SEEK_HOLE       4

#define NULL            ((void*)0)

#define F_OK            0
#define R_OK            4
#define W_OK            2
#define X_OK            1

int pipe();
int pipe2();
int close(int fildes);
int dup(int fildes);
int dup2();
int dup3();
off_t lseek();
int fsync();
int fdatasync();

ssize_t read(int fildes, void *buf, size_t nbyte);
ssize_t write(int fildes, const void *buf, size_t nbyte);
ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);
ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);

int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fildes, uid_t owner, gid_t group);
int lchown(const char *path, uid_t owner, gid_t group);
int fchownat(int fildes, const char *path, uid_t owner, gid_t group);

int link(const char *target, const char *lpath);
int linkat(int target_fd, const char *tpath, int link_fd, const char *lpath);
int symlink(const char *target, const char *lpath);
int symlinkat(const char *target, int fildes, const char *lpath);
ssize_t readlink(const char* __restrict path, char* __restrict buf, size_t bufsz);
ssize_t readlinkat(int fildes, const char* __restrict path, char* __restrict buf, size_t bufsz);
int unlink(const char *lpath);
int unlinkat(int fildes, const char *lpath, int flag);
int rmdir(const char *path);
int truncate(const char *path, off_t length);
int ftruncate(int fildes, off_t length);

int access(const char *path, int amode);
int faccessat(int fildes, const char *path, int amode, int flag);

int chdir(const char *path);
int fchdir(int fildes);
char* getcwd(char *buf, size_t bufsz);

unsigned int alarm(unsigned int seconds);
unsigned int sleep(unsigned int seconds);
unsigned int ualarm(useconds_t usec);
unsigned int usleep(useconds_t usec);
int pause(void);

pid_t fork(void);
pid_t vfork(void);
void _exit(int status);
int execve(const char *pathname, char* const argv[], char* const envp[]);
int execv(const char *pathname, char* const argv[]);
int execle(const char *pathname, const char *argv, ...);
int execl(const char *pathname, const char *argv, ...);
int execvp(const char *pathname, char* const argv[]);
int execvpe(const char *pathname, char* const argv[], char* const envp[]);
int execlp(const char *pathname, char* const argv[], ...);
int fexecve(int fildes, char* const argv[], char* const envp[]);

pid_t getpid(void);
pid_t getppid(void);
pid_t getpgrp(void);
pid_t getpgid(pid_t);
int setpgid(pid_t pid, pid_t pgid);
pid_t setsid(void);
pid_t getsid(pid_t pid);
char* ttyname(int fildes);
int ttyname_r(int fildes, char *buf, size_t bufsz);
int isatty(int fildes);
pid_t tcgetpgrp(int fildes);

uid_t getuid(void);
uid_t geteuid(void);
gid_t getgid(void);
gid_t getegid(void);
int getgroups(int gidsetsize, gid_t grouplist[]);
int setuid(uid_t uid);
int seteuid(uid_t euid);
int setgid(gid_t gid);
int setegid(gid_t egid);

char* getlogin(void);
int getlogin_r(char *buf, size_t bufsz);
char* ctermid(char *buf);

long int pathconf(const char *path, int name);
long int fpathconf(int fildes, int name);
long int sysconf(int name);
size_t confstr(int name, char *buf, size_t bufsz);

int setreuid(uid_t ruid, uid_t euid);
int setregid(gid_t rgid, gid_t egid);
int lockf(int fildes, int op, off_t length);

int nice(int incr);
void sync(void);
pid_t setpgrp(void);
void swab(const void* __restrict from, void* __restrict to, ssize_t n);

int brk(void *addr);
void* sbrk(intptr_t incr);

int vhangup(void);
int chroot(const char *path);
int getpagesize(void);
int getdtablesize(void);

int gethostname(char *buf, size_t bufsz);
int sethostname(const char *name, size_t len);
int getdomainname(char *buf, size_t bufsz);
int setdomainname(const char *name, size_t len);
int daemon(int nochdir, int noclose);

char* getusershell(void);
void setusershell(void);
void endusershell(void);

int acct(const char *path);
int getentropy(void *buffer, size_t bufsz);

#endif