aboutsummaryrefslogtreecommitdiff
path: root/include/sys.h
blob: 20dafa9430dafaabfa57c8a1e5f8eff230ee7c24 (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
#pragma once

/* types declarations */
#include <arch/types.h>
#include <arch/constants.h>

#include <os/types.h>
#include <os/constants.h>
#include <os/errno.h>

// -----------------------------------------------------------------------
// global constants

/* open */
#define sys·ORead    0x0u
#define sys·OWrite   0x1u
#define sys·ORdwr    0x2u
#define sys·OExec    sys·OPath

/* seek */
#define sys·SeekSet  0u
#define sys·SeekCur  1u
#define sys·SeekEnd  2u

/* special file descriptors */
#define sys·Stdin  0
#define sys·Stdout 1
#define sys·Stderr 2

// -----------------------------------------------------------------------
// functions

/* errors */
char *sys·errormsg(int num);

/* file operations */
int sys·open(char *path, int flag, int mode, int *fd);
int sys·openat(int dirfd, char *path, int flags, int mode, int *fd);
int sys·close(int fd);
int sys·write(int fd, void *buf, uintptr len, intptr *nw);
int sys·read(int fd, void *buf, uintptr len, intptr *nr);
int sys·seek(int fd, intptr offset, int from, intptr *pos);

int sys·access(char *path, int mode);
int sys·accessat(int dirfd, char *path, int mode, int flags);

int sys·info(char *path, sys·Info *ret);
int sys·infofd(int fd, sys·Info *ret);
int sys·infoat(int dirfd, char *path, int flag, uint mask, sys·Info *ret);

int sys·dup(int from, int to);

/* directory operations */
int sys·cwd(char *buf, uintptr size);

int sys·chdir(char *path);
int sys·chdirfd(int fd);
int sys·mkdir(char *path, uint mode);
int sys·mkdirat(int fd, char *path, uint mode);

int sys·direntry(int fd, void *buffer, uintptr len, uintptr *size);

/* file node */
int sys·mknode(char *path, uint mode, uint64 dev);
int sys·mknodeat(int dirfd, char *path, uint mode, uint64 device);

/* ioctl :( */
int sys·ioctl(int, int, ...);

/* process operations */
int sys·getpid(void);
int sys·getuid(void);
int sys·getgid(void);

int sys·getpgid(int pid);
int sys·setpgid(int pid, int pgid);

int sys·fork(void);
int sys·exec(char *program, char *argv[], char *env[]);

int sys·wait(int *status);
int sys·waitfor(int pid, int *status, int option, sys·UsageInfo *msg);

/* memory operations */
int sys·brk(void *addr);
//int sys·sbrk(intptr delta, void **ret);

int sys·mmap(void *addr, uintptr len, int prot, int flags, int fd, intptr off, void **ret);
int sys·mremap(void *old, uintptr from, uintptr to, int flags, void **new);
int sys·munmap(void *addr, uintptr len);
int sys·madvise(void *addr, uintptr len, int advice);
int sys·mprotect(void *addr, uintptr len, int prot);
int sys·mlock(void *addr, uintptr len);
int sys·munlock(void *addr, uintptr len);