The Pedigree Project  0.1
system-syscalls.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef SYSTEM_SYSCALLS_H
21 #define SYSTEM_SYSCALLS_H
22 
23 #include "pedigree/kernel/processor/Processor.h"
24 #include "pedigree/kernel/processor/VirtualAddressSpace.h"
25 #include "pedigree/kernel/processor/state.h"
26 
27 #include "logging.h"
28 
29 #include <sys/types.h>
30 
31 // Forward-declare types.
32 struct group;
33 struct passwd;
34 struct timespec;
35 
36 uintptr_t posix_brk(uintptr_t theBreak);
37 long posix_sbrk(int delta);
38 long posix_clone(
39  SyscallState &state, unsigned long flags, void *child_stack, int *ptid,
40  int *ctid, unsigned long newtls);
41 int posix_fork(SyscallState &state);
42 int posix_execve(
43  const char *name, const char **argv, const char **env, SyscallState &state);
44 int posix_waitpid(const int pid, int *status, int options);
45 int posix_exit(int code, bool allthreads = true) NORETURN;
46 int posix_getpid();
47 int posix_getppid();
48 
49 int posix_gettimeofday(timeval *tv, struct timezone *tz);
50 int posix_settimeofday(const timeval *tv, const struct timezone *tz);
51 time_t posix_time(time_t *tval);
52 clock_t posix_times(struct tms *tm);
53 int posix_getrusage(int who, struct rusage *r);
54 
55 int posix_getpwent(passwd *pw, int n, char *str);
56 int posix_getpwnam(passwd *pw, const char *name, char *str);
57 uid_t posix_getuid();
58 gid_t posix_getgid();
59 uid_t posix_geteuid();
60 gid_t posix_getegid();
61 int posix_setuid(uid_t uid);
62 int posix_setgid(gid_t gid);
63 int posix_seteuid(uid_t euid);
64 int posix_setegid(gid_t egid);
65 
66 size_t posix_alarm(uint32_t seconds);
67 int posix_sleep(uint32_t seconds);
68 int posix_usleep(size_t useconds);
69 int posix_nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
70 int posix_clock_gettime(clockid_t clock_id, struct timespec *tp);
71 
72 int pedigree_sigret();
73 
74 int posix_setsid();
75 int posix_setpgid(int pid, int pgid);
76 int posix_getpgrp();
77 int posix_getpgid(int pid);
78 
79 mode_t posix_umask(mode_t mask);
80 
81 int posix_getgrnam(const char *name, struct group *out);
82 int posix_getgrgid(gid_t id, struct group *out);
83 
84 int posix_linux_syslog(int type, char *buf, int len);
85 int posix_syslog(const char *msg, int prio);
86 
87 int pedigree_login(int uid, const char *password);
88 
89 int pedigree_reboot();
90 
91 int posix_uname(struct utsname *n);
92 
93 int posix_prctl(
94  int option, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5);
95 int posix_arch_prctl(int code, unsigned long addr);
96 
97 int posix_pause();
98 
99 int posix_setgroups(size_t size, const gid_t *list);
100 int posix_getgroups(size_t size, gid_t *list);
101 
102 int posix_getrlimit(int resource, struct rlimit *rlim);
103 int posix_setrlimit(int resource, const struct rlimit *rlim);
104 int posix_getpriority(int which, int who);
105 int posix_setpriority(int which, int who, int prio);
106 
107 int posix_setreuid(uid_t ruid, uid_t euid);
108 int posix_setregid(gid_t rgid, gid_t egid);
109 
110 int posix_setresuid(uid_t ruid, uid_t euid, uid_t suid);
111 int posix_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
112 int posix_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
113 int posix_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
114 
115 int posix_get_robust_list(
116  int pid, struct robust_list_head **head_ptr, size_t *len_ptr);
117 int posix_set_robust_list(struct robust_list_head *head, size_t len);
118 
119 int posix_ioperm(unsigned long from, unsigned long num, int turn_on);
120 int posix_iopl(int level);
121 
122 int posix_getitimer(int which, struct itimerval *curr_value);
123 int posix_setitimer(
124  int which, const struct itimerval *new_value, struct itimerval *old_value);
125 
126 int posix_capget(void *hdrp, void *datap);
127 int posix_capset(void *hdrp, const void *datap);
128 
129 #endif