syscalls_rust/syscalls/linux.rs
1#![cfg(target_os = "linux")]
2
3use std::ffi::*;
4
5use crate::types::linux::*;
6
7
8unsafe extern "system" {
9
10 /// read() attempts to read up to count bytes from file descriptor fd
11 /// into the buffer starting at buf.<br>
12 /// #### RETURN VALUE
13 /// On success, the number of bytes read is returned (zero indicates
14 /// end of file), and the file position is advanced by this number.
15 /// #### ERRORS
16 /// EAGAIN(35), EBADF(9), EFAULT(14), EINTR(4), EINVAL(22), EIO(5), EISDIR(21), etc.
17 /// #### Link
18 /// Read the docs
19 /// [here](https://man7.org/linux/man-pages/man2/read.2.html)
20 pub unsafe fn read(fd: c_uint, buf: *mut c_char, count: size_t) -> ssize_t;
21
22 /// write() writes up to count bytes from the buffer starting at buf
23 /// to the file referred to by the file descriptor fd.<br>
24 /// #### RETURN VALUE
25 /// On success, the number of bytes written is returned. On error, -1
26 /// is returned, and errno is set to indicate the error.
27 /// #### ERRORS
28 /// EAGAIN(35), EBADF(9), EDESTADDRREQ(39), EDQUOT(69), EFAULT(14), EFBIG(27),<br>
29 /// EINTR(4), EINVAL(22), EIO(5), ENOSPC(28), EPERM(1), EPIPE(32), etc.
30 /// #### Link
31 /// Read the docs
32 /// [here](https://man7.org/linux/man-pages/man2/write.2.html)
33 pub unsafe fn write(fd: c_uint, buf: *const c_char, count: size_t) -> ssize_t;
34
35 /// The open() system call opens the file specified by pathname. If
36 /// the specified file does not exist, it may optionally (if O_CREAT
37 /// is specified in flags) be created by open().<br>
38 /// #### RETURN VALUE
39 /// On success, the number of bytes read is returned (zero indicates
40 /// end of file), and the file position is advanced by this number.
41 /// #### ERRORS
42 /// EAGAIN(35), EBADF(9), EFAULT(14), EINTR(4), EINVAL(22), EIO(5), EISDIR(21), etc.
43 /// #### Link
44 /// Read the docs
45 /// [here](https://man7.org/linux/man-pages/man2/open.2.html)
46 pub unsafe fn open(filename: *const c_char, flags: c_int, mode: umode_t) -> c_long;
47
48 /// close() closes a file descriptor, so that it no longer refers to
49 /// any file and may be reused.<br>
50 /// #### RETURN VALUE
51 /// close() returns zero on success. On error, -1 is returned, and
52 /// errno is set to indicate the error.<br>
53 /// #### ERRORS
54 /// EBADF(9), EINTR(4), EIO(5), ENOSPC(28), etc.
55 /// #### Link
56 /// Read the docs
57 /// [here](https://man7.org/linux/man-pages/man2/close.2.html)
58 pub unsafe fn close(fd: c_uint) -> c_int;
59
60 pub unsafe fn newstat(filename: *const c_char, statbuf: *mut Stat) -> c_int;
61 pub unsafe fn newfstat(fd: c_uint, statbuf: *mut Stat) -> c_int;
62 pub unsafe fn newlstat(filename: *const c_char, statbuf: *mut Stat) -> c_int;
63 pub unsafe fn poll(ufds: *mut Pollfd, nfds: c_uint, timeout_msecs: c_int) -> c_int;
64 pub unsafe fn lseek(fd: c_uint, offset: off_t, whence: c_uint) -> off_t;
65 pub unsafe fn mmap(addr: c_ulong, len: c_ulong, prot: c_ulong, flags: c_ulong, fd: c_ulong, off: c_ulong) -> c_ulong;
66 pub unsafe fn mprotect(start: c_ulong, len: size_t, prot: c_ulong) -> c_int;
67 pub unsafe fn munmap(addr: c_ulong, len: size_t) -> c_int;
68
69 /// brk() and sbrk() change the location of the program break, which
70 /// defines the end of the process's data segment.<br>
71 /// #### RETURN VALUE
72 /// On success, brk() returns zero. On error, -1 is returned, and
73 /// errno is set to ENOMEM.
74 /// #### ERRORS
75 /// ENOMEM(12), etc.
76 /// #### Link
77 /// Read the docs
78 /// [here](https://man7.org/linux/man-pages/man2/brk.2.html)
79 pub unsafe fn brk(brk: c_ulong) -> c_ulong;
80
81
82 // pub unsafe fn rt_sigaction (int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize);
83 // pub unsafe fn rt_sigaction(sig: c_int, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize) -> c_int;
84
85 // pub unsafe fn rt_sigprocmask (int how, sigset_t *nset, sigset_t *oset, size_t sigsetsize);
86 // pub unsafe fn rt_sigreturn (void);
87 // pub unsafe fn ioctl (unsigned int fd, unsigned int cmd, unsigned long arg);
88 // pub unsafe fn pread64 (unsigned int fd, char *buf, size_t count, loff_t pos);
89 // pub unsafe fn pwrite64 (unsigned int fd, const char *buf, size_t count, loff_t pos);
90 // pub unsafe fn readv (unsigned long fd, const struct iovec *vec, unsigned long vlen);
91 // pub unsafe fn writev (unsigned long fd, const struct iovec *vec, unsigned long vlen);
92 // pub unsafe fn access (const char *filename, int mode);
93 // pub unsafe fn pipe (int *fildes);
94 // pub unsafe fn select (int n, fd_set *inp, fd_set *outp, fd_set *exp, struct __kernel_old_timeval *tvp);
95 // pub unsafe fn sched_yield (void);
96 // pub unsafe fn mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr);
97 // pub unsafe fn msync (MMU unsigned long start, size_t len, int flags);
98 // pub unsafe fn mincore (MMU unsigned long start, size_t len, unsigned char *vec);
99 // pub unsafe fn madvise (ADVISE_SYSCALLS unsigned long start, size_t len_in, int behavior);
100 // pub unsafe fn shmget (SYSVIPC key_t key, size_t size, int shmflg);
101 // pub unsafe fn shmat (SYSVIPC int shmid, char *shmaddr, int shmflg
102 // pub unsafe fn shmct (SYSVIPC int shmid, int cmd, struct shmid_ds *buf);
103 // pub unsafe fn dup (unsigned int fildes);
104 // pub unsafe fn dup2 (unsigned int oldfd, unsigned int newfd);
105 // pub unsafe fn pause (void);
106 // pub unsafe fn nanosleep (struct __kernel_timespec *rqtp, struct __kernel_timespec *rmtp);
107 // pub unsafe fn getitimer (int which, struct __kernel_old_itimerval *value);
108 // pub unsafe fn alarm (unsigned int seconds
109 // pub unsafe fn setitimer (int which, struct __kernel_old_itimerval *value, struct __kernel_old_itimerval *ovalue);
110
111 /// getpid() returns the process ID (PID) of the calling process.
112 /// (This is often used by routines that generate unique temporary
113 /// filenames.)<br>
114 /// #### RETURN VALUE
115 /// getpid() returns the process ID (PID) of the calling process
116 /// #### ERRORS
117 /// These functions are always successful.
118 /// #### Link
119 /// Read the docs
120 /// [here](https://man7.org/linux/man-pages/man2/getpid.2.html)
121 pub unsafe fn getpid() -> pid_t;
122
123 // pub unsafe fn sendfile64 (int out_fd, int in_fd, loff_t *offset, size_t count);
124 pub unsafe fn socket(family: c_int, _type: c_int, protocol: c_int) -> c_int;
125 pub unsafe fn connect(fd: c_int,uservaddr: *mut sockaddr, addrlen: c_int) -> c_int;
126 pub unsafe fn accept(fd: c_int, upeer_sockaddr: *mut sockaddr, upeer_addrlen: *mut c_int) -> c_int;
127 // pub unsafe fn sendto (NET int fd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len);
128 // pub unsafe fn recvfrom (NET int fd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len);
129 // pub unsafe fn sendmsg (NET int fd, struct user_msghdr *msg, unsigned int flags);
130 // pub unsafe fn recvmsg (NET int fd, struct user_msghdr *msg, unsigned int flags);
131 // pub unsafe fn shutdown (NET int fd, int how);
132 pub unsafe fn bind(fd: c_int, umyaddr: *mut sockaddr, addrlen: c_int) -> c_int;
133 pub unsafe fn listen(fd: c_int, backlog: c_int) -> c_int;
134 // pub unsafe fn getsockname (NET int fd, struct sockaddr *usockaddr, int *usockaddr_len);
135 // pub unsafe fn getpeername (NET int fd, struct sockaddr *usockaddr, int *usockaddr_len);
136 // pub unsafe fn socketpair (NET int family, int type, int protocol, int *usockvec);
137 // pub unsafe fn setsockopt (NET int fd, int level, int optname, char *optval, int optlen);
138 // pub unsafe fn getsockopt (NET int fd, int level, int optname, char *optval, int *optlen);
139 // pub unsafe fn clone (unsigned long clone_flags, unsigned long newsp, int *parent_tidptr, int *child_tidptr, unsigned long tls);
140
141 /// fork() creates a new process by duplicating the calling process.
142 /// The new process is referred to as the child process. The calling
143 /// process is referred to as the parent process.
144 /// #### RETURN VALUE
145 /// On success, the PID of the child process is returned in the
146 /// parent, and 0 is returned in the child. On failure, -1 is
147 /// returned in the parent, no child process is created, and errno is
148 /// set to indicate the error.
149 /// #### ERRORS
150 /// EAGAIN(35), ENOMEM(12), ENOSYS(78), ERESTARTNOINTR(513), etc.
151 /// #### Link
152 /// Read the docs
153 /// [here](https://man7.org/linux/man-pages/man2/fork.2.html)
154 pub unsafe fn fork() -> pid_t;
155
156 /// vfork - create a child process and block parent
157 /// #### Link
158 /// Read the docs
159 /// [here](https://man7.org/linux/man-pages/man2/vfork.2.html)
160 pub unsafe fn vfork() -> pid_t;
161
162 pub unsafe fn execve(filename: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> c_int;
163
164 /// exit() terminates the calling process "immediately".
165 /// #### RETURN VALUE
166 /// These functions do not return.
167 /// #### Link
168 /// Read the docs
169 /// [here](https://man7.org/linux/man-pages/man3/exit.3.html)
170 pub unsafe fn exit(error_code: c_int);
171
172 // pub unsafe fn wait4 (pid_t upid, int *stat_addr, int options, struct rusage *ru);
173
174 /// The kill() system call can be used to send any signal to any
175 /// process group or process.
176 /// #### RETURN VALUE
177 /// On success (at least one signal was sent), zero is returned. On
178 /// error, -1 is returned, and errno is set to indicate the error.
179 /// #### ERRORS
180 /// EINVAL(22), EPERM(1), ESRCH(3).
181 /// #### Link
182 /// Read the docs
183 /// [here](https://man7.org/linux/man-pages/man2/kill.2.html)
184 pub unsafe fn kill(pid: pid_t, sig: c_int) -> c_int;
185
186
187 // pub unsafe fn newuname ( struct new_utsname *name);
188 // pub unsafe fn semget (SYSVIPC key_t key, int nsems, int semflg);
189 // pub unsafe fn semop (SYSVIPC int semid, struct sembuf *tsops, unsigned nsops);
190 // pub unsafe fn semctl (SYSVIPC int semid, int semnum, int cmd, unsigned long arg);
191 // pub unsafe fn shmdt (SYSVIPC char *shmaddr);
192 // pub unsafe fn msgget (SYSVIPC key_t key, int msgflg);
193 // pub unsafe fn msgsnd (SYSVIPC int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
194 // pub unsafe fn msgrcv (SYSVIPC int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
195 // pub unsafe fn msgctl (SYSVIPC int msqid, int cmd, struct msqid_ds *buf);
196
197 /// fcntl() performs one of the operations described below on the open
198 /// file descriptor fd. The operation is determined by op.
199 /// #### RETURN VALUE
200 /// For a successful call, the return value depends on the operation.
201 /// On error, -1 is returned, and errno is set to indicate the error.
202 /// #### ERRORS
203 /// EACCES(13), EAGAIN(11), EBADF(9), EINVAL(22).
204 /// #### Link
205 /// Read the docs
206 /// [here](https://man7.org/linux/man-pages/man2/fcntl.2.html)
207 pub unsafe fn fcntl(fd: c_uint, cmd: c_uint, arg: c_uint) -> c_long;
208
209 pub unsafe fn flock(fd: c_uint, cmd: c_uint) -> c_int;
210
211 /// fsync() transfers ("flushes") all modified in-core data of (i.e.,
212 /// modified buffer cache pages for) the file referred to by the file
213 /// descriptor fd to the disk device (or other permanent storage
214 /// device) so that all changed information can be retrieved even if
215 /// the system crashes or is rebooted. This includes writing through
216 /// or flushing a disk cache if present. The call blocks until the
217 /// device reports that the transfer has completed.
218 /// #### RETURN VALUE
219 /// On success, these system calls return zero. On error, -1 is
220 /// returned, and errno is set to indicate the error.
221 /// #### Link
222 /// Read the docs
223 /// [here](https://man7.org/linux/man-pages/man2/fsync.2.html)
224 pub unsafe fn fsync(fd: c_uint) -> c_int;
225
226 /// fdatasync() is similar to fsync(), but does not flush modified
227 /// metadata unless that metadata is needed in order to allow a
228 /// subsequent data retrieval to be correctly handled. For example,
229 /// changes to st_atime or st_mtime (respectively, time of last access
230 /// and time of last modification; see inode(7)) do not require
231 /// flushing because they are not necessary for a subsequent data read
232 /// to be handled correctly. On the other hand, a change to the file
233 /// size (st_size, as made by say ftruncate(2)), would require a
234 /// metadata flush.
235 /// #### RETURN VALUE
236 /// On success, these system calls return zero. On error, -1 is
237 /// returned, and errno is set to indicate the error.
238 /// #### Link
239 /// Read the docs
240 /// [here](https://man7.org/linux/man-pages/man2/fsync.2.html)
241 pub unsafe fn fdatasync(fd: c_uint) -> c_int;
242
243 pub unsafe fn truncate(path: *const c_char, length: c_long) -> c_long;
244 pub unsafe fn ftruncate(fd: c_uint, length: off_t) -> c_long;
245
246 // pub unsafe fn getdents(unsigned int fd, struct linux_dirent *dirent, unsigned int count);
247
248 /// The getcwd() function copies an absolute pathname of the current
249 /// working directory to the array pointed to by buf, which is of
250 /// length size.
251 /// #### RETURN VALUE
252 /// On success, these functions return a pointer to a string
253 /// containing the pathname of the current working directory. In the
254 /// case of getcwd() and getwd() this is the same value as buf.
255 ///
256 /// On failure, these functions return NULL, and errno is set to
257 /// indicate the error. The contents of the array pointed to by buf
258 /// are undefined on error.
259 /// #### Link
260 /// Read the docs
261 /// [here](https://man7.org/linux/man-pages/man3/getcwd.3.html)
262 pub unsafe fn getcwd(buf: *mut c_char, size: c_ulong) -> c_int;
263
264 /// chdir() changes the current working directory of the calling
265 /// process to the directory specified in path.
266 /// #### RETURN VALUE
267 /// On success, zero is returned. On error, -1 is returned, and errno
268 /// is set to indicate the error.
269 /// #### Link
270 /// Read the docs
271 /// [here](https://man7.org/linux/man-pages/man2/chdir.2.html)
272 pub unsafe fn chdir(filename: *const c_char) -> c_int;
273
274
275 /// fchdir() is identical to chdir(); the only difference is that the
276 /// directory is given as an open file descriptor.
277 /// #### RETURN VALUE
278 /// On success, zero is returned. On error, -1 is returned, and errno
279 /// is set to indicate the error.
280 /// #### Link
281 /// Read the docs
282 /// [here](https://man7.org/linux/man-pages/man2/chdir.2.html)
283 pub unsafe fn fchdir(fd: c_uint) -> c_int;
284
285 /// rename() renames a file, moving it between directories if
286 /// required. Any other hard links to the file (as created using
287 /// link(2)) are unaffected. Open file descriptors for oldpath are
288 /// also unaffected.
289 /// #### RETURN VALUE
290 /// On success, zero is returned. On error, -1 is returned, and errno
291 /// is set to indicate the error.
292 /// #### Link
293 /// Read the docs
294 /// [here](https://man7.org/linux/man-pages/man2/renameat.2.html)
295 pub unsafe fn rename(oldname: *const c_char, newname: *const c_char) -> c_uint;
296
297 /// mkdir() attempts to create a directory named path.
298 /// #### RETURN VALUE
299 /// mkdir() return zero on success. On error, -1 is
300 /// returned and errno is set to indicate the error.
301 /// #### Link
302 /// Read the docs
303 /// [here](https://man7.org/linux/man-pages/man2/mkdir.2.html)
304 pub unsafe fn mkdir(pathname: *const c_char, mode: umode_t) -> c_int;
305
306 pub unsafe fn rmdir(pathname: *const c_char) -> c_int;
307 pub unsafe fn creat(pathname: *const c_char, mode: umode_t) -> c_long;
308 pub unsafe fn link(oldname: *const c_char, newname: *const c_char) -> c_int;
309 pub unsafe fn unlink(pathname: *const c_char) -> c_int;
310 pub unsafe fn symlink(oldname: *const c_char, newname: *const c_char) -> c_int;
311 pub unsafe fn readlink(path: *const c_char, buf: *mut c_char, bufsiz: c_int) -> c_int;
312 pub unsafe fn chmod(filename: *const c_char, mode: umode_t) -> c_int;
313 pub unsafe fn fchmod(fd: c_int, mode: umode_t) -> c_int;
314 pub unsafe fn chown(filename: *const c_char, user: uid_t, group: gid_t) -> c_int;
315 // pub unsafe fn fchown (unsigned int fd, uid_t user, gid_t group);
316 // pub unsafe fn lchown (const char *filename, uid_t user, gid_t group);
317 pub unsafe fn umask (mask: c_int) -> c_int;
318 // pub unsafe fn gettimeofday (struct __kernel_old_timeval *tv, struct timezone *tz);
319 // pub unsafe fn getrlimit (unsigned int resource, struct rlimit *rlim);
320 // pub unsafe fn getrusage (int who, struct rusage *ru);
321 // pub unsafe fn sysinfo (struct sysinfo *info);
322 // pub unsafe fn times (struct tms *tbuf);
323 // pub unsafe fn ptrace (long request, long pid, unsigned long addr, unsigned long data);
324 pub unsafe fn getuid() -> uid_t;
325 pub unsafe fn syslog(_type: c_int, buf: *mut c_char, len: c_int) -> c_int;
326 pub unsafe fn getgid() -> uid_t;
327 pub unsafe fn setuid(uid: uid_t) -> c_long;
328 pub unsafe fn setgid(gid: gid_t) -> c_long;
329 pub unsafe fn geteuid() -> uid_t;
330 pub unsafe fn getegid() -> uid_t;
331 pub unsafe fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
332 pub unsafe fn getppid() -> c_int;
333 pub unsafe fn getpgrp() -> c_int;
334 pub unsafe fn setsid() -> c_int;
335 // pub unsafe fn setreuid (MULTIUSER uid_t ruid, uid_t euid);
336 // pub unsafe fn setregid (MULTIUSER gid_t rgid, gid_t egid);
337 // pub unsafe fn getgroups (MULTIUSER int gidsetsize, gid_t *grouplist);
338 // pub unsafe fn setgroups (MULTIUSER int gidsetsize, gid_t *grouplist);
339 // pub unsafe fn setresuid (MULTIUSER uid_t ruid, uid_t euid, uid_t suid);
340 // pub unsafe fn getresuid (MULTIUSER uid_t *ruidp, uid_t *euidp, uid_t *suidp);
341 // pub unsafe fn setresgid (MULTIUSER gid_t rgid, gid_t egid, gid_t sgid);
342 // pub unsafe fn getresgid (MULTIUSER gid_t *rgidp, gid_t *egidp, gid_t *sgidp);
343 // pub unsafe fn getpgid (pid_t pid);
344 // pub unsafe fn setfsuid (MULTIUSER uid_t uid);
345 // pub unsafe fn setfsgid (MULTIUSER gid_t gid);
346 // pub unsafe fn getsid (pid_t pid);
347 // pub unsafe fn capget (MULTIUSER cap_user_header_t header, cap_user_data_t dataptr);
348 // pub unsafe fn capset (MULTIUSER cap_user_header_t header, const cap_user_data_t data);
349 // pub unsafe fn rt_sigpending (sigset_t *uset, size_t sigsetsize);
350 // pub unsafe fn rt_sigtimedwait (const sigset_t *uthese, siginfo_t *uinfo, const struct __kernel_timespec *uts, size_t sigsetsize);
351
352 // pub unsafe fn rt_sigsuspend (sigset_t *unewset, size_t sigsetsize);
353 // pub unsafe fn rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *uinfo);
354 // pub unsafe fn sigaltstack (const stack_t *uss, stack_t *uoss);
355 // pub unsafe fn utime (char *filename, struct utimbuf *times);
356 // pub unsafe fn mknod (const char *filename, umode_t mode, unsigned dev);
357 // pub unsafe fn personality (unsigned int personality);
358 // pub unsafe fn ustat (unsigned dev, struct ustat *ubuf);
359 // pub unsafe fn statfs (const char *pathname, struct statfs *buf);
360 // pub unsafe fn fstatfs (unsigned int fd, struct statfs *buf);
361 // pub unsafe fn sysfs (SYSFS_SYSCALL int option, unsigned long arg1, unsigned long arg2);
362 // pub unsafe fn getpriority (int which, int who);
363 // pub unsafe fn setpriority (int which, int who, int niceval);
364 // pub unsafe fn sched_setparam (pid_t pid, struct sched_param *param);
365 // pub unsafe fn sched_getparam (pid_t pid, struct sched_param *param);
366 // pub unsafe fn sched_setscheduler (pid_t pid, int policy, struct sched_param *param);
367 // pub unsafe fn sched_getscheduler (pid_t pid);
368 // pub unsafe fn sched_get_priority_max (int policy);
369 // pub unsafe fn sched_get_priority_min (int policy);
370 // pub unsafe fn sched_rr_get_interval ( pid_t pid, struct __kernel_timespec *interval);
371 // pub unsafe fn mlock ( MMU unsigned long start, size_t len);
372 // pub unsafe fn munlock ( MMU unsigned long start, size_t len);
373 // pub unsafe fn mlockall ( MMU int flags);
374 // pub unsafe fn munlockall ( MMU void);
375 // pub unsafe fn vhangup ( void);
376 // pub unsafe fn modify_ldt ( MODIFY_LDT_SYSCALL int func, void *ptr, unsigned long bytecount);
377 // pub unsafe fn pivot_root ( const char *new_root, const char *put_old);
378 // pub unsafe fn prctl ( int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5);
379 // pub unsafe fn arch_prctl ( int option, unsigned long arg2);
380 // pub unsafe fn adjtimex ( struct __kernel_timex *txc_p);
381 // pub unsafe fn setrlimit ( unsigned int resource, struct rlimit *rlim);
382 // pub unsafe fn chroot ( const char *filename);
383 // pub unsafe fn sync ( void);
384 // pub unsafe fn acct ( BSD_PROCESS_ACCT const char *name);
385 // pub unsafe fn settimeofday ( struct __kernel_old_timeval *tv, struct timezone *tz);
386 pub unsafe fn mount(dev_name: *mut c_char, dir_name: *mut c_char, _type: *mut c_char, flags: c_ulong, data: *mut c_void) -> c_int;
387 pub unsafe fn umount(name: *mut c_char, flags: c_int) -> c_int;
388 pub unsafe fn swapon(specialfile: *const c_char, swap_flags: c_int) -> c_int;
389 pub unsafe fn swapoff(specialfile: *const c_char);
390 // pub unsafe fn reboot ( int magic1, int magic2, unsigned int cmd, void *arg);
391 // pub unsafe fn sethostname (char *name, int len);
392 // pub unsafe fn setdomainname( char *name, int len);
393 // pub unsafe fn statmount ( const struct mnt_id_req *req, struct statmount *buf, size_t bufsize, unsigned int flags);
394 // pub unsafe fn listmount ( const struct mnt_id_req *req, u64 *mnt_ids, size_t nr_mnt_ids, unsigned int flags);
395 // pub unsafe fn lsm_get_self_attr ( SECURITY unsigned int attr, struct lsm_ctx *ctx, u32 *size, u32 flags);
396 // pub unsafe fn lsm_set_self_attr ( SECURITY unsigned int attr, struct lsm_ctx *ctx, u32 size, u32 flags);
397 // pub unsafe fn lsm_list_modules ( SECURITY u64 *ids, u32 *size, u32 flags);
398 // pub unsafe fn mseal ( unsigned long start, size_t len, unsigned long flags);
399 // pub unsafe fn setxattrat ( int dfd, const char *pathname, unsigned int at_flags, const char *name, const struct xattr_args *uargs, size_t usize);
400 // pub unsafe fn getxattrat ( int dfd, const char *pathname, unsigned int at_flags, const char *name, struct xattr_args *uargs, size_t usize);
401 // pub unsafe fn listxattrat ( int dfd, const char *pathname, unsigned int at_flags, char *list, size_t size);
402 // pub unsafe fn removexattrat ( int dfd, const char *pathname, unsigned int at_flags, const char *name);
403 // pub unsafe fn iopl ( X86_IOPL_IOPERM unsigned int level);
404 // pub unsafe fn ioperm ( X86_IOPL_IOPERM unsigned long from, unsigned long num, int turn_on);
405 // pub unsafe fn init_module ( MODULES void *umod, unsigned long len, const char *uargs);
406 // pub unsafe fn delete_module ( MODULE_UNLOAD const char *name_user, unsigned int flags);
407 // pub unsafe fn quotactl ( QUOTACTL unsigned int cmd, const char *special, qid_t id, void *addr);
408 // pub unsafe fn gettid ( void);
409 // pub unsafe fn readahead ( int fd, loff_t offset, size_t count);
410 // pub unsafe fn setxattr ( const char *pathname, const char *name, const void *value, size_t size, int flags);
411 // pub unsafe fn lsetxattr ( const char *pathname, const char *name, const void *value, size_t size, int flags);
412 // pub unsafe fn fsetxattr ( int fd, const char *name, const void *value, size_t size, int flags);
413 // pub unsafe fn getxattr ( const char *pathname, const char *name, void *value, size_t size);
414 // pub unsafe fn lgetxattr ( const char *pathname, const char *name, void *value, size_t size);
415 // pub unsafe fn fgetxattr ( int fd, const char *name, void *value, size_t size);
416 // pub unsafe fn listxattr ( const char *pathname, char *list, size_t size);
417 // pub unsafe fn llistxattr ( const char *pathname, char *list, size_t size);
418 // pub unsafe fn flistxattr ( int fd, char *list, size_t size);
419 // pub unsafe fn removexattr ( const char *pathname, const char *name);
420 // pub unsafe fn lremovexattr ( const char *pathname, const char *name);
421 // pub unsafe fn fremovexattr ( int fd, const char *name);
422 // pub unsafe fn tkill ( pid_t pid, int sig);
423 // pub unsafe fn time ( __kernel_old_time_t *tloc);
424 // pub unsafe fn futex ( FUTEX u32 *uaddr, int op, u32 val, const struct __kernel_timespec *utime, u32 *uaddr2, u32 val3);
425 // pub unsafe fn sched_setaffinity( pid_t pid, unsigned int len, unsigned long *user_mask_ptr);
426 // pub unsafe fn sched_getaffinity ( pid_t pid, unsigned int len, unsigned long *user_mask_ptr);
427 // pub unsafe fn io_setup ( AIO unsigned nr_events, aio_context_t *ctxp);
428 // pub unsafe fn io_destroy ( AIO aio_context_t ctx);
429 // pub unsafe fn io_getevents ( AIO aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct __kernel_timespec *timeout);
430 // pub unsafe fn io_submit ( AIO aio_context_t ctx_id, long nr, struct iocb **iocbpp);
431 // pub unsafe fn io_cancel ( AIO aio_context_t ctx_id, struct iocb *iocb, struct io_event *result);
432 // pub unsafe fn epoll_create ( EPOLL int size
433 // pub unsafe fn remap_file_pages ( MMU unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags);
434 // pub unsafe fn getdents64 ( unsigned int fd, struct linux_dirent64 *dirent, unsigned int count);
435 // pub unsafe fn set_tid_address ( int *tidptr);
436 // pub unsafe fn restart_syscall ( void);
437 // pub unsafe fn semtimedop ( SYSVIPC int semid, struct sembuf *tsops, unsigned int nsops, const struct __kernel_timespec *timeout);
438 // pub unsafe fn fadvise64 ( ADVISE_SYSCALLS int fd, loff_t offset, size_t len, int advice);
439 // pub unsafe fn timer_create ( const clockid_t which_clock, struct sigevent *timer_event_spec, timer_t *created_timer_id);
440 // pub unsafe fn timer_settime ( timer_t timer_id, int flags, const struct __kernel_itimerspec *new_setting, struct __kernel_itimerspec *old_setting);
441 // pub unsafe fn timer_gettime ( timer_t timer_id, struct __kernel_itimerspec *setting);
442 // pub unsafe fn timer_getoverrun ( timer_t timer_id);
443 // pub unsafe fn timer_delete ( timer_t timer_id);
444
445 // pub unsafe fn clock_settime ( const clockid_t which_clock, const struct __kernel_timespec *tp);
446 // pub unsafe fn clock_gettime( const clockid_t which_clock, struct __kernel_timespec *tp);
447 // pub unsafe fn clock_getres ( const clockid_t which_clock, struct __kernel_timespec *tp);
448 // pub unsafe fn clock_nanosleep ( const clockid_t which_clock, int flags, const struct __kernel_timespec *rqtp, struct __kernel_timespec *rmtp);
449 // pub unsafe fn exit_group ( int error_code);
450 // pub unsafe fn epoll_wait ( EPOLL int epfd, struct epoll_event *events, int maxevents, int timeout);
451 // pub unsafe fn epoll_ctl ( EPOLL int epfd, int op, int fd, struct epoll_event *event);
452 // pub unsafe fn tgkill ( pid_t tgid, pid_t pid, int sig);
453 // pub unsafe fn utimes ( char *filename, struct __kernel_old_timeval *utimes);
454 // pub unsafe fn mbind ( NUMA unsigned long start, unsigned long len, unsigned long mode, const unsigned long *nmask, unsigned long maxnode, unsigned int flags);
455 // pub unsafe fn set_mempolicy ( NUMA int mode, const unsigned long *nmask, unsigned long maxnode);
456 // pub unsafe fn get_mempolicy( NUMA int *policy, unsigned long *nmask, unsigned long maxnode, unsigned long addr, unsigned long flags);
457 // pub unsafe fn mq_open ( POSIX_MQUEUE const char *u_name, int oflag, umode_t mode, struct mq_attr *u_attr);
458 // pub unsafe fn mq_unlink ( POSIX_MQUEUE const char *u_name);
459 // pub unsafe fn mq_timedsend ( POSIX_MQUEUE mqd_t mqdes, const char *u_msg_ptr, size_t msg_len, unsigned int msg_prio, const struct __kernel_timespec *u_abs_timeout);
460 // pub unsafe fn mq_timedreceive ( POSIX_MQUEUE mqd_t mqdes, char *u_msg_ptr, size_t msg_len, unsigned int *u_msg_prio, const struct __kernel_timespec *u_abs_timeout);
461 // pub unsafe fn mq_notify ( POSIX_MQUEUE mqd_t mqdes, const struct sigevent *u_notification);
462 // pub unsafe fn mq_getsetattr ( POSIX_MQUEUE mqd_t mqdes, const struct mq_attr *u_mqstat, struct mq_attr *u_omqstat);
463 // pub unsafe fn kexec_load ( KEXEC unsigned long entry, unsigned long nr_segments, struct kexec_segment *segments, unsigned long flags);
464 // pub unsafe fn waitid ( int which, pid_t upid, struct siginfo *infop, int options, struct rusage *ru);
465 // pub unsafe fn add_key ( KEYS const char *_type, const char *_description, const void *_payload, size_t plen, key_serial_t ringid);
466 // pub unsafe fn request_key ( KEYS const char *_type, const char *_description, const char *_callout_info, key_serial_t destringid);
467 // pub unsafe fn keyctl ( KEYS int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5);
468 // pub unsafe fn ioprio_set ( BLOCK int which, int who, int ioprio);
469 // pub unsafe fn ioprio_get ( BLOCK int which, int who);
470 // pub unsafe fn inotify_init ( INOTIFY_USER void);
471 // pub unsafe fn inotify_add_watch ( INOTIFY_USER int fd, const char *pathname, u32 mask);
472 // pub unsafe fn inotify_rm_watch ( INOTIFY_USER int fd, __s32 wd);
473
474 // pub unsafe fn migrate_pages ( MIGRATION pid_t pid, unsigned long maxnode, const unsigned long *old_nodes, const unsigned long *new_nodes);
475 // pub unsafe fn openat ( int dfd, const char *filename, int flags, umode_t mode);
476 // pub unsafe fn mkdirat ( int dfd, const char *pathname, umode_t mode);
477 // pub unsafe fn mknodat ( int dfd, const char *filename, umode_t mode, unsigned int dev);
478 // pub unsafe fn fchownat ( int dfd, const char *filename, uid_t user, gid_t group, int flag);
479 // pub unsafe fn futimesat ( int dfd, const char *filename, struct __kernel_old_timeval *utimes);
480 // pub unsafe fn newfstatat ( int dfd, const char *filename, struct stat *statbuf, int flag);
481 // pub unsafe fn unlinkat ( int dfd, const char *pathname, int flag);
482 // pub unsafe fn renameat ( int olddfd, const char *oldname, int newdfd, const char *newname);
483 // pub unsafe fn linkat ( int olddfd, const char *oldname, int newdfd, const char *newname, int flags);
484 // pub unsafe fn symlinkat ( const char *oldname, int newdfd, const char *newname);
485 // pub unsafe fn readlinkat ( int dfd, const char *pathname, char *buf, int bufsiz);
486 // pub unsafe fn fchmodat ( int dfd, const char *filename, umode_t mode);
487 // pub unsafe fn faccessat ( int dfd, const char *filename, int mode);
488 // pub unsafe fn pselect6 ( int n, fd_set *inp, fd_set *outp, fd_set *exp, struct __kernel_timespec *tsp, void *sig);
489 // pub unsafe fn ppoll ( struct pollfd *ufds, unsigned int nfds, struct __kernel_timespec *tsp, const sigset_t *sigmask, size_t sigsetsize);
490 // pub unsafe fn unshare ( unsigned long unshare_flags);
491 // pub unsafe fn set_robust_list ( FUTEX struct robust_list_head *head, size_t len);
492 // pub unsafe fn get_robust_list ( FUTEX int pid, struct robust_list_head **head_ptr, size_t *len_ptr);
493 // pub unsafe fn splice ( int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags);
494 // pub unsafe fn tee ( int fdin, int fdout, size_t len, unsigned int flags);
495 // pub unsafe fn sync_file_range ( int fd, loff_t offset, loff_t nbytes, unsigned int flags);
496 // pub unsafe fn vmsplice ( int fd, const struct iovec *uiov, unsigned long nr_segs, unsigned int flags);
497 // pub unsafe fn move_pages ( MIGRATION pid_t pid, unsigned long nr_pages, const void **pages, const int *nodes, int *status, int flags);
498 // pub unsafe fn utimensat ( int dfd, const char *filename, struct __kernel_timespec *utimes, int flags);
499 // pub unsafe fn epoll_pwait ( EPOLL int epfd, struct epoll_event *events, int maxevents, int timeout, const sigset_t *sigmask, size_t sigsetsize);
500 // pub unsafe fn signalfd ( SIGNALFD int ufd, sigset_t *user_mask, size_t sizemask);
501 // pub unsafe fn timerfd_create ( int clockid, int flags);
502 // pub unsafe fn eventfd ( unsigned int count);
503 // pub unsafe fn fallocate ( int fd, int mode, loff_t offset, loff_t len);
504 // pub unsafe fn timerfd_settime ( int ufd, int flags, const struct __kernel_itimerspec *utmr, struct __kernel_itimerspec *otmr);
505 // pub unsafe fn timerfd_gettime ( int ufd, struct __kernel_itimerspec *otmr);
506 // pub unsafe fn accept4 ( NET int fd, struct sockaddr *upeer_sockaddr, int *upeer_addrlen, int flags);
507 // pub unsafe fn signalfd4 ( SIGNALFD int ufd, sigset_t *user_mask, size_t sizemask, int flags);
508 // pub unsafe fn eventfd2 ( unsigned int count, int flags);
509 // pub unsafe fn epoll_create1 ( EPOLL int flags);
510 // pub unsafe fn dup3 ( unsigned int oldfd, unsigned int newfd, int flags);
511 // pub unsafe fn pipe2 ( int *fildes, int flags);
512 // pub unsafe fn inotify_init1 ( INOTIFY_USER int flags);
513 // pub unsafe fn preadv ( unsigned long fd, const struct iovec *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h);
514 // pub unsafe fn pwritev ( unsigned long fd, const struct iovec *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h);
515 // pub unsafe fn rt_tgsigqueueinfo( pid_t tgid, pid_t pid, int sig, siginfo_t *uinfo);
516 // pub unsafe fn perf_event_open ( PERF_EVENTS struct perf_event_attr *attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags);
517 // pub unsafe fn recvmmsg ( NET int fd, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct __kernel_timespec *timeout);
518 // pub unsafe fn fanotify_init ( FANOTIFY unsigned int flags, unsigned int event_f_flags);
519 // pub unsafe fn fanotify_mark ( FANOTIFY int fanotify_fd, unsigned int flags, __u64 mask, int dfd, const char *pathname);
520 // pub unsafe fn prlimit64 ( pid_t pid, unsigned int resource, const struct rlimit64 *new_rlim, struct rlimit64 *old_rlim);
521 // pub unsafe fn name_to_handle_at ( FHANDLE int dfd, const char *name, struct file_handle *handle, void *mnt_id, int flag);
522 // pub unsafe fn open_by_handle_at ( FHANDLE int mountdirfd, struct file_handle *handle, int flags);
523 // pub unsafe fn clock_adjtime ( const clockid_t which_clock, struct __kernel_timex *utx);
524
525 /// syncfs() is like sync(), but synchronizes just the filesystem
526 /// containing file referred to by the open file descriptor fd.
527 pub unsafe fn syncfs(fd: c_int);
528
529 // pub unsafe fn sendmmsg ( NET int fd, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags);
530 // pub unsafe fn setns ( int fd, int flags);
531 // pub unsafe fn getcpu ( unsigned *cpup, unsigned *nodep, struct getcpu_cache *unused);
532 // pub unsafe fn process_vm_readv ( CROSS_MEMORY_ATTACH pid_t pid, const struct iovec *lvec, unsigned long liovcnt, const struct iovec *rvec, unsigned long riovcnt, unsigned long flags);
533 // pub unsafe fn process_vm_writev ( CROSS_MEMORY_ATTACH pid_t pid, const struct iovec *lvec, unsigned long liovcnt, const struct iovec *rvec, unsigned long riovcnt, unsigned long flags);
534 // pub unsafe fn kcmp ( KCMP pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2);
535 // pub unsafe fn finit_module ( MODULES int fd, const char *uargs, int flags);
536 // pub unsafe fn sched_setattr ( pid_t pid, struct sched_attr *uattr, unsigned int flags);
537 // pub unsafe fn sched_getattr ( pid_t pid, struct sched_attr *uattr, unsigned int usize, unsigned int flags);
538 // pub unsafe fn renameat2 ( int olddfd, const char *oldname, int newdfd, const char *newname, unsigned int flags);
539 // pub unsafe fn seccomp ( SECCOMP unsigned int op, unsigned int flags, void *uargs);
540 // pub unsafe fn getrandom ( char *ubuf, size_t len, unsigned int flags);
541 // pub unsafe fn memfd_create ( MEMFD_CREATE const char *uname, unsigned int flags);
542 // pub unsafe fn kexec_file_load ( KEXEC_FILE int kernel_fd, int initrd_fd, unsigned long cmdline_len, const char *cmdline_ptr, unsigned long flags);
543 // pub unsafe fn bpf ( BPF_SYSCALL int cmd, union bpf_attr *uattr, unsigned int size);
544 // pub unsafe fn execveat ( int fd, const char *filename, const char *const *argv, const char *const *envp, int flags);
545 // pub unsafe fn userfaultfd ( USERFAULTFD int flags);
546 // pub unsafe fn membarrier ( MEMBARRIER int cmd, unsigned int flags, int cpu_id);
547 // pub unsafe fn mlock2 ( MMU unsigned long start, size_t len, int flags);
548 // pub unsafe fn copy_file_range ( int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags);
549 // pub unsafe fn preadv2 ( unsigned long fd, const struct iovec *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h, rwf_t flags);
550 // pub unsafe fn pwritev2 ( unsigned long fd, const struct iovec *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h, rwf_t flags);
551 // pub unsafe fn pkey_mprotect ( X86_INTEL_MEMORY_PROTECTION_KEYS unsigned long start, size_t len, unsigned long prot, int pkey);
552 // pub unsafe fn pkey_alloc ( X86_INTEL_MEMORY_PROTECTION_KEYS unsigned long flags, unsigned long init_val);
553 // pub unsafe fn pkey_free ( X86_INTEL_MEMORY_PROTECTION_KEYS int pkey);
554 // pub unsafe fn statx ( int dfd, const char *filename, unsigned flags, unsigned int mask, struct statx *buffer);
555 // pub unsafe fn io_pgetevents ( AIO aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct __kernel_timespec *timeout, const struct __aio_sigset *usig);
556 // pub unsafe fn rseq ( RSEQ struct rseq *rseq, u32 rseq_len, int flags, u32 sig);
557 // pub unsafe fn uretprobe ( void);
558 // pub unsafe fn pidfd_send_signal ( int pidfd, int sig, siginfo_t *info, unsigned int flags);
559 // pub unsafe fn io_uring_setup ( IO_URING u32 entries, struct io_uring_params *params);
560 // pub unsafe fn io_uring_enter ( IO_URING unsigned int fd, u32 to_submit, u32 min_complete, u32 flags, const void *argp, size_t argsz);
561 // pub unsafe fn io_uring_register ( IO_URING unsigned int fd, unsigned int opcode, void *arg, unsigned int nr_args);
562 // pub unsafe fn open_tree ( int dfd, const char *filename, unsigned flags);
563 // pub unsafe fn move_mount ( int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, unsigned int flags);
564 // pub unsafe fn fsopen ( const char *_fs_name, unsigned int flags);
565 // pub unsafe fn fsconfig( int fd, unsigned int cmd, const char *_key, const void *_value, int aux);
566 // pub unsafe fn fsmount ( int fs_fd, unsigned int flags, unsigned int attr_flags);
567 // pub unsafe fn fspick ( int dfd, const char *path, unsigned int flags);
568 // pub unsafe fn pidfd_open ( pid_t pid, unsigned int flags);
569 // pub unsafe fn clone3 ( struct clone_args *uargs, size_t size);
570 // pub unsafe fn close_range ( unsigned int fd, unsigned int max_fd, unsigned int flags);
571 // pub unsafe fn openat2 ( int dfd, const char *filename, struct open_how *how, size_t usize);
572 // pub unsafe fn pidfd_getfd ( int pidfd, int fd, unsigned int flags);
573 // pub unsafe fn faccessat2 ( int dfd, const char *filename, int mode, int flags);
574 // pub unsafe fn process_madvise ( ADVISE_SYSCALLS int pidfd, const struct iovec *vec, size_t vlen, int behavior, unsigned int flags);
575 // pub unsafe fn epoll_pwait2 ( EPOLL int epfd, struct epoll_event *events, int maxevents, const struct __kernel_timespec *timeout, const sigset_t *sigmask, size_t sigsetsize);
576 // pub unsafe fn mount_setattr ( int dfd, const char *path, unsigned int flags, struct mount_attr *uattr, size_t usize);
577 // pub unsafe fn quotactl_fd ( QUOTACTL unsigned int fd, unsigned int cmd, qid_t id, void *addr);
578 // pub unsafe fn landlock_create_ruleset ( SECURITY_LANDLOCK const struct landlock_ruleset_attr *const attr, const size_t size, const __u32 flags);
579 // pub unsafe fn landlock_add_rule ( SECURITY_LANDLOCK const int ruleset_fd, const enum landlock_rule_type rule_type, const void *const rule_attr, const __u32 flags);
580 // pub unsafe fn landlock_restrict_self ( SECURITY_LANDLOCK const int ruleset_fd, const __u32 flags);
581 // pub unsafe fn memfd_secret ( SECRETMEM unsigned int flags);
582 // pub unsafe fn process_mrelease ( MMU int pidfd, unsigned int flags);
583 // pub unsafe fn futex_waitv ( FUTEX struct futex_waitv *waiters, unsigned int nr_futexes, unsigned int flags, struct __kernel_timespec *timeout, clockid_t clockid);
584 // pub unsafe fn set_mempolicy_home_node ( NUMA unsigned long start, unsigned long len, unsigned long home_node, unsigned long flags);
585 // pub unsafe fn cachestat ( CACHESTAT_SYSCALL unsigned int fd, struct cachestat_range *cstat_range, struct cachestat *cstat, unsigned int flags);
586 // pub unsafe fn fchmodat2 ( int dfd, const char *filename, umode_t mode, unsigned int flags);
587 // pub unsafe fn map_shadow_stack ( X86_USER_SHADOW_STACK unsigned long addr, unsigned long size, unsigned int flags);
588 // pub unsafe fn futex_wake ( FUTEX void *uaddr, unsigned long mask, int nr, unsigned int flags);
589 // pub unsafe fn futex_wait ( FUTEX void *uaddr, unsigned long val, unsigned long mask, unsigned int flags, struct __kernel_timespec *timeout, clockid_t clockid);
590 // pub unsafe fn futex_requeue ( FUTEX struct futex_waitv *waiters, unsigned int flags, int nr_wake, int nr_requeue);
591}
592
593
594
595
596
597
598