Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
unistd.h
Go to the documentation of this file.
1 
4 #ifndef __UNISTD_H__
5 #define __UNISTD_H__
6 
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <sys/types.h>
10 
11 #include "kconfig.h"
12 
13 #define MQ_PRIO_MAX _MQ_PRIO_MAX
14 
15 #define STDIN_FILENO 0 /* Standard input file descriptor */
16 #define STDOUT_FILENO 1 /* Standard output file descriptor */
17 #define STDERR_FILENO 2 /* Standard error file descriptor */
18 
26 unsigned int sleep(unsigned int seconds);
27 
34 int usleep(useconds_t usec);
35 
42 int close(int fd);
43 
51 int dup(int oldfd);
52 
61 int dup2(int oldfd, int newfd);
62 
70 int pipe(int pipefd[2]);
71 
77 pid_t vfork(void);
78 
83 pid_t fork(void);
84 
90 pid_t setsid(void);
91 
101 int execve(const char *pathname, char *const argv[], char *const envp[]);
102 
110 int execvp(const char *file, char *const argv[]);
111 
120 ssize_t read(int fd, void *buf, size_t count);
121 
130 ssize_t write(int fd, const void *buf, size_t count);
131 
141 off_t lseek(int fd, long offset, int whence);
142 
147 pid_t getpid(void);
148 
154 pid_t getppid(void);
155 
165 char *getcwd(char *buf, size_t size);
166 
172 int chdir(const char *path);
173 
179 int unlink(const char *pathname);
180 
186 int rmdir(const char *pathname);
187 
188 /* Values sysconf() reports, with the numbers Linux gives them */
189 #define _SC_ARG_MAX 0
190 #define _SC_CLK_TCK 2
191 #define _SC_OPEN_MAX 4
192 #define _SC_PAGESIZE 8
193 
200 /* Newlib ships one that answers for a system Tenok is not */
201 #define sysconf _sysconf
202 long sysconf(int name);
203 
204 /* Accessibility asked about by access() */
205 #define F_OK 0 /* The file exists */
206 #define X_OK 1 /* The file can be executed */
207 #define W_OK 2 /* The file can be written */
208 #define R_OK 4 /* The file can be read */
209 
216 int isatty(int fd);
217 
224 int access(const char *pathname, int mode);
225 
230 uid_t getuid(void);
231 
239 int setuid(uid_t uid);
240 
248 int seteuid(uid_t uid);
249 uid_t geteuid(void);
250 
255 gid_t getgid(void);
256 
264 int setgid(gid_t gid);
265 
273 int setegid(gid_t gid);
274 gid_t getegid(void);
275 
283 int getgroups(int size, gid_t list[]);
284 
291 int link(const char *oldpath, const char *newpath);
292 
299 int symlink(const char *target, const char *linkpath);
300 
310 int readlink(const char *pathname, char *buf, size_t bufsiz);
311 
318 int fchdir(int fd);
319 
328 int ttyname_r(int fd, char *buf, size_t buflen);
329 
336 int chroot(const char *path);
337 
346 int chown(const char *pathname, uid_t owner, gid_t group);
347 
356 int lchown(const char *pathname, uid_t owner, gid_t group);
357 
358 #endif
Definition: fs.h:136
Definition: grp.h:10
pid_t vfork(void)
Create a child process. Tenok runs every task from the image it booted and has no way to make another...
Definition: task.c:62
int seteuid(uid_t uid)
Become the effective user of the given identifier, the way setuid() does.
Definition: pwd.c:93
int chdir(const char *path)
Change working directory.
Definition: file.c:274
int dup2(int oldfd, int newfd)
Perform the same task as dup(), but use the file descriptor number specified by newfd.
Definition: file.c:97
int lchown(const char *pathname, uid_t owner, gid_t group)
Replace the owner of a file without following a symbolic link. Tenok has no symbolic link,...
Definition: pwd.c:120
int fchdir(int fd)
Change the working directory to the one the descriptor names. Tenok keeps no way back from a descript...
Definition: wrapper.c:433
int dup(int oldfd)
Create a copy of the file descriptor oldfd, using the lowest-numbered unused file descriptor for the ...
Definition: file.c:68
uid_t getuid(void)
Report the user a task runs as, which on Tenok is always root.
Definition: pwd.c:49
int setgid(gid_t gid)
Join the group of the given identifier. Tenok has the one group, so only that one can be joined.
Definition: pwd.c:83
char * getcwd(char *buf, size_t size)
Get current working directory.
Definition: file.c:246
int execve(const char *pathname, char *const argv[], char *const envp[])
Replace the running program with the one the pathname names. No file of Tenok is in a format the syst...
Definition: task.c:87
int pipe(int pipefd[2])
Create a pipe, a stream that is written to through one descriptor and read from through the other.
Definition: file.c:107
pid_t setsid(void)
Start a session. Tenok has the one console and no sessions to give it out to.
Definition: task.c:77
int isatty(int fd)
Tell whether a descriptor refers to a terminal.
Definition: file.c:444
int rmdir(const char *pathname)
Delete a directory, which must be empty.
Definition: file.c:341
gid_t getgid(void)
Report the group a task runs as, which on Tenok is always root.
Definition: pwd.c:59
unsigned int sleep(unsigned int seconds)
To cause the calling thread to sleep either until the number of real-time seconds specified in second...
Definition: sched.c:44
int chown(const char *pathname, uid_t owner, gid_t group)
Replace the owner of a file. Tenok has one user, so only a request that names it can be granted.
Definition: pwd.c:103
off_t lseek(int fd, long offset, int whence)
Reposition the file offset of the open file description associated with the file descriptor fd.
Definition: file.c:163
int symlink(const char *target, const char *linkpath)
Make a name that stands for another. Tenok has no symbolic link.
Definition: wrapper.c:415
int ttyname_r(int fd, char *buf, size_t buflen)
Name the terminal the descriptor is open on. Tenok keeps no way back from a descriptor to the name it...
Definition: wrapper.c:440
int execvp(const char *file, char *const argv[])
Replace the running program with the one found by searching PATH for the file, the way execve() does.
Definition: task.c:93
#define sysconf
Report a value of the system that is decided when it is built.
Definition: unistd.h:201
int setuid(uid_t uid)
Become the user of the given identifier. Tenok runs as the one user it has, so only that one can be b...
Definition: pwd.c:73
pid_t fork(void)
Create a child process, the way vfork() does not either.
Definition: task.c:68
int access(const char *pathname, int mode)
Check whether the calling task can reach a file the way it asks.
Definition: file.c:411
int getgroups(int size, gid_t list[])
Report the supplementary groups of the task. Tenok has one group and root is in it,...
Definition: pwd.c:126
int link(const char *oldpath, const char *newpath)
Give a file a second name. Tenok gives a file one name.
Definition: wrapper.c:408
int close(int fd)
Close a file descriptor, so that it no longer refers to any file and may be reused.
Definition: file.c:53
ssize_t write(int fd, const void *buf, size_t count)
Write up to count bytes from the buffer starting at buf to the file referred to by the file descripto...
Definition: file.c:132
int usleep(useconds_t usec)
Suspend execution of the calling thread for a given time in microseconds.
Definition: sched.c:64
pid_t getpid(void)
Return the ID of the calling task.
Definition: task.c:25
pid_t getppid(void)
Return the ID of the task that started the calling one. Every task of Tenok is started by the one tha...
Definition: task.c:39
int readlink(const char *pathname, char *buf, size_t bufsiz)
Read what a symbolic link stands for. Nothing a path of Tenok names is one.
Definition: wrapper.c:422
int setegid(gid_t gid)
Join the effective group of the given identifier, the way setgid() does.
Definition: pwd.c:98
ssize_t read(int fd, void *buf, size_t count)
Attempt to read up to count bytes from file descriptor fd into the buffer starting at buf.
Definition: file.c:117
int unlink(const char *pathname)
Delete a name from the file system.
Definition: file.c:351
int chroot(const char *path)
Make the given directory the root. The root of Tenok is the whole of what it mounted,...
Definition: wrapper.c:450