MentOS  0.8.0
The Mentoring Operating System
unistd.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "sys/types.h"
9 #include "stddef.h"
10 #include "sys/dirent.h"
11 
12 #define STDIN_FILENO 0
13 #define STDOUT_FILENO 1
14 #define STDERR_FILENO 2
15 
16 #define stdin STDIN_FILENO
17 #define stdout STDOUT_FILENO
18 #define stderr STDERR_FILENO
19 
25 ssize_t read(int fd, void *buf, size_t nbytes);
26 
32 ssize_t write(int fd, const void *buf, size_t nbytes);
33 
39 int open(const char *pathname, int flags, mode_t mode);
40 
44 int close(int fd);
45 
54 off_t lseek(int fd, off_t offset, int whence);
55 
59 int unlink(const char *path);
60 
65 int symlink(const char *linkname, const char *path);
66 
72 int readlink(const char *path, char *buffer, size_t bufsize);
73 
76 extern void exit(int status);
77 
80 extern pid_t getpid(void);
81 
88 extern pid_t getsid(pid_t pid);
89 
98 extern pid_t setsid(void);
99 
105 
111 int setpgid(pid_t pid, pid_t pgid);
112 
115 extern gid_t getgid(void);
116 
119 extern gid_t getegid(void);
120 
125 extern int setgid(gid_t gid);
126 
132 extern int setregid(gid_t rgid, gid_t egid);
133 
136 extern uid_t getuid(void);
137 
140 extern uid_t geteuid(void);
141 
146 extern int setuid(uid_t uid);
147 
153 extern int setreuid(uid_t ruid, uid_t euid);
154 
157 extern pid_t getppid(void);
158 
164 extern pid_t fork(void);
165 
172 int execl(const char *path, const char *arg, ...);
173 
181 int execlp(const char *file, const char *arg, ...);
182 
189 int execle(const char *path, const char *arg, ...);
190 
198 int execlpe(const char *file, const char *arg, ...);
199 
205 int execv(const char *path, char *const argv[]);
206 
213 int execvp(const char *file, char *const argv[]);
214 
224 int execve(const char *path, char *const argv[], char *const envp[]);
225 
236 int execvpe(const char *file, char *const argv[], char *const envp[]);
237 
242 int nice(int inc);
243 
253 int reboot(int magic1, int magic2, unsigned int cmd, void *arg);
254 
260 char *getcwd(char *buf, size_t size);
261 
265 int chdir(char const *path);
266 
271 int fchdir(int fd);
272 
280 ssize_t getdents(int fd, dirent_t *dirp, unsigned int count);
281 
286 int dup(int fd);
287 
294 unsigned alarm(int seconds);
295 
301 int chmod(const char *pathname, mode_t mode);
302 
308 int fchmod(int fd, mode_t mode);
309 
316 int chown(const char *pathname, uid_t owner, gid_t group);
317 
324 int fchown(int fd, uid_t owner, gid_t group);
325 
332 int lchown(const char *pathname, uid_t owner, gid_t group);
Functions used to manage directories.
signed int pid_t
The type of process id.
Definition: types.h:9
Define basic data types.
int gid_t
The type of group-id.
Definition: stddef.h:43
long ssize_t
Define the generic signed size type.
Definition: stddef.h:31
long int off_t
The type of offset.
Definition: stddef.h:46
unsigned int mode_t
The type of mode.
Definition: stddef.h:49
int uid_t
The type of user-id.
Definition: stddef.h:40
Directory entry.
Definition: dirent.h:44
Contains user group informations.
Definition: grp.h:14
int readlink(const char *path, char *buffer, size_t bufsize)
Read the symbolic link, if present.
int setreuid(uid_t ruid, uid_t euid)
Sets the effective and real User IDs of the calling process.
int lchown(const char *pathname, uid_t owner, gid_t group)
Change the owner and group of a file.
int fchdir(int fd)
Is identical to chdir(), the only difference is that the directory is given as an open file descripto...
int execl(const char *path, const char *arg,...)
Replaces the current process image with a new process image (argument list).
Definition: exec.c:97
int chmod(const char *pathname, mode_t mode)
Change the file's mode bits.
int fchown(int fd, uid_t owner, gid_t group)
Change the owner and group of a file.
int unlink(const char *path)
Delete a name and possibly the file it refers to.
int execle(const char *path, const char *arg,...)
Replaces the current process image with a new process image (argument list).
Definition: exec.c:158
uid_t getuid(void)
Returns the real User ID of the calling process.
int setgid(gid_t gid)
sets the group IDs of the calling process.
char * getcwd(char *buf, size_t size)
Get current working directory.
pid_t getsid(pid_t pid)
Return session id of the given process. If pid == 0 return the SID of the calling process If pid !...
ssize_t write(int fd, const void *buf, size_t nbytes)
Write data into a file descriptor.
pid_t setsid(void)
creates a new session if the calling process is not a process group leader. The calling process is th...
gid_t getegid(void)
returns the effective group ID of the calling process.
int fchmod(int fd, mode_t mode)
Change the file's mode bits.
pid_t getpgid(pid_t pid)
returns the Process Group ID (PGID) of the process specified by pid. If pid is zero,...
int dup(int fd)
Return a new file descriptor.
int open(const char *pathname, int flags, mode_t mode)
Opens the file specified by pathname.
void exit(int status)
Wrapper for exit system call.
Definition: exit.c:9
gid_t getgid(void)
returns the real group ID of the calling process.
int execlp(const char *file, const char *arg,...)
Replaces the current process image with a new process image (argument list).
Definition: exec.c:126
int execlpe(const char *file, const char *arg,...)
Replaces the current process image with a new process image (argument list).
Definition: exec.c:198
int execve(const char *path, char *const argv[], char *const envp[])
Replaces the current process image with a new process image (argument vector), allows the caller to s...
Definition: exec.c:61
int chown(const char *pathname, uid_t owner, gid_t group)
Change the owner and group of a file.
int reboot(int magic1, int magic2, unsigned int cmd, void *arg)
Reboots the system, or enables/disables the reboot keystroke.
int setregid(gid_t rgid, gid_t egid)
sets the real and effective group IDs of the calling process.
uid_t geteuid(void)
Returns the effective User ID of the calling process.
off_t lseek(int fd, off_t offset, int whence)
Repositions the file offset inside a file.
ssize_t read(int fd, void *buf, size_t nbytes)
Read data from a file descriptor.
int execvp(const char *file, char *const argv[])
Replaces the current process image with a new process image (argument vector).
Definition: exec.c:73
int setuid(uid_t uid)
Sets the User IDs of the calling process.
pid_t fork(void)
Clone the calling process, but without copying the whole address space. The calling process is suspen...
int symlink(const char *linkname, const char *path)
Creates a symbolic link.
int nice(int inc)
Adds inc to the nice value for the calling thread.
int close(int fd)
Close a file descriptor.
int chdir(char const *path)
Changes the current working directory to the given path.
pid_t getpid(void)
Returns the process ID (PID) of the calling process.
pid_t getppid(void)
Returns the parent process ID (PPID) of the calling process.
int execvpe(const char *file, char *const argv[], char *const envp[])
Replaces the current process image with a new process image (argument vector), allows the caller to s...
Definition: exec.c:78
int execv(const char *path, char *const argv[])
Replaces the current process image with a new process image (argument vector).
Definition: exec.c:68
int setpgid(pid_t pid, pid_t pgid)
Sets the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of t...
ssize_t getdents(int fd, dirent_t *dirp, unsigned int count)
unsigned alarm(int seconds)
Send signal to calling thread after desired seconds.