Skip to main content

proot/syscall/
nr.rs

1//! x86_64 syscall numbers used by the filter and the handlers.
2#![allow(dead_code)]
3
4pub const READ: i64 = 0;
5pub const WRITE: i64 = 1;
6pub const OPEN: i64 = 2;
7pub const CLOSE: i64 = 3;
8pub const STAT: i64 = 4;
9pub const FSTAT: i64 = 5;
10pub const LSTAT: i64 = 6;
11pub const ACCESS: i64 = 21;
12pub const GETPID: i64 = 39;
13pub const CONNECT: i64 = 42;
14pub const SENDTO: i64 = 44;
15pub const SENDMSG: i64 = 46;
16pub const BIND: i64 = 49;
17pub const CLONE: i64 = 56;
18pub const FORK: i64 = 57;
19pub const VFORK: i64 = 58;
20pub const EXECVE: i64 = 59;
21pub const UNAME: i64 = 63;
22pub const TRUNCATE: i64 = 76;
23pub const GETCWD: i64 = 79;
24pub const CHDIR: i64 = 80;
25pub const FCHDIR: i64 = 81;
26pub const RENAME: i64 = 82;
27pub const MKDIR: i64 = 83;
28pub const RMDIR: i64 = 84;
29pub const CREAT: i64 = 85;
30pub const LINK: i64 = 86;
31pub const UNLINK: i64 = 87;
32pub const SYMLINK: i64 = 88;
33pub const READLINK: i64 = 89;
34pub const CHMOD: i64 = 90;
35pub const FCHMOD: i64 = 91;
36pub const CHOWN: i64 = 92;
37pub const FCHOWN: i64 = 93;
38pub const GETUID: i64 = 102;
39pub const GETGID: i64 = 104;
40pub const SETUID: i64 = 105;
41pub const SETGID: i64 = 106;
42pub const GETEUID: i64 = 107;
43pub const GETEGID: i64 = 108;
44pub const SETREUID: i64 = 113;
45pub const SETREGID: i64 = 114;
46pub const GETGROUPS: i64 = 115;
47pub const SETGROUPS: i64 = 116;
48pub const SETRESUID: i64 = 117;
49pub const GETRESUID: i64 = 118;
50pub const SETRESGID: i64 = 119;
51pub const GETRESGID: i64 = 120;
52pub const SETFSUID: i64 = 122;
53pub const SETFSGID: i64 = 123;
54pub const CAPSET: i64 = 126;
55pub const LCHOWN: i64 = 94;
56pub const UTIME: i64 = 132;
57pub const MKNOD: i64 = 133;
58pub const STATFS: i64 = 137;
59pub const PRCTL: i64 = 157;
60pub const CHROOT: i64 = 161;
61pub const SETXATTR: i64 = 188;
62pub const LSETXATTR: i64 = 189;
63pub const GETXATTR: i64 = 191;
64pub const LGETXATTR: i64 = 192;
65pub const LISTXATTR: i64 = 194;
66pub const LLISTXATTR: i64 = 195;
67pub const REMOVEXATTR: i64 = 197;
68pub const LREMOVEXATTR: i64 = 198;
69pub const UTIMES: i64 = 235;
70pub const UNSHARE: i64 = 272;
71pub const SETNS: i64 = 308;
72pub const INOTIFY_ADD_WATCH: i64 = 254;
73pub const OPENAT: i64 = 257;
74pub const MKDIRAT: i64 = 258;
75pub const MKNODAT: i64 = 259;
76pub const FCHOWNAT: i64 = 260;
77pub const FUTIMESAT: i64 = 261;
78pub const NEWFSTATAT: i64 = 262;
79pub const UNLINKAT: i64 = 263;
80pub const RENAMEAT: i64 = 264;
81pub const LINKAT: i64 = 265;
82pub const SYMLINKAT: i64 = 266;
83pub const READLINKAT: i64 = 267;
84pub const FCHMODAT: i64 = 268;
85pub const FACCESSAT: i64 = 269;
86pub const UTIMENSAT: i64 = 280;
87pub const NAME_TO_HANDLE_AT: i64 = 303;
88pub const RENAMEAT2: i64 = 316;
89pub const EXECVEAT: i64 = 322;
90pub const STATX: i64 = 332;
91pub const CLONE3: i64 = 435;
92pub const OPENAT2: i64 = 437;
93pub const FACCESSAT2: i64 = 439;
94pub const FCHMODAT2: i64 = 452;
95/// Placeholder number for the i386 `socketcall` multiplexer, which has no x86_64 equivalent.
96pub const SOCKETCALL: i64 = -102;
97
98/// Human-readable name for diagnostics.
99pub fn name(nr: i64) -> &'static str {
100    match nr {
101        OPEN => "open",
102        STAT => "stat",
103        LSTAT => "lstat",
104        ACCESS => "access",
105        CONNECT => "connect",
106        BIND => "bind",
107        EXECVE => "execve",
108        UNAME => "uname",
109        PRCTL => "prctl",
110        TRUNCATE => "truncate",
111        GETCWD => "getcwd",
112        CHDIR => "chdir",
113        FCHDIR => "fchdir",
114        CLONE => "clone",
115        FORK => "fork",
116        VFORK => "vfork",
117        CLONE3 => "clone3",
118        UNSHARE => "unshare",
119        SETNS => "setns",
120        SOCKETCALL => "socketcall",
121        RENAME => "rename",
122        MKDIR => "mkdir",
123        RMDIR => "rmdir",
124        CREAT => "creat",
125        LINK => "link",
126        UNLINK => "unlink",
127        SYMLINK => "symlink",
128        READLINK => "readlink",
129        CHMOD => "chmod",
130        CHOWN => "chown",
131        LCHOWN => "lchown",
132        UTIME => "utime",
133        MKNOD => "mknod",
134        STATFS => "statfs",
135        CHROOT => "chroot",
136        SETXATTR => "setxattr",
137        LSETXATTR => "lsetxattr",
138        GETXATTR => "getxattr",
139        LGETXATTR => "lgetxattr",
140        LISTXATTR => "listxattr",
141        LLISTXATTR => "llistxattr",
142        REMOVEXATTR => "removexattr",
143        LREMOVEXATTR => "lremovexattr",
144        UTIMES => "utimes",
145        INOTIFY_ADD_WATCH => "inotify_add_watch",
146        OPENAT => "openat",
147        MKDIRAT => "mkdirat",
148        MKNODAT => "mknodat",
149        FCHOWNAT => "fchownat",
150        FUTIMESAT => "futimesat",
151        NEWFSTATAT => "newfstatat",
152        UNLINKAT => "unlinkat",
153        RENAMEAT => "renameat",
154        LINKAT => "linkat",
155        SYMLINKAT => "symlinkat",
156        READLINKAT => "readlinkat",
157        FCHMODAT => "fchmodat",
158        FACCESSAT => "faccessat",
159        UTIMENSAT => "utimensat",
160        NAME_TO_HANDLE_AT => "name_to_handle_at",
161        RENAMEAT2 => "renameat2",
162        EXECVEAT => "execveat",
163        STATX => "statx",
164        OPENAT2 => "openat2",
165        FACCESSAT2 => "faccessat2",
166        FCHMODAT2 => "fchmodat2",
167        GETUID => "getuid",
168        GETGID => "getgid",
169        SETUID => "setuid",
170        SETGID => "setgid",
171        GETEUID => "geteuid",
172        GETEGID => "getegid",
173        SETREUID => "setreuid",
174        SETREGID => "setregid",
175        SETGROUPS => "setgroups",
176        GETGROUPS => "getgroups",
177        SETRESUID => "setresuid",
178        GETRESUID => "getresuid",
179        SETRESGID => "setresgid",
180        GETRESGID => "getresgid",
181        SETFSUID => "setfsuid",
182        SETFSGID => "setfsgid",
183        CAPSET => "capset",
184        FCHOWN => "fchown",
185        _ => "?",
186    }
187}