Show HN: I've updated my Linux System Call website and API (syscall.sh)
175 points by guitmz 10 hours ago
I first released those in back in 2020 and now I finally added more architectures, Kernel selector, syscall descriptions and a few other niceties. It should work a bit better on mobile devices too but I am no CSS expert.
The API is at https://api.syscall.sh
db48x 3 hours ago
It’s a side issue, but I’ve long thought that the kernel should duplicate every existing syscall that takes a null–terminated string by pointer with an otherwise identical syscall that takes the string by pointer, capacity, and length instead. It would be a huge boon to programs written in modern languages. I keep meaning to search the kernel mailing lists to see if the idea has been proposed before, but I never quite find the time.
ozgrakkurt 5 hours ago
Would also recommend using commands like:
echo '#include <sys/syscall.h>' | gcc -E -dM -xc - | grep -i "read"
To get the real values on your PC to make sure.
I had LLMs give wrong numbers or constant definitions several times but getting it to generate a command like this and seeing it for myself works every time.
Also chromium docs has a table:
https://www.chromium.org/chromium-os/developer-library/refer...
It would be very useful to just make this website directly link to the syscall number.
guitmz 4 hours ago
The website content comes directly from Kernel sources so should be accurate. The chromium page is what I used to use until I made this website in 2020 but it's very outdated I think
bkallus 8 hours ago
On x86_64 and x32, the syscall number goes in eax, not rax. The upper 32 bits of rax are ignored and can be anything.
guitmz 8 hours ago
Good catch, thanks! Since 5.14 (I think?) the kernel only reads eax (before that it used all of rax and returned ENOSYS if the upper half wasn't zero), so I'm adding a note about it to the x64 and x32 conventions
bkallus 7 hours ago
According to [1], the kernel has flip-flopped a few times on this, but the original behavior was to ignore the upper 32 bits.
[1] https://lore.kernel.org/all/20210518191303.4135296-5-hpa@zyt...
guitmz 7 hours ago
I also made a CLI for consulting the syscall API when I originally released the website. I think I can tidy up the code and make it public too. It uses a embedded dataset so it does not have to query the API endpoint all the time
wg0 7 hours ago
This is really great resource, didn't know about it. But one question not related to the website above - why the syscalls vary per architecture if the linux API is the same?
Or is it I am confusing it with the C standard library/POSIX and assuming that it should be the same everywhere?
guitmz 7 hours ago
The Linux kernel API is the same everywhere, but the syscall ABI (numbers, calling convention, entry paths) is specific to a architecture, while it's the C library that wraps those details into the portable POSIX API we code against
weli 7 hours ago
Also newer archs (riscv) don't support certain syscalls (open, fork) they are still functions you can call under your standard musl,glibc but they inernally call openat, clone.
tomtomtom777 7 hours ago
I see, but why were they numbered differently? Why not use the same numbers?
guitmz 7 hours ago
DustinBrett 5 hours ago
That website messes with my graphics for some reason.
hmokiguess 6 hours ago
I am not familiar with the internals, so excuse my question, but how does one builds this? Separately, how often can it get stale?
guitmz 6 hours ago
It was stale for many years because I had a script to generate the tables for me that ran manually and then I had to convert the data into SQL so my API could use it (and also convert to html for the frontend). I changed the script to generate the dataset from Kernel sources as JSON instead and the API loads it and makes it available.
Then the frontend is refreshed from the API weekly via a cronjob with some simple Go templating
hmokiguess 5 hours ago
How often does it break or needs changes to this job and template? I am curious on how can this datasource be trusted and to what extent
guitmz 3 hours ago
celesian 3 hours ago
Muito foda TMZ!
guitmz 3 hours ago
É nois!!! Valeu!
shoobiedoo 8 hours ago
This is very handy, thank you. Currently learning aarch64 assembly
w2seraph 5 hours ago
hehehe can't wait to get syscallin'
whalesalad 5 hours ago
Somewhat related - I am working on a dual Pentium III retro build (first retro build) and completely forgot that this would be 32-bit and won't have niceties like SSE2. Having some fun going down the rabbit hole of IDE, SCSI interfaces and AGP graphics. Can anyone recommend some OS installations to play with? So far I am thinking Haiku, ReactOS, NetBSD and antiX or MX Linux. At some point I am also going to simulate a Novell Netware deployment.
guitmz 4 hours ago
Good list, maybe SerenityOS too?
puklessne 4 hours ago
[flagged]
tonglingxujianx 4 hours ago
[flagged]
ReDress 9 hours ago
If syscalls are so similar, for instance, like 'read' and 'readv' or 'pread', 'sendmsg' and 'sendmsgv' or 'fork' and 'vfork'.
Does it still make sense to term or classify them as two distinct syscalls?
PhilipRoman 9 hours ago
I wouldn't call any of them similar, except for 'pread' maybe. Each one has a lot of subtle semantics. Either way, it's syscall.tbl that determines whether they are distinct syscalls, not the author's page
ReDress 9 hours ago
I'm just noting this because it makes the number of Linux syscalls seem very exaggerated at a whole around 400 syscalls.
But, anyways, not like it matters that much but still.
400 distinct syscalls is a very large number of syscalls if you generally presume they're entirely distinct.
adrian_b 9 hours ago
trashb 6 hours ago
Joker_vD 8 hours ago
PhilipRoman 9 hours ago
trashb 6 hours ago
Yes because they have a different "syscall number".
Doesn't really matter if it has the same name or similar (or identical) function. This website seeks to describe the syscall ABI and that means that each number should get it's own entry.
And there is no identical syscalls in the list, they all have slightly different behavior.
It would be nice to make a banner or warning for deprecated or surpassed syscalls. For example (as mentioned in other comments) you should probably use pipe2 instead of pipe and similar other examples.
rustyhancock 9 hours ago
It definitely makes sense to have a section "similar syscalls on this architecture" on the details page.
guitmz 9 hours ago
There's a "Same syscall on other architectures" section already, maybe I could add the Similar section next to it. Edit: but this means it needs a way to actually know they are similar apart from only their names