5 ms·
I think there's a general push to have dirfd versions of all syscalls, since it makes it easier to write libraries that don't break when the application or anot
by remexre 5y ago
I think there's a general push to have dirfd versions of all syscalls, since it makes it easier to write libraries that don't break when the application or another library chdir()s.
- MichaelMoser123 5y agothanks, makes sense. Still interesting that nowadays they are not afraid to add non posix syscalls to linux and glibc (like c); i think that several years ago they were less likely to do that. I would be afraid to use all these new additions in an application; you couldn't use that with a docker container on an older system (docker uses the same kernel/glibc as the host)
- Denvercoder9 5y ago> docker uses the same kernel/glibc as the host Docker containers usesthe same kernel as the host, but the libc comes from the container.
- MichaelMoser123 5y agobut for syscalls libc calls down into the kernel; libc and the kernel are a pair of shoes.
- Denvercoder9 5y ago> libc and the kernel are a pair of shoes. Not really. The kernel obviously is compatible with older versions of libc, but glibc is also compatible with older kernel versions (down to 3.2 for the latest version), and it even attempts to emulate some system calls if your kernel doesn't support them. You've quite some freedom to mix versions.
- MichaelMoser123 5y agohere is the present source code for glibc where faccessat2 is used. What you say is true for some cases; if glibc is built for kernel versions below 0x050800 then it doesn't assume faccessat2, here it falls back to faccessat for some cases - and faccessat was added in 2.6.16. But if you have flags other than AT_SYMLINK_NOFOLLOW or AT_EACCESS the call just fails without doing the fallback. See https://github.com/bminor/glibc/blob/595c22ecd8e87a27fd19270ed30fdbae9ad25426/sysdeps/unix/sysv/linux/faccessat.c#L36 https://github.com/bminor/glibc/blob/595c22ecd8e87a27fd19270... TIL that this this glibc mirror is kept in sync with the real one https://github.com/bminor/glibc https://github.com/bminor/glibc