Hacker News new | ask | show | jobs
by matheusmoreira 2237 days ago
You absolutely can use system calls in your code. The kernel has an awesome header that makes this easy and allows you to eliminate all dependencies:

https://github.com/torvalds/linux/blob/master/tools/include/...

This system call avoidance dogma exists because libraries generally have more convenient interfaces and are therefore easier to use. They're not strictly necessary though.

It should be noted that using certain system calls may cause problems with the libraries you're using. For example, glibc needs to maintain complete control over the threading model in order to implement thread-local storage. By issuing a clone system call directly, the glibc threading model is broken and even something simple like errno is likely to break.

In my opinion, libraries shouldn't contain thread-local or global variables in the first place. Unfortunately, the C language is old and these problems will never be fixed. It's possible to create better libraries in freestanding C or even freestanding Rust but replacing what already exists is a lifetime of work.

> What exactly is liburing bringing to the table that I shouldn't be using the uring syscalls directly?

It's easier to use compared to the kernel interface. For example, it handles submission queue polling automatically without any extra code.