Hacker News new | ask | show | jobs
by adrian_b 32 days ago
The number of Linux syscalls depends on the architecture and on x86-64 there are over 450 Linux syscalls.

Nonetheless, about one third of those syscalls are obsolete (being replaced by newer improved syscalls), even if a large number of programs are still using them, and about one other third of them are rarely used in the environments familiar to most Linux users, like personal computers and small servers.

The obsolete syscalls inflate a lot the number of Linux syscalls, because there are a lot of syscalls that were originally defined with an inadequate set of parameters, then they were fixed by adding parameters or changing the meaning of the existing parameters. There are many syscalls were even 3 or 4 attempts were needed until reaching an acceptable definition for their parameters.

New programs should use only the newest improved syscalls, but the documentation of the Linux syscalls in various places is usually not up-to-date itself, so a lot of people are still using older syscalls, without being aware that they are suboptimal. So the obsolete syscalls will have to be supported forever by the Linux kernels (though in most cases when an obsolete syscall is invoked it just fills the parameters with adjusted values and then it jumps to the current syscall).

1 comments

I'd love to learn more about the syscalls that took 3 or 4 attempts.
Well, from a quick look, Linux has dup/dup2/dup3 and clone/clone2/clone3 . I don't see anything that took 4, but there are things like accept/acccept4 and where the second one takes four arguments and wait4 which takes 4 arguments, but wait3 was already obsolete before Linux or FreeBSD started numbering syscalls. (I'm lazy and only looking on systems I have)

It's not some Linux specific issue either. FreeBSD has three versions of statfs/fstatsfs/truncate/ftruncate.

A lot of the file related syscalls also have a XXXXat (ex: open/openat) variant taking a directory reference instead of using cwd.