-
Notifications
You must be signed in to change notification settings - Fork 16
Introduce temporary syscall number definitions under sysdefs/ to replace hardcoded values in Rust #887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Introduce temporary syscall number definitions under sysdefs/ to replace hardcoded values in Rust #887
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| //! Syscall number constants for the Lind platform. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this manually copied over or is there a script, etc.? Is the same information in glibc? How does this + the kernel sync? Is it so slow moving that this doesn't matter?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were manually copied from the Linux x86_64 syscall table. The same numbers are already in glibc's lind_syscall_num.h, so this file is basically the Rust equivalent of that. Since the Linux syscall table is append-only (existing numbers never get reassigned), sync drift isn't really a concern in practice. But yeah, I think auto-generating both the C header and this Rust file from a single source would definitely be cleaner and is a good follow-up to do! |
||
| //! | ||
| //! Source of truth: Linux x86_64 syscall table | ||
| //! https://github.com/torvalds/linux/blob/v6.16-rc1/arch/x86/entry/syscalls/syscall_64.tbl | ||
| //! (Historical overview: https://filippo.io/linux-syscall-table/) | ||
| //! | ||
| //! Keep these in sync with glibc's lind_syscall_num.h and RawPOSIX dispatcher. | ||
|
|
||
| pub const READ_SYSCALL: i32 = 0; | ||
| pub const WRITE_SYSCALL: i32 = 1; | ||
| pub const OPEN_SYSCALL: i32 = 2; | ||
| pub const CLOSE_SYSCALL: i32 = 3; | ||
| pub const STAT_SYSCALL: i32 = 4; | ||
| pub const FSTAT_SYSCALL: i32 = 5; | ||
| pub const POLL_SYSCALL: i32 = 7; | ||
| pub const LSEEK_SYSCALL: i32 = 8; | ||
| pub const MMAP_SYSCALL: i32 = 9; | ||
| pub const MPROTECT_SYSCALL: i32 = 10; | ||
| pub const MUNMAP_SYSCALL: i32 = 11; | ||
| pub const BRK_SYSCALL: i32 = 12; | ||
| pub const SIGACTION_SYSCALL: i32 = 13; | ||
| pub const SIGPROCMASK_SYSCALL: i32 = 14; | ||
| pub const IOCTL_SYSCALL: i32 = 16; | ||
| pub const PREAD_SYSCALL: i32 = 17; | ||
| pub const PWRITE_SYSCALL: i32 = 18; | ||
| pub const READV_SYSCALL: i32 = 19; | ||
| pub const WRITEV_SYSCALL: i32 = 20; | ||
| pub const ACCESS_SYSCALL: i32 = 21; | ||
| pub const PIPE_SYSCALL: i32 = 22; | ||
| pub const SELECT_SYSCALL: i32 = 23; | ||
| pub const SCHED_YIELD_SYSCALL: i32 = 24; | ||
| pub const SHMGET_SYSCALL: i32 = 29; | ||
| pub const SHMAT_SYSCALL: i32 = 30; | ||
| pub const SHMCTL_SYSCALL: i32 = 31; | ||
| pub const DUP_SYSCALL: i32 = 32; | ||
| pub const DUP2_SYSCALL: i32 = 33; | ||
| pub const NANOSLEEP_SYSCALL: i32 = 35; | ||
| pub const SETITIMER_SYSCALL: i32 = 38; | ||
| pub const GETPID_SYSCALL: i32 = 39; | ||
| pub const SOCKET_SYSCALL: i32 = 41; | ||
| pub const CONNECT_SYSCALL: i32 = 42; | ||
| pub const ACCEPT_SYSCALL: i32 = 43; | ||
| pub const SENDTO_SYSCALL: i32 = 44; | ||
| pub const RECVFROM_SYSCALL: i32 = 45; | ||
| pub const SENDMSG_SYSCALL: i32 = 46; | ||
| pub const RECVMSG_SYSCALL: i32 = 47; | ||
| pub const SHUTDOWN_SYSCALL: i32 = 48; | ||
| pub const BIND_SYSCALL: i32 = 49; | ||
| pub const LISTEN_SYSCALL: i32 = 50; | ||
| pub const GETSOCKNAME_SYSCALL: i32 = 51; | ||
| pub const GETPEERNAME_SYSCALL: i32 = 52; | ||
| pub const SOCKETPAIR_SYSCALL: i32 = 53; | ||
| pub const SETSOCKOPT_SYSCALL: i32 = 54; | ||
| pub const GETSOCKOPT_SYSCALL: i32 = 55; | ||
| pub const CLONE_SYSCALL: i32 = 56; | ||
| pub const FORK_SYSCALL: i32 = 57; | ||
| pub const EXEC_SYSCALL: i32 = 59; | ||
| pub const EXIT_SYSCALL: i32 = 60; | ||
| pub const WAITPID_SYSCALL: i32 = 61; | ||
| pub const KILL_SYSCALL: i32 = 62; | ||
| pub const SHMDT_SYSCALL: i32 = 67; | ||
| pub const FCNTL_SYSCALL: i32 = 72; | ||
| pub const FLOCK_SYSCALL: i32 = 73; | ||
| pub const FSYNC_SYSCALL: i32 = 74; | ||
| pub const FDATASYNC_SYSCALL: i32 = 75; | ||
| pub const TRUNCATE_SYSCALL: i32 = 76; | ||
| pub const FTRUNCATE_SYSCALL: i32 = 77; | ||
| pub const GETDENTS_SYSCALL: i32 = 78; | ||
| pub const GETCWD_SYSCALL: i32 = 79; | ||
| pub const CHDIR_SYSCALL: i32 = 80; | ||
| pub const FCHDIR_SYSCALL: i32 = 81; | ||
| pub const RENAME_SYSCALL: i32 = 82; | ||
| pub const MKDIR_SYSCALL: i32 = 83; | ||
| pub const RMDIR_SYSCALL: i32 = 84; | ||
| pub const LINK_SYSCALL: i32 = 86; | ||
| pub const UNLINK_SYSCALL: i32 = 87; | ||
| pub const READLINK_SYSCALL: i32 = 89; | ||
| pub const CHMOD_SYSCALL: i32 = 90; | ||
| pub const FCHMOD_SYSCALL: i32 = 91; | ||
| pub const GETUID_SYSCALL: i32 = 102; | ||
| pub const GETGID_SYSCALL: i32 = 104; | ||
| pub const GETEUID_SYSCALL: i32 = 107; | ||
| pub const GETEGID_SYSCALL: i32 = 108; | ||
| pub const GETPPID_SYSCALL: i32 = 110; | ||
| pub const STATFS_SYSCALL: i32 = 137; | ||
| pub const FSTATFS_SYSCALL: i32 = 138; | ||
| pub const GETHOSTNAME_SYSCALL: i32 = 170; | ||
| pub const FUTEX_SYSCALL: i32 = 202; | ||
| pub const EPOLL_CREATE_SYSCALL: i32 = 213; | ||
| pub const CLOCK_GETTIME_SYSCALL: i32 = 228; | ||
| pub const EPOLL_WAIT_SYSCALL: i32 = 232; | ||
| pub const EPOLL_CTL_SYSCALL: i32 = 233; | ||
| pub const UNLINKAT_SYSCALL: i32 = 263; | ||
| pub const READLINKAT_SYSCALL: i32 = 267; | ||
| pub const SYNC_FILE_RANGE_SYSCALL: i32 = 277; | ||
| pub const EPOLL_CREATE1_SYSCALL: i32 = 291; | ||
| pub const DUP3_SYSCALL: i32 = 292; | ||
| pub const PIPE2_SYSCALL: i32 = 293; | ||
| pub const GETRANDOM_SYSCALL: i32 = 318; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this makes sense. Maybe it should be autogenerated. I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Auto-generation would be the cleaner long-term solution. For now this PR replaces the hardcoded magic numbers with named constants to unblock #612, and we can follow up with a generation script as a next step.