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
|
/*
* unistd.h - Standard Weenix System Interface
*/
#pragma once
#include "lseek.h"
#include "stdarg.h"
#include "sys/stat.h"
#include "sys/types.h"
#include "weenix/config.h"
#ifndef NULL
#define NULL 0
#endif
struct dirent;
/* User exec-related */
int fork(void);
int execl(const char *filename, const char *arg, ...); /* NYI */
int execle(const char *filename, const char *arg, ...); /* NYI */
int execv(const char *filename, char *const argv[]); /* NYI */
int execve(const char *filename, char *const argv[], char *const envp[]);
/* Kern-related */
pid_t wait(int *status);
pid_t waitpid(pid_t pid, int *status, int options);
void thr_exit(int status);
int thr_errno(void);
void thr_set_errno(int n);
int sched_yield(void);
pid_t getpid(void);
int halt(void);
void sync(void);
size_t get_free_mem(void);
/* VFS-related */
int open(const char *filename, int flags, int mode);
int close(int fd);
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
off_t lseek(int fd, off_t offset, int whence);
int dup(int fd);
int dup2(int ofd, int nfd);
int mkdir(const char *path, int mode);
int rmdir(const char *path);
int unlink(const char *path);
int link(const char *oldpath, const char *newpath);
int rename(const char *oldpath, const char *newpath);
int chdir(const char *path);
int getdents(int fd, struct dirent *dir, size_t size);
int stat(const char *path, struct stat *buf);
int pipe(int pipefd[2]);
/* VM-related */
void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off);
int munmap(void *addr, size_t len);
int brk(void *addr);
void *sbrk(intptr_t incr);
/* Mounting */
int mount(const char *source, const char *target, const char *filesystemtype,
unsigned long mountflags, const void *data);
int umount(const char *target);
time_t time(time_t *tloc);
long usleep(useconds_t usec);
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
|