Started adding sanity checks to syscalls. Added SYS_CHDIR and helpers. Used SYS_CHDIR...
[tpg/acess2.git] / Usermode / include / acess / sys.h
1 /*
2  * Acess2 System Interface Header
3  */
4 #ifndef _SYS_SYS_H_
5 #define _SYS_SYS_H_
6
7 #include <stdint.h>
8
9 // === CONSTANTS ===
10 #define OPENFLAG_EXEC   0x01
11 #define OPENFLAG_READ   0x02
12 #define OPENFLAG_WRITE  0x04
13 #define OPENFLAG_NOLINK 0x40
14 #define SEEK_SET        1
15 #define SEEK_CUR        0
16 #define SEEK_END        -1
17 #define CLONE_VM        0x10
18 #define FILEFLAG_DIRECTORY      0x10
19 #define FILEFLAG_SYMLINK        0x20
20
21 // === TYPES ===
22 struct s_sysACL {
23         union {
24                 struct {
25                         unsigned        group: 1;
26                         unsigned        id:     31;
27                 };
28                 uint32_t        object;
29         };
30         union {
31                 struct {
32                         unsigned        invert: 1;
33                         unsigned        perms:  31;
34                 };
35                 uint32_t        rawperms;
36         };
37 };
38 struct s_sysFInfo {
39         uint    uid, gid;
40         uint    flags;
41         uint64_t        size;
42         uint64_t        atime;
43         uint64_t        mtime;
44         uint64_t        ctime;
45          int    numacls;
46         struct s_sysACL acls[];
47 };
48 typedef struct s_sysFInfo       t_sysFInfo;
49 typedef struct s_sysACL t_sysACL;
50
51 // === FUNCTIONS ===
52 void    _SysDebug(char *str, ...);
53 // --- Proc ---
54 void    sleep();
55 void    wait(int miliseconds);
56  int    waittid(int id, int *status);
57  int    clone(int flags, void *stack);
58  int    execve(char *path, char **argv, char **envp);
59 // --- VFS ---
60  int    chdir(char *dir);
61  int    open(char *path, int flags);
62  int    reopen(int fd, char *path, int flags);
63 void    close(int fd);
64 uint64_t        read(int fd, uint64_t length, void *buffer);
65 uint64_t        write(int fd, uint64_t length, void *buffer);
66  int    seek(int fd, uint64_t offset, int whence);
67  int    ioctl(int fd, int id, void *data);
68  int    finfo(int fd, t_sysFInfo *info, int maxacls);
69  int    readdir(int fd, char *dest);
70  int    _SysGetACL(int fd, t_sysACL *dest);
71
72 // --- MEMORY ---
73 uint64_t        _SysGetPhys(uint vaddr);
74 uint64_t        _SysAllocate(uint vaddr);
75
76 #endif

UCC git Repository :: git.ucc.asn.au