26 comments

[ 0.23 ms ] story [ 6.4 ms ] thread
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?

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
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.

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.
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
This is very handy, thank you. Currently learning aarch64 assembly
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?

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
I am not familiar with the internals, so excuse my question, but how does one builds this? Separately, how often can it get stale?
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

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
It was not a problem of the template but rather that I never really "finished" it before so it required manual intervention every time I needed to update the list. I finally put some time into it and it is automated and easily extendable now, so it should continue to work with minimal/no effort.

The data comes directly from the official Kernel source code so it is as official as it gets, I don't change anything just format it in a way my website and API understands

That website messes with my graphics for some reason.
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.

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
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.
Good list, maybe SerenityOS too?
NextStep, GEOS, Quarterdesk/X come to mind ..
hehehe can't wait to get syscallin'
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.
Modern languages .. or more specifically .. modern compilers for those languages .. can surely sustain a pointer, capacity and length wrap to pointer until null ..
Why also capacity?

What I think would make sense is a change to the C API where the error code is an out parameter and not that ugly thread local errno. But I guess that's not big enough of an issue for people/languages that use libc as system call interface.