syscall-napi 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,337 @@
1
+ declare const syscallNumbers: {
2
+ io_setup: bigint;
3
+ io_destroy: bigint;
4
+ io_submit: bigint;
5
+ io_cancel: bigint;
6
+ io_getevents: bigint;
7
+ setxattr: bigint;
8
+ lsetxattr: bigint;
9
+ fsetxattr: bigint;
10
+ getxattr: bigint;
11
+ lgetxattr: bigint;
12
+ fgetxattr: bigint;
13
+ listxattr: bigint;
14
+ llistxattr: bigint;
15
+ flistxattr: bigint;
16
+ removexattr: bigint;
17
+ lremovexattr: bigint;
18
+ fremovexattr: bigint;
19
+ getcwd: bigint;
20
+ lookup_dcookie: bigint;
21
+ eventfd2: bigint;
22
+ epoll_create1: bigint;
23
+ epoll_ctl: bigint;
24
+ epoll_pwait: bigint;
25
+ dup: bigint;
26
+ dup3: bigint;
27
+ inotify_init1: bigint;
28
+ inotify_add_watch: bigint;
29
+ inotify_rm_watch: bigint;
30
+ ioctl: bigint;
31
+ ioprio_set: bigint;
32
+ ioprio_get: bigint;
33
+ flock: bigint;
34
+ mknodat: bigint;
35
+ mkdirat: bigint;
36
+ unlinkat: bigint;
37
+ symlinkat: bigint;
38
+ linkat: bigint;
39
+ renameat: bigint;
40
+ umount2: bigint;
41
+ mount: bigint;
42
+ pivot_root: bigint;
43
+ nfsservctl: bigint;
44
+ fallocate: bigint;
45
+ faccessat: bigint;
46
+ chdir: bigint;
47
+ fchdir: bigint;
48
+ chroot: bigint;
49
+ fchmod: bigint;
50
+ fchmodat: bigint;
51
+ fchownat: bigint;
52
+ fchown: bigint;
53
+ openat: bigint;
54
+ close: bigint;
55
+ vhangup: bigint;
56
+ pipe2: bigint;
57
+ quotactl: bigint;
58
+ getdents64: bigint;
59
+ read: bigint;
60
+ write: bigint;
61
+ readv: bigint;
62
+ writev: bigint;
63
+ pread64: bigint;
64
+ pwrite64: bigint;
65
+ preadv: bigint;
66
+ pwritev: bigint;
67
+ pselect6: bigint;
68
+ ppoll: bigint;
69
+ signalfd4: bigint;
70
+ vmsplice: bigint;
71
+ splice: bigint;
72
+ tee: bigint;
73
+ readlinkat: bigint;
74
+ sync: bigint;
75
+ fsync: bigint;
76
+ fdatasync: bigint;
77
+ sync_file_range2: bigint;
78
+ timerfd_create: bigint;
79
+ timerfd_settime: bigint;
80
+ timerfd_gettime: bigint;
81
+ utimensat: bigint;
82
+ acct: bigint;
83
+ capget: bigint;
84
+ capset: bigint;
85
+ personality: bigint;
86
+ exit: bigint;
87
+ exit_group: bigint;
88
+ waitid: bigint;
89
+ set_tid_address: bigint;
90
+ unshare: bigint;
91
+ futex: bigint;
92
+ set_robust_list: bigint;
93
+ get_robust_list: bigint;
94
+ nanosleep: bigint;
95
+ getitimer: bigint;
96
+ setitimer: bigint;
97
+ kexec_load: bigint;
98
+ init_module: bigint;
99
+ delete_module: bigint;
100
+ timer_create: bigint;
101
+ timer_gettime: bigint;
102
+ timer_getoverrun: bigint;
103
+ timer_settime: bigint;
104
+ timer_delete: bigint;
105
+ clock_settime: bigint;
106
+ clock_gettime: bigint;
107
+ clock_getres: bigint;
108
+ clock_nanosleep: bigint;
109
+ syslog: bigint;
110
+ ptrace: bigint;
111
+ sched_setparam: bigint;
112
+ sched_setscheduler: bigint;
113
+ sched_getscheduler: bigint;
114
+ sched_getparam: bigint;
115
+ sched_setaffinity: bigint;
116
+ sched_getaffinity: bigint;
117
+ sched_yield: bigint;
118
+ sched_get_priority_max: bigint;
119
+ sched_get_priority_min: bigint;
120
+ sched_rr_get_interval: bigint;
121
+ restart_syscall: bigint;
122
+ kill: bigint;
123
+ tkill: bigint;
124
+ tgkill: bigint;
125
+ sigaltstack: bigint;
126
+ rt_sigsuspend: bigint;
127
+ rt_sigaction: bigint;
128
+ rt_sigprocmask: bigint;
129
+ rt_sigpending: bigint;
130
+ rt_sigtimedwait: bigint;
131
+ rt_sigqueueinfo: bigint;
132
+ rt_sigreturn: bigint;
133
+ setpriority: bigint;
134
+ getpriority: bigint;
135
+ reboot: bigint;
136
+ setregid: bigint;
137
+ setgid: bigint;
138
+ setreuid: bigint;
139
+ setuid: bigint;
140
+ setresuid: bigint;
141
+ getresuid: bigint;
142
+ setresgid: bigint;
143
+ getresgid: bigint;
144
+ setfsuid: bigint;
145
+ setfsgid: bigint;
146
+ times: bigint;
147
+ setpgid: bigint;
148
+ getpgid: bigint;
149
+ getsid: bigint;
150
+ setsid: bigint;
151
+ getgroups: bigint;
152
+ setgroups: bigint;
153
+ uname: bigint;
154
+ sethostname: bigint;
155
+ setdomainname: bigint;
156
+ setrlimit: bigint;
157
+ getrusage: bigint;
158
+ umask: bigint;
159
+ prctl: bigint;
160
+ getcpu: bigint;
161
+ gettimeofday: bigint;
162
+ settimeofday: bigint;
163
+ adjtimex: bigint;
164
+ getpid: bigint;
165
+ getppid: bigint;
166
+ getuid: bigint;
167
+ geteuid: bigint;
168
+ getgid: bigint;
169
+ getegid: bigint;
170
+ gettid: bigint;
171
+ sysinfo: bigint;
172
+ mq_open: bigint;
173
+ mq_unlink: bigint;
174
+ mq_timedsend: bigint;
175
+ mq_timedreceive: bigint;
176
+ mq_notify: bigint;
177
+ mq_getsetattr: bigint;
178
+ msgget: bigint;
179
+ msgctl: bigint;
180
+ msgrcv: bigint;
181
+ msgsnd: bigint;
182
+ semget: bigint;
183
+ semctl: bigint;
184
+ semtimedop: bigint;
185
+ semop: bigint;
186
+ shmget: bigint;
187
+ shmctl: bigint;
188
+ shmat: bigint;
189
+ shmdt: bigint;
190
+ socket: bigint;
191
+ socketpair: bigint;
192
+ bind: bigint;
193
+ listen: bigint;
194
+ accept: bigint;
195
+ connect: bigint;
196
+ getsockname: bigint;
197
+ getpeername: bigint;
198
+ sendto: bigint;
199
+ recvfrom: bigint;
200
+ setsockopt: bigint;
201
+ getsockopt: bigint;
202
+ shutdown: bigint;
203
+ sendmsg: bigint;
204
+ recvmsg: bigint;
205
+ readahead: bigint;
206
+ brk: bigint;
207
+ munmap: bigint;
208
+ mremap: bigint;
209
+ add_key: bigint;
210
+ request_key: bigint;
211
+ keyctl: bigint;
212
+ clone: bigint;
213
+ execve: bigint;
214
+ swapon: bigint;
215
+ swapoff: bigint;
216
+ mprotect: bigint;
217
+ msync: bigint;
218
+ mlock: bigint;
219
+ munlock: bigint;
220
+ mlockall: bigint;
221
+ munlockall: bigint;
222
+ mincore: bigint;
223
+ madvise: bigint;
224
+ remap_file_pages: bigint;
225
+ mbind: bigint;
226
+ get_mempolicy: bigint;
227
+ set_mempolicy: bigint;
228
+ migrate_pages: bigint;
229
+ move_pages: bigint;
230
+ rt_tgsigqueueinfo: bigint;
231
+ perf_event_open: bigint;
232
+ accept4: bigint;
233
+ recvmmsg: bigint;
234
+ wait4: bigint;
235
+ prlimit64: bigint;
236
+ fanotify_init: bigint;
237
+ fanotify_mark: bigint;
238
+ name_to_handle_at: bigint;
239
+ open_by_handle_at: bigint;
240
+ clock_adjtime: bigint;
241
+ syncfs: bigint;
242
+ setns: bigint;
243
+ sendmmsg: bigint;
244
+ process_vm_readv: bigint;
245
+ process_vm_writev: bigint;
246
+ kcmp: bigint;
247
+ finit_module: bigint;
248
+ sched_setattr: bigint;
249
+ sched_getattr: bigint;
250
+ renameat2: bigint;
251
+ seccomp: bigint;
252
+ getrandom: bigint;
253
+ memfd_create: bigint;
254
+ bpf: bigint;
255
+ execveat: bigint;
256
+ userfaultfd: bigint;
257
+ membarrier: bigint;
258
+ mlock2: bigint;
259
+ copy_file_range: bigint;
260
+ preadv2: bigint;
261
+ pwritev2: bigint;
262
+ pkey_mprotect: bigint;
263
+ pkey_alloc: bigint;
264
+ pkey_free: bigint;
265
+ statx: bigint;
266
+ io_pgetevents: bigint;
267
+ rseq: bigint;
268
+ kexec_file_load: bigint;
269
+ clock_gettime64: bigint;
270
+ clock_settime64: bigint;
271
+ clock_adjtime64: bigint;
272
+ clock_getres_time64: bigint;
273
+ clock_nanosleep_time64: bigint;
274
+ timer_gettime64: bigint;
275
+ timer_settime64: bigint;
276
+ timerfd_gettime64: bigint;
277
+ timerfd_settime64: bigint;
278
+ utimensat_time64: bigint;
279
+ pselect6_time64: bigint;
280
+ ppoll_time64: bigint;
281
+ io_pgetevents_time64: bigint;
282
+ recvmmsg_time64: bigint;
283
+ mq_timedsend_time64: bigint;
284
+ mq_timedreceive_time64: bigint;
285
+ semtimedop_time64: bigint;
286
+ rt_sigtimedwait_time64: bigint;
287
+ futex_time64: bigint;
288
+ sched_rr_get_interval_time64: bigint;
289
+ pidfd_send_signal: bigint;
290
+ io_uring_setup: bigint;
291
+ io_uring_enter: bigint;
292
+ io_uring_register: bigint;
293
+ open_tree: bigint;
294
+ move_mount: bigint;
295
+ fsopen: bigint;
296
+ fsconfig: bigint;
297
+ fsmount: bigint;
298
+ fspick: bigint;
299
+ pidfd_open: bigint;
300
+ clone3: bigint;
301
+ close_range: bigint;
302
+ openat2: bigint;
303
+ pidfd_getfd: bigint;
304
+ faccessat2: bigint;
305
+ process_madvise: bigint;
306
+ epoll_pwait2: bigint;
307
+ mount_setattr: bigint;
308
+ quotactl_fd: bigint;
309
+ landlock_create_ruleset: bigint;
310
+ landlock_add_rule: bigint;
311
+ landlock_restrict_self: bigint;
312
+ process_mrelease: bigint;
313
+ futex_waitv: bigint;
314
+ set_mempolicy_home_node: bigint;
315
+ fcntl: bigint;
316
+ statfs: bigint;
317
+ fstatfs: bigint;
318
+ truncate: bigint;
319
+ ftruncate: bigint;
320
+ lseek: bigint;
321
+ sendfile: bigint;
322
+ fstat: bigint;
323
+ stat: bigint;
324
+ lstat: bigint;
325
+ fcntl64: bigint;
326
+ statfs64: bigint;
327
+ fstatfs64: bigint;
328
+ truncate64: bigint;
329
+ ftruncate64: bigint;
330
+ sendfile64: bigint;
331
+ fstatat64: bigint;
332
+ fstat64: bigint;
333
+ mmap2: bigint;
334
+ stat64: bigint;
335
+ lstat64: bigint;
336
+ };
337
+ export { syscallNumbers };
@@ -0,0 +1,311 @@
1
+ declare const syscallNumbers: {
2
+ io_setup: bigint;
3
+ io_destroy: bigint;
4
+ io_submit: bigint;
5
+ io_cancel: bigint;
6
+ io_getevents: bigint;
7
+ setxattr: bigint;
8
+ lsetxattr: bigint;
9
+ fsetxattr: bigint;
10
+ getxattr: bigint;
11
+ lgetxattr: bigint;
12
+ fgetxattr: bigint;
13
+ listxattr: bigint;
14
+ llistxattr: bigint;
15
+ flistxattr: bigint;
16
+ removexattr: bigint;
17
+ lremovexattr: bigint;
18
+ fremovexattr: bigint;
19
+ getcwd: bigint;
20
+ lookup_dcookie: bigint;
21
+ eventfd2: bigint;
22
+ epoll_create1: bigint;
23
+ epoll_ctl: bigint;
24
+ epoll_pwait: bigint;
25
+ dup: bigint;
26
+ dup3: bigint;
27
+ inotify_init1: bigint;
28
+ inotify_add_watch: bigint;
29
+ inotify_rm_watch: bigint;
30
+ ioctl: bigint;
31
+ ioprio_set: bigint;
32
+ ioprio_get: bigint;
33
+ flock: bigint;
34
+ mknodat: bigint;
35
+ mkdirat: bigint;
36
+ unlinkat: bigint;
37
+ symlinkat: bigint;
38
+ linkat: bigint;
39
+ renameat: bigint;
40
+ umount2: bigint;
41
+ mount: bigint;
42
+ pivot_root: bigint;
43
+ nfsservctl: bigint;
44
+ fallocate: bigint;
45
+ faccessat: bigint;
46
+ chdir: bigint;
47
+ fchdir: bigint;
48
+ chroot: bigint;
49
+ fchmod: bigint;
50
+ fchmodat: bigint;
51
+ fchownat: bigint;
52
+ fchown: bigint;
53
+ openat: bigint;
54
+ close: bigint;
55
+ vhangup: bigint;
56
+ pipe2: bigint;
57
+ quotactl: bigint;
58
+ getdents64: bigint;
59
+ read: bigint;
60
+ write: bigint;
61
+ readv: bigint;
62
+ writev: bigint;
63
+ pread64: bigint;
64
+ pwrite64: bigint;
65
+ preadv: bigint;
66
+ pwritev: bigint;
67
+ pselect6: bigint;
68
+ ppoll: bigint;
69
+ signalfd4: bigint;
70
+ vmsplice: bigint;
71
+ splice: bigint;
72
+ tee: bigint;
73
+ readlinkat: bigint;
74
+ sync: bigint;
75
+ fsync: bigint;
76
+ fdatasync: bigint;
77
+ sync_file_range: bigint;
78
+ timerfd_create: bigint;
79
+ timerfd_settime: bigint;
80
+ timerfd_gettime: bigint;
81
+ utimensat: bigint;
82
+ acct: bigint;
83
+ capget: bigint;
84
+ capset: bigint;
85
+ personality: bigint;
86
+ exit: bigint;
87
+ exit_group: bigint;
88
+ waitid: bigint;
89
+ set_tid_address: bigint;
90
+ unshare: bigint;
91
+ futex: bigint;
92
+ set_robust_list: bigint;
93
+ get_robust_list: bigint;
94
+ nanosleep: bigint;
95
+ getitimer: bigint;
96
+ setitimer: bigint;
97
+ kexec_load: bigint;
98
+ init_module: bigint;
99
+ delete_module: bigint;
100
+ timer_create: bigint;
101
+ timer_gettime: bigint;
102
+ timer_getoverrun: bigint;
103
+ timer_settime: bigint;
104
+ timer_delete: bigint;
105
+ clock_settime: bigint;
106
+ clock_gettime: bigint;
107
+ clock_getres: bigint;
108
+ clock_nanosleep: bigint;
109
+ syslog: bigint;
110
+ ptrace: bigint;
111
+ sched_setparam: bigint;
112
+ sched_setscheduler: bigint;
113
+ sched_getscheduler: bigint;
114
+ sched_getparam: bigint;
115
+ sched_setaffinity: bigint;
116
+ sched_getaffinity: bigint;
117
+ sched_yield: bigint;
118
+ sched_get_priority_max: bigint;
119
+ sched_get_priority_min: bigint;
120
+ sched_rr_get_interval: bigint;
121
+ restart_syscall: bigint;
122
+ kill: bigint;
123
+ tkill: bigint;
124
+ tgkill: bigint;
125
+ sigaltstack: bigint;
126
+ rt_sigsuspend: bigint;
127
+ rt_sigaction: bigint;
128
+ rt_sigprocmask: bigint;
129
+ rt_sigpending: bigint;
130
+ rt_sigtimedwait: bigint;
131
+ rt_sigqueueinfo: bigint;
132
+ rt_sigreturn: bigint;
133
+ setpriority: bigint;
134
+ getpriority: bigint;
135
+ reboot: bigint;
136
+ setregid: bigint;
137
+ setgid: bigint;
138
+ setreuid: bigint;
139
+ setuid: bigint;
140
+ setresuid: bigint;
141
+ getresuid: bigint;
142
+ setresgid: bigint;
143
+ getresgid: bigint;
144
+ setfsuid: bigint;
145
+ setfsgid: bigint;
146
+ times: bigint;
147
+ setpgid: bigint;
148
+ getpgid: bigint;
149
+ getsid: bigint;
150
+ setsid: bigint;
151
+ getgroups: bigint;
152
+ setgroups: bigint;
153
+ uname: bigint;
154
+ sethostname: bigint;
155
+ setdomainname: bigint;
156
+ getrlimit: bigint;
157
+ setrlimit: bigint;
158
+ getrusage: bigint;
159
+ umask: bigint;
160
+ prctl: bigint;
161
+ getcpu: bigint;
162
+ gettimeofday: bigint;
163
+ settimeofday: bigint;
164
+ adjtimex: bigint;
165
+ getpid: bigint;
166
+ getppid: bigint;
167
+ getuid: bigint;
168
+ geteuid: bigint;
169
+ getgid: bigint;
170
+ getegid: bigint;
171
+ gettid: bigint;
172
+ sysinfo: bigint;
173
+ mq_open: bigint;
174
+ mq_unlink: bigint;
175
+ mq_timedsend: bigint;
176
+ mq_timedreceive: bigint;
177
+ mq_notify: bigint;
178
+ mq_getsetattr: bigint;
179
+ msgget: bigint;
180
+ msgctl: bigint;
181
+ msgrcv: bigint;
182
+ msgsnd: bigint;
183
+ semget: bigint;
184
+ semctl: bigint;
185
+ semtimedop: bigint;
186
+ semop: bigint;
187
+ shmget: bigint;
188
+ shmctl: bigint;
189
+ shmat: bigint;
190
+ shmdt: bigint;
191
+ socket: bigint;
192
+ socketpair: bigint;
193
+ bind: bigint;
194
+ listen: bigint;
195
+ accept: bigint;
196
+ connect: bigint;
197
+ getsockname: bigint;
198
+ getpeername: bigint;
199
+ sendto: bigint;
200
+ recvfrom: bigint;
201
+ setsockopt: bigint;
202
+ getsockopt: bigint;
203
+ shutdown: bigint;
204
+ sendmsg: bigint;
205
+ recvmsg: bigint;
206
+ readahead: bigint;
207
+ brk: bigint;
208
+ munmap: bigint;
209
+ mremap: bigint;
210
+ add_key: bigint;
211
+ request_key: bigint;
212
+ keyctl: bigint;
213
+ clone: bigint;
214
+ execve: bigint;
215
+ swapon: bigint;
216
+ swapoff: bigint;
217
+ mprotect: bigint;
218
+ msync: bigint;
219
+ mlock: bigint;
220
+ munlock: bigint;
221
+ mlockall: bigint;
222
+ munlockall: bigint;
223
+ mincore: bigint;
224
+ madvise: bigint;
225
+ remap_file_pages: bigint;
226
+ mbind: bigint;
227
+ get_mempolicy: bigint;
228
+ set_mempolicy: bigint;
229
+ migrate_pages: bigint;
230
+ move_pages: bigint;
231
+ rt_tgsigqueueinfo: bigint;
232
+ perf_event_open: bigint;
233
+ accept4: bigint;
234
+ recvmmsg: bigint;
235
+ arch_specific_syscall: bigint;
236
+ wait4: bigint;
237
+ prlimit64: bigint;
238
+ fanotify_init: bigint;
239
+ fanotify_mark: bigint;
240
+ name_to_handle_at: bigint;
241
+ open_by_handle_at: bigint;
242
+ clock_adjtime: bigint;
243
+ syncfs: bigint;
244
+ setns: bigint;
245
+ sendmmsg: bigint;
246
+ process_vm_readv: bigint;
247
+ process_vm_writev: bigint;
248
+ kcmp: bigint;
249
+ finit_module: bigint;
250
+ sched_setattr: bigint;
251
+ sched_getattr: bigint;
252
+ renameat2: bigint;
253
+ seccomp: bigint;
254
+ getrandom: bigint;
255
+ memfd_create: bigint;
256
+ bpf: bigint;
257
+ execveat: bigint;
258
+ userfaultfd: bigint;
259
+ membarrier: bigint;
260
+ mlock2: bigint;
261
+ copy_file_range: bigint;
262
+ preadv2: bigint;
263
+ pwritev2: bigint;
264
+ pkey_mprotect: bigint;
265
+ pkey_alloc: bigint;
266
+ pkey_free: bigint;
267
+ statx: bigint;
268
+ io_pgetevents: bigint;
269
+ rseq: bigint;
270
+ kexec_file_load: bigint;
271
+ pidfd_send_signal: bigint;
272
+ io_uring_setup: bigint;
273
+ io_uring_enter: bigint;
274
+ io_uring_register: bigint;
275
+ open_tree: bigint;
276
+ move_mount: bigint;
277
+ fsopen: bigint;
278
+ fsconfig: bigint;
279
+ fsmount: bigint;
280
+ fspick: bigint;
281
+ pidfd_open: bigint;
282
+ clone3: bigint;
283
+ close_range: bigint;
284
+ openat2: bigint;
285
+ pidfd_getfd: bigint;
286
+ faccessat2: bigint;
287
+ process_madvise: bigint;
288
+ epoll_pwait2: bigint;
289
+ mount_setattr: bigint;
290
+ quotactl_fd: bigint;
291
+ landlock_create_ruleset: bigint;
292
+ landlock_add_rule: bigint;
293
+ landlock_restrict_self: bigint;
294
+ memfd_secret: bigint;
295
+ process_mrelease: bigint;
296
+ futex_waitv: bigint;
297
+ set_mempolicy_home_node: bigint;
298
+ syscalls: bigint;
299
+ fcntl: bigint;
300
+ statfs: bigint;
301
+ fstatfs: bigint;
302
+ truncate: bigint;
303
+ ftruncate: bigint;
304
+ lseek: bigint;
305
+ sendfile: bigint;
306
+ newfstatat: bigint;
307
+ fstat: bigint;
308
+ mmap: bigint;
309
+ fadvise64: bigint;
310
+ };
311
+ export { syscallNumbers };
@@ -0,0 +1,4 @@
1
+ declare const syscallNumbers: Partial<{
2
+ [x: string]: any;
3
+ }>;
4
+ export { syscallNumbers };
@@ -0,0 +1,32 @@
1
+ import { syscallNumbers as syscallNumbersX86_64 } from "./x64.js";
2
+ import { syscallNumbers as syscallNumbersArm64 } from "./arm64.js";
3
+ import { syscallNumbers as syscallNumbersArm } from "./arm.js";
4
+ import nodeProcess from "node:process";
5
+
6
+ if (nodeProcess.platform !== "linux") {
7
+ throw Error("only supported on linux");
8
+ }
9
+
10
+ /*type Common<T, U> = Pick<T, Extract<keyof T, keyof U>>;*/
11
+
12
+ /*type TCommonSyscallConstants = Common<Common<typeof syscallNumbersX86_64, typeof syscallNumbersArm64>, typeof syscallNumbersArm>;*/
13
+
14
+ /*type TSyscallConstants = TCommonSyscallConstants &
15
+ (Partial<typeof syscallNumbersX86_64> & Partial<typeof syscallNumbersArm64> & Partial<typeof syscallNumbersArm>);*/
16
+
17
+ const syscallNumbersByArch/*: Partial<{ [key in NodeJS.Architecture]: TSyscallConstants }>*/ = {
18
+ x64: syscallNumbersX86_64,
19
+ arm64: syscallNumbersArm64,
20
+ arm: syscallNumbersArm,
21
+ };
22
+
23
+ const syscallNumbersOfArch = syscallNumbersByArch[nodeProcess.arch];
24
+ if (syscallNumbersOfArch === undefined) {
25
+ throw Error(`unsupported architecture: ${nodeProcess.arch}`);
26
+ }
27
+
28
+ const syscallNumbers = syscallNumbersOfArch/*!*/;
29
+
30
+ export {
31
+ syscallNumbers
32
+ };
@@ -0,0 +1,311 @@
1
+ declare const syscallNumbers: {
2
+ io_setup: bigint;
3
+ io_destroy: bigint;
4
+ io_submit: bigint;
5
+ io_cancel: bigint;
6
+ io_getevents: bigint;
7
+ setxattr: bigint;
8
+ lsetxattr: bigint;
9
+ fsetxattr: bigint;
10
+ getxattr: bigint;
11
+ lgetxattr: bigint;
12
+ fgetxattr: bigint;
13
+ listxattr: bigint;
14
+ llistxattr: bigint;
15
+ flistxattr: bigint;
16
+ removexattr: bigint;
17
+ lremovexattr: bigint;
18
+ fremovexattr: bigint;
19
+ getcwd: bigint;
20
+ lookup_dcookie: bigint;
21
+ eventfd2: bigint;
22
+ epoll_create1: bigint;
23
+ epoll_ctl: bigint;
24
+ epoll_pwait: bigint;
25
+ dup: bigint;
26
+ dup3: bigint;
27
+ inotify_init1: bigint;
28
+ inotify_add_watch: bigint;
29
+ inotify_rm_watch: bigint;
30
+ ioctl: bigint;
31
+ ioprio_set: bigint;
32
+ ioprio_get: bigint;
33
+ flock: bigint;
34
+ mknodat: bigint;
35
+ mkdirat: bigint;
36
+ unlinkat: bigint;
37
+ symlinkat: bigint;
38
+ linkat: bigint;
39
+ renameat: bigint;
40
+ umount2: bigint;
41
+ mount: bigint;
42
+ pivot_root: bigint;
43
+ nfsservctl: bigint;
44
+ fallocate: bigint;
45
+ faccessat: bigint;
46
+ chdir: bigint;
47
+ fchdir: bigint;
48
+ chroot: bigint;
49
+ fchmod: bigint;
50
+ fchmodat: bigint;
51
+ fchownat: bigint;
52
+ fchown: bigint;
53
+ openat: bigint;
54
+ close: bigint;
55
+ vhangup: bigint;
56
+ pipe2: bigint;
57
+ quotactl: bigint;
58
+ getdents64: bigint;
59
+ read: bigint;
60
+ write: bigint;
61
+ readv: bigint;
62
+ writev: bigint;
63
+ pread64: bigint;
64
+ pwrite64: bigint;
65
+ preadv: bigint;
66
+ pwritev: bigint;
67
+ pselect6: bigint;
68
+ ppoll: bigint;
69
+ signalfd4: bigint;
70
+ vmsplice: bigint;
71
+ splice: bigint;
72
+ tee: bigint;
73
+ readlinkat: bigint;
74
+ sync: bigint;
75
+ fsync: bigint;
76
+ fdatasync: bigint;
77
+ sync_file_range: bigint;
78
+ timerfd_create: bigint;
79
+ timerfd_settime: bigint;
80
+ timerfd_gettime: bigint;
81
+ utimensat: bigint;
82
+ acct: bigint;
83
+ capget: bigint;
84
+ capset: bigint;
85
+ personality: bigint;
86
+ exit: bigint;
87
+ exit_group: bigint;
88
+ waitid: bigint;
89
+ set_tid_address: bigint;
90
+ unshare: bigint;
91
+ futex: bigint;
92
+ set_robust_list: bigint;
93
+ get_robust_list: bigint;
94
+ nanosleep: bigint;
95
+ getitimer: bigint;
96
+ setitimer: bigint;
97
+ kexec_load: bigint;
98
+ init_module: bigint;
99
+ delete_module: bigint;
100
+ timer_create: bigint;
101
+ timer_gettime: bigint;
102
+ timer_getoverrun: bigint;
103
+ timer_settime: bigint;
104
+ timer_delete: bigint;
105
+ clock_settime: bigint;
106
+ clock_gettime: bigint;
107
+ clock_getres: bigint;
108
+ clock_nanosleep: bigint;
109
+ syslog: bigint;
110
+ ptrace: bigint;
111
+ sched_setparam: bigint;
112
+ sched_setscheduler: bigint;
113
+ sched_getscheduler: bigint;
114
+ sched_getparam: bigint;
115
+ sched_setaffinity: bigint;
116
+ sched_getaffinity: bigint;
117
+ sched_yield: bigint;
118
+ sched_get_priority_max: bigint;
119
+ sched_get_priority_min: bigint;
120
+ sched_rr_get_interval: bigint;
121
+ restart_syscall: bigint;
122
+ kill: bigint;
123
+ tkill: bigint;
124
+ tgkill: bigint;
125
+ sigaltstack: bigint;
126
+ rt_sigsuspend: bigint;
127
+ rt_sigaction: bigint;
128
+ rt_sigprocmask: bigint;
129
+ rt_sigpending: bigint;
130
+ rt_sigtimedwait: bigint;
131
+ rt_sigqueueinfo: bigint;
132
+ rt_sigreturn: bigint;
133
+ setpriority: bigint;
134
+ getpriority: bigint;
135
+ reboot: bigint;
136
+ setregid: bigint;
137
+ setgid: bigint;
138
+ setreuid: bigint;
139
+ setuid: bigint;
140
+ setresuid: bigint;
141
+ getresuid: bigint;
142
+ setresgid: bigint;
143
+ getresgid: bigint;
144
+ setfsuid: bigint;
145
+ setfsgid: bigint;
146
+ times: bigint;
147
+ setpgid: bigint;
148
+ getpgid: bigint;
149
+ getsid: bigint;
150
+ setsid: bigint;
151
+ getgroups: bigint;
152
+ setgroups: bigint;
153
+ uname: bigint;
154
+ sethostname: bigint;
155
+ setdomainname: bigint;
156
+ getrlimit: bigint;
157
+ setrlimit: bigint;
158
+ getrusage: bigint;
159
+ umask: bigint;
160
+ prctl: bigint;
161
+ getcpu: bigint;
162
+ gettimeofday: bigint;
163
+ settimeofday: bigint;
164
+ adjtimex: bigint;
165
+ getpid: bigint;
166
+ getppid: bigint;
167
+ getuid: bigint;
168
+ geteuid: bigint;
169
+ getgid: bigint;
170
+ getegid: bigint;
171
+ gettid: bigint;
172
+ sysinfo: bigint;
173
+ mq_open: bigint;
174
+ mq_unlink: bigint;
175
+ mq_timedsend: bigint;
176
+ mq_timedreceive: bigint;
177
+ mq_notify: bigint;
178
+ mq_getsetattr: bigint;
179
+ msgget: bigint;
180
+ msgctl: bigint;
181
+ msgrcv: bigint;
182
+ msgsnd: bigint;
183
+ semget: bigint;
184
+ semctl: bigint;
185
+ semtimedop: bigint;
186
+ semop: bigint;
187
+ shmget: bigint;
188
+ shmctl: bigint;
189
+ shmat: bigint;
190
+ shmdt: bigint;
191
+ socket: bigint;
192
+ socketpair: bigint;
193
+ bind: bigint;
194
+ listen: bigint;
195
+ accept: bigint;
196
+ connect: bigint;
197
+ getsockname: bigint;
198
+ getpeername: bigint;
199
+ sendto: bigint;
200
+ recvfrom: bigint;
201
+ setsockopt: bigint;
202
+ getsockopt: bigint;
203
+ shutdown: bigint;
204
+ sendmsg: bigint;
205
+ recvmsg: bigint;
206
+ readahead: bigint;
207
+ brk: bigint;
208
+ munmap: bigint;
209
+ mremap: bigint;
210
+ add_key: bigint;
211
+ request_key: bigint;
212
+ keyctl: bigint;
213
+ clone: bigint;
214
+ execve: bigint;
215
+ swapon: bigint;
216
+ swapoff: bigint;
217
+ mprotect: bigint;
218
+ msync: bigint;
219
+ mlock: bigint;
220
+ munlock: bigint;
221
+ mlockall: bigint;
222
+ munlockall: bigint;
223
+ mincore: bigint;
224
+ madvise: bigint;
225
+ remap_file_pages: bigint;
226
+ mbind: bigint;
227
+ get_mempolicy: bigint;
228
+ set_mempolicy: bigint;
229
+ migrate_pages: bigint;
230
+ move_pages: bigint;
231
+ rt_tgsigqueueinfo: bigint;
232
+ perf_event_open: bigint;
233
+ accept4: bigint;
234
+ recvmmsg: bigint;
235
+ wait4: bigint;
236
+ prlimit64: bigint;
237
+ fanotify_init: bigint;
238
+ fanotify_mark: bigint;
239
+ name_to_handle_at: bigint;
240
+ open_by_handle_at: bigint;
241
+ clock_adjtime: bigint;
242
+ syncfs: bigint;
243
+ setns: bigint;
244
+ sendmmsg: bigint;
245
+ process_vm_readv: bigint;
246
+ process_vm_writev: bigint;
247
+ kcmp: bigint;
248
+ finit_module: bigint;
249
+ sched_setattr: bigint;
250
+ sched_getattr: bigint;
251
+ renameat2: bigint;
252
+ seccomp: bigint;
253
+ getrandom: bigint;
254
+ memfd_create: bigint;
255
+ bpf: bigint;
256
+ execveat: bigint;
257
+ userfaultfd: bigint;
258
+ membarrier: bigint;
259
+ mlock2: bigint;
260
+ copy_file_range: bigint;
261
+ preadv2: bigint;
262
+ pwritev2: bigint;
263
+ pkey_mprotect: bigint;
264
+ pkey_alloc: bigint;
265
+ pkey_free: bigint;
266
+ statx: bigint;
267
+ io_pgetevents: bigint;
268
+ rseq: bigint;
269
+ kexec_file_load: bigint;
270
+ pidfd_send_signal: bigint;
271
+ io_uring_setup: bigint;
272
+ io_uring_enter: bigint;
273
+ io_uring_register: bigint;
274
+ open_tree: bigint;
275
+ move_mount: bigint;
276
+ fsopen: bigint;
277
+ fsconfig: bigint;
278
+ fsmount: bigint;
279
+ fspick: bigint;
280
+ pidfd_open: bigint;
281
+ clone3: bigint;
282
+ close_range: bigint;
283
+ openat2: bigint;
284
+ pidfd_getfd: bigint;
285
+ faccessat2: bigint;
286
+ process_madvise: bigint;
287
+ epoll_pwait2: bigint;
288
+ mount_setattr: bigint;
289
+ quotactl_fd: bigint;
290
+ landlock_create_ruleset: bigint;
291
+ landlock_add_rule: bigint;
292
+ landlock_restrict_self: bigint;
293
+ memfd_secret: bigint;
294
+ process_mrelease: bigint;
295
+ futex_waitv: bigint;
296
+ set_mempolicy_home_node: bigint;
297
+ fcntl: bigint;
298
+ statfs: bigint;
299
+ fstatfs: bigint;
300
+ truncate: bigint;
301
+ ftruncate: bigint;
302
+ lseek: bigint;
303
+ sendfile: bigint;
304
+ newfstatat: bigint;
305
+ fstat: bigint;
306
+ mmap: bigint;
307
+ fadvise64: bigint;
308
+ stat: bigint;
309
+ lstat: bigint;
310
+ };
311
+ export { syscallNumbers };
@@ -0,0 +1,13 @@
1
+ import { syscallNumbers } from "./constants/index.js";
2
+ type TSyscallResult = {
3
+ errno: undefined;
4
+ ret: bigint;
5
+ } | {
6
+ errno: number;
7
+ ret: undefined;
8
+ };
9
+ declare const syscall: ({ syscallNumber, args }: {
10
+ syscallNumber: bigint;
11
+ args: (bigint | Uint8Array)[];
12
+ }) => TSyscallResult;
13
+ export { syscall, syscallNumbers };
@@ -1,33 +1,21 @@
1
- import { syscallNumbers } from "./constants/index.ts";
1
+ import { syscallNumbers } from "./constants/index.js";
2
+ import { syscall_sync } from "./native.js";
2
3
 
3
- import { createRequire } from "module";
4
- const require = createRequire(import.meta.url);
5
-
6
- let native;
7
-
8
- try {
9
- native = require("../build/Release/syscall.node");
10
- } catch {
11
- native = require("../build/Debug/syscall.node");
12
- }
13
-
14
- const { syscall_sync } = native;
15
-
16
- type TSyscallResult = {
4
+ /*type TSyscallResult = {
17
5
  errno: undefined;
18
6
  ret: bigint;
19
7
  } | {
20
8
  errno: number;
21
9
  ret: undefined;
22
- }
10
+ }*/
23
11
 
24
12
  const syscall = ({
25
13
  syscallNumber,
26
14
  args
27
- }: {
15
+ }/*: {
28
16
  syscallNumber: bigint;
29
17
  args: (bigint | Uint8Array)[];
30
- }): TSyscallResult => {
18
+ }*/)/*: TSyscallResult*/ => {
31
19
  const { errno, ret } = syscall_sync(syscallNumber, ...args);
32
20
 
33
21
  if (errno !== 0) {
@@ -37,6 +25,11 @@ const syscall = ({
37
25
  };
38
26
  }
39
27
 
28
+ // mainly for TypeScript type narrowing
29
+ if (ret === undefined) {
30
+ throw new Error("syscall returned undefined ret with errno 0");
31
+ }
32
+
40
33
  return {
41
34
  errno: undefined,
42
35
  ret
@@ -0,0 +1,6 @@
1
+ type TSyscallSync = (args: bigint, ...rest: (bigint | Uint8Array)[]) => {
2
+ errno: number;
3
+ ret?: bigint;
4
+ };
5
+ declare const syscall_sync: TSyscallSync;
6
+ export { syscall_sync };
@@ -0,0 +1,14 @@
1
+ import { createNativeAddonLoader } from "./snippets/native-loader.js";
2
+
3
+ const nativeAddonLoader = createNativeAddonLoader();
4
+ const native = nativeAddonLoader.loadRelativeToPackageRoot({
5
+ relativeBuildFolderPath: "./build"
6
+ });
7
+
8
+ /*type TSyscallSync = (args: bigint, ...rest: (bigint | Uint8Array)[]) => { errno: number; ret?: bigint; };*/
9
+
10
+ const syscall_sync = native.syscall_sync /*as TSyscallSync*/;
11
+
12
+ export {
13
+ syscall_sync
14
+ };
@@ -0,0 +1,6 @@
1
+ declare const createNativeAddonLoader: () => {
2
+ loadRelativeToPackageRoot: ({ relativeBuildFolderPath }: {
3
+ relativeBuildFolderPath: string;
4
+ }) => any;
5
+ };
6
+ export { createNativeAddonLoader, };
@@ -0,0 +1,121 @@
1
+ import nodeFs from "node:fs";
2
+ import nodeUrl from "node:url";
3
+ import nodePath from "node:path";
4
+ import nodeModule from "node:module";
5
+
6
+ const findPackageJson = ({ startPath, maxUpwardSteps }/*: { startPath: string; maxUpwardSteps: number }*/) => {
7
+ let currentPath = startPath;
8
+
9
+ for (let i = 0; i < maxUpwardSteps; i += 1) {
10
+ const packageJsonPath = nodePath.join(currentPath, "package.json");
11
+
12
+ if (nodeFs.existsSync(packageJsonPath)) {
13
+ return packageJsonPath;
14
+ }
15
+
16
+ const parentPath = nodePath.dirname(currentPath);
17
+
18
+ // Reached filesystem root
19
+ if (parentPath === currentPath) {
20
+ break;
21
+ }
22
+
23
+ currentPath = parentPath;
24
+ }
25
+
26
+ throw new Error(`Could not find package.json within ${maxUpwardSteps} directory levels from ${startPath}`);
27
+ };
28
+
29
+ const findPackageRoot = ({ maxUpwardSteps }/*: { maxUpwardSteps: number }*/) => {
30
+ const ourScriptUrl = import.meta.url;
31
+ const ourScriptPath = nodeUrl.fileURLToPath(ourScriptUrl);
32
+ const ourScriptDirectory = nodePath.dirname(ourScriptPath);
33
+
34
+ const ourPackageJsonPath = findPackageJson({
35
+ startPath: ourScriptDirectory,
36
+ maxUpwardSteps,
37
+ });
38
+
39
+ const ourPackageRoot = nodePath.dirname(ourPackageJsonPath);
40
+
41
+ return ourPackageRoot;
42
+ };
43
+
44
+ const findAddonInAddonFolder = ({ addonFolderPath }/*: { addonFolderPath: string }*/) => {
45
+ const entries = nodeFs.readdirSync(addonFolderPath);
46
+
47
+ const addonEntries = entries.filter((entry) => {
48
+ return entry.endsWith(".node");
49
+ });
50
+
51
+ if (addonEntries.length === 0) {
52
+ throw Error(`no .node addon file found in build folder "${addonFolderPath}"`);
53
+ }
54
+
55
+ if (addonEntries.length > 1) {
56
+ throw Error(`multiple .node addon files found in build folder "${addonFolderPath}", cannot determine which to load`);
57
+ }
58
+
59
+ const addonFileName = addonEntries[0];
60
+
61
+ return addonFileName;
62
+ };
63
+
64
+ const loadAddonAtPath = ({ addonFilePath }/*: { addonFilePath: string }*/) => {
65
+ const require = nodeModule.createRequire(import.meta.url);
66
+
67
+ const native = require(addonFilePath);
68
+
69
+ return native;
70
+ };
71
+
72
+ const createNativeAddonLoader = () => {
73
+
74
+ const loadRelativeToPackageRoot = ({ relativeBuildFolderPath }/*: { relativeBuildFolderPath: string }*/) => {
75
+ let packageRoot/*: string*/;
76
+
77
+ try {
78
+ packageRoot = findPackageRoot({ maxUpwardSteps: 10 });
79
+ } catch (err) {
80
+ throw Error(`could not find our package root, make sure to keep the package structure intact when distributing the package - a package.json and built addon at ./build are required`);
81
+ }
82
+
83
+ const buildFolderPath = nodePath.join(packageRoot, relativeBuildFolderPath);
84
+
85
+ if (!nodeFs.existsSync(buildFolderPath)) {
86
+ throw Error(`no build folder found at our package root "${buildFolderPath}", make sure to build the native addon first`);
87
+ }
88
+
89
+ const debugFolderPath = nodePath.join(buildFolderPath, "Debug");
90
+ const releaseFolderPath = nodePath.join(buildFolderPath, "Release");
91
+
92
+ const debugFolderExists = nodeFs.existsSync(debugFolderPath);
93
+ const releaseFolderExists = nodeFs.existsSync(releaseFolderPath);
94
+
95
+ if (!debugFolderExists && !releaseFolderExists) {
96
+ throw Error(`neither Debug nor Release build folders found at our package root "${buildFolderPath}", make sure to build the native addon first`);
97
+ }
98
+
99
+ if (debugFolderExists && releaseFolderExists) {
100
+ throw Error(`both Debug and Release build folders exist at our package root "${buildFolderPath}", please remove one to avoid ambiguity`);
101
+ }
102
+
103
+ const addonFolderPath = releaseFolderExists ? releaseFolderPath : debugFolderPath;
104
+
105
+ const addonFileName = findAddonInAddonFolder({ addonFolderPath });
106
+
107
+ const addonFilePath = nodePath.resolve(addonFolderPath, addonFileName);
108
+
109
+ const native = loadAddonAtPath({ addonFilePath });
110
+
111
+ return native;
112
+ };
113
+
114
+ return {
115
+ loadRelativeToPackageRoot,
116
+ };
117
+ };
118
+
119
+ export {
120
+ createNativeAddonLoader,
121
+ };
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
1
  {
2
2
  "name": "syscall-napi",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "description": "Node.js module to perform synchronous syscalls",
6
- "main": "lib/index.ts",
7
- "scripts": {
8
- "test": "c8 --reporter lcov --reporter html --reporter text mocha test/**/*.ts",
9
- "eslint": "eslint ."
10
- },
11
6
  "files": [
12
- "lib/**/*",
7
+ "dist/**/*",
13
8
  "native/**/*",
14
- "samples/**/*",
15
9
  "binding.gyp"
16
10
  ],
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/k13-engineering/node-syscall-napi.git"
20
- },
21
- "keywords": [],
22
- "author": "Simon Kadisch",
23
- "license": "LGPL 2.1",
24
- "bugs": {
25
- "url": "https://github.com/k13-engineering/node-syscall-napi/issues"
11
+ "main": "dist/lib/index.js",
12
+ "scripts": {
13
+ "build": "rm -rf dist/ && deno-node-build --root . --out dist/ --entry lib/index.ts",
14
+ "test": "c8 --reporter lcov --reporter html --reporter text mocha test/**/*.ts",
15
+ "eslint": "eslint ."
26
16
  },
27
- "homepage": "https://github.com/k13-engineering/node-syscall-napi#readme",
28
17
  "devDependencies": {
29
18
  "@eslint/js": "^9.39.2",
19
+ "@k13engineering/releasetool": "^0.0.1",
30
20
  "@types/mocha": "^10.0.10",
31
21
  "@types/node": "^25.0.3",
32
22
  "c8": "^10.1.3",
23
+ "deno-node": "^0.0.12",
33
24
  "eslint": "^9.39.2",
34
25
  "mocha": "^11.7.1",
35
26
  "node-archibald": "^0.0.7",
36
27
  "typescript-eslint": "^8.51.0"
37
28
  },
38
- "dependencies": {
39
-
40
- }
29
+ "dependencies": {},
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/k13-engineering/node-syscall-napi.git"
33
+ },
34
+ "keywords": [],
35
+ "author": "Simon Kadisch",
36
+ "license": "LGPL 2.1",
37
+ "bugs": {
38
+ "url": "https://github.com/k13-engineering/node-syscall-napi/issues"
39
+ },
40
+ "homepage": "https://github.com/k13-engineering/node-syscall-napi#readme"
41
41
  }
@@ -1,32 +0,0 @@
1
- import { syscallNumbers as syscallNumbersX86_64 } from "./x64.ts";
2
- import { syscallNumbers as syscallNumbersArm64 } from "./arm64.ts";
3
- import { syscallNumbers as syscallNumbersArm } from "./arm.ts";
4
- import nodeProcess from "node:process";
5
-
6
- if (nodeProcess.platform !== "linux") {
7
- throw Error("only supported on linux");
8
- }
9
-
10
- type Common<T, U> = Pick<T, Extract<keyof T, keyof U>>;
11
-
12
- type TCommonSyscallConstants = Common<Common<typeof syscallNumbersX86_64, typeof syscallNumbersArm64>, typeof syscallNumbersArm>;
13
-
14
- type TSyscallConstants = TCommonSyscallConstants &
15
- (Partial<typeof syscallNumbersX86_64> & Partial<typeof syscallNumbersArm64> & Partial<typeof syscallNumbersArm>);
16
-
17
- const syscallNumbersByArch: Partial<{ [key in NodeJS.Architecture]: TSyscallConstants }> = {
18
- x64: syscallNumbersX86_64,
19
- arm64: syscallNumbersArm64,
20
- arm: syscallNumbersArm,
21
- };
22
-
23
- const syscallNumbersOfArch = syscallNumbersByArch[nodeProcess.arch];
24
- if (syscallNumbersOfArch === undefined) {
25
- throw Error(`unsupported architecture: ${nodeProcess.arch}`);
26
- }
27
-
28
- const syscallNumbers = syscallNumbersOfArch!;
29
-
30
- export {
31
- syscallNumbers
32
- };
package/samples/getpid.ts DELETED
@@ -1,12 +0,0 @@
1
- import { syscall, syscallNumbers } from "../lib/index.ts";
2
-
3
- const { errno, ret: pid } = syscall({
4
- syscallNumber: syscallNumbers.getpid,
5
- args: []
6
- });
7
-
8
- if (errno === undefined) {
9
- console.log(`pid = ${pid}`);
10
- } else {
11
- console.log(`errno = ${errno}`);
12
- }