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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! System Call API
//!
//! This module provides symbols for all available system calls, implementing a
//! uniform API to call into the kernel. Any architecture-peculiarities are
//! hidden from the caller, except if they leak into external data definitions.
//! That is, binary formatting of argument structures still need to be
//! performed by the caller. However, correct syscall invocation and splitting
//! across registers is performed by these helpers.
pub use Retval;
/// Restart System Call
///
/// This system call continues an interrupted system call with the same
/// parameters it was initially called, adjusted only for the time difference
/// between the original syscall and now.
///
/// This system call is used by the kernel itself to resume system calls of
/// frozen processes. Whenever a system call is interrupted, the kernel saves
/// the system call parameters and restarts the system call with the same
/// parameters once the task is resumed again. However, for system calls that
/// take relative time-frames as arguments, the kernel usually needs to adjust
/// these relative time-frames for the elapsed time. For those system calls,
/// the kernel refrains from restarting the system call directly and instead
/// changes the system call number of the to-be-restarted call to this system
/// call. When this system call is then invoked, the kernel fetches the
/// original system call and its parameters from its internal state, adjusts
/// the relative timeout, and then restarts the original system call.
///
/// There is usually no reason why you would ever invoke this system call from
/// user-space. Moreover, even when the kernel triggers a syscall restart with
/// this system call, it never leaves kernel space, and thus user-space should
/// never see this system call at all. Tracing debuggers might see it, though.
/// And they are the only ones that might reasonable interfere with it.
///
/// If no system call is to be resumed, this system call returns `EINTR`.
/// Otherwise, it resumes the original system call with adjusted relative time
/// parameters and returns the result of the resumed system call.
pub unsafe
/// Exit Task
///
/// `fn sys_exit(code: u32) -> !`
///
/// Stop the current execution and tear down this task. Other tasks of a
/// possible thread group are left around. See the linux task model for
/// information how threads and processes map to linux tasks.
///
/// Takes a single argument `code` which specifies the exit condition of the
/// running task.
///
/// This system call never returns, under no circumstances. This also implies
/// that this system call cannot be interrupted.
pub use crateEXIT;
/// Fork Task
///
/// XXX
pub use crateFORK;
/// Read from File-Descriptor
///
/// XXX
pub use crateREAD;
/// Write to File-Descriptor
///
/// XXX
pub use crateWRITE;
/// Open File
///
/// XXX
pub use crateOPEN;
/// Close File Descriptor
///
/// `fn sys_close(fd: u32) -> i32`
///
/// Close the file-descriptor specified by the first argument. First, the
/// file-descriptor is unlinked from the file-descriptor table of the calling
/// task, then the reference count of the open file-description is decremented
/// and possibly released thereafter.
///
/// This system call always unlinks the file-descriptor from the
/// file-descriptor table of the calling task. That is, if the passed
/// file-descriptor is valid, it is always invalidated by this system call,
/// regardless of the return code, even if `EINTR` is returned. You must never
/// repeat or restart this system call.
///
/// Takes a single argument `fd` which specifies the file-descriptor to close.
/// Unlike most other system calls, this type is `unsigned`, but that should
/// make no observable difference to the caller.
///
/// This system call returns `EBADF` if the specified file-descriptor was
/// invalid. In this case, this system call was a no-op. In all other cases,
/// regardless of the return code, the system call actually closed the
/// file-descriptor. Moreover, if this did not release the underlying open
/// file-description, then this will always return 0.
/// However, if this system call ends up releasing the underlying open
/// file-description, the teardown operation of just this can trigger any kind
/// of writeback, cache-invalidation, resource relinking, rcu grace period,
/// etc., and thus might take a considerable amount of time. Furthermore, for
/// historical reasons, this final teardown can also return arbitrary error
/// codes from deep down in the kernel device drivers (even confusingly
/// allowing `EBADF`). Given that, you should never check the return value of
/// this system call, but always assume it succeeded.
///
/// Lastly, you must never assume that a call to this operation actually
/// performs a final teardown of the underlying open file-description. Any
/// temporary, parallel kernel maintenance thread might pin the same open
/// file-description for a short moment, and thus delay the teardown for an
/// arbitrary amount of time. This especially means you *MUST NOT* rely on this
/// function implying an `fsync()`, unless you verified this via the kernel
/// sources yourself.
pub use crateCLOSE;
/// XXX
pub use crateLSEEK;
/// XXX
pub use crateGETPID;
/// XXX
pub use cratePIPE2;
/// XXX
pub use crateMEMFD_CREATE;
/// XXX
pub use crateREADLINKAT;
/// XXX
pub use crateSTATX;
/// XXX
pub use crateCOPY_FILE_RANGE;
/// XXX
pub use crateDUP;
/// XXX
pub use crateDUP2;
/// XXX
pub use crateDUP3;