]> git.ipfire.org Git - thirdparty/systemd.git/commit
fs-util: prefer glibc's fchmodat() if possible
authorLuca Boccassi <luca.boccassi@gmail.com>
Tue, 23 Sep 2025 22:13:23 +0000 (23:13 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 10 Oct 2025 08:36:47 +0000 (10:36 +0200)
commitb465e4816ea2e2e8c39ae348c6600ecd2dcd9c1b
treecede23bb909b1c5d127bf5b69f8a1d0b549a1cb7
parent0db08364fcd915edf691719d0281f4c209c2ae74
fs-util: prefer glibc's fchmodat() if possible

Since v2.39 glibc's fchmodat() will call into the kernel's fchmodat2()
if flags are passed:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=65341f7bbea824d2ff9d37db15d8be162df42bd3;hp=c52c2c32db15aba8bbe1a0b4d3235f97d9c1a525

On older versions, if the flag is anything other than AT_SYMLINK_NOFOLLOW,
it returns EINVAL, so we can detect it and call the kernel syscall directly
ourselves.

Using the glibc wrappers when possible is prefereable so that programs
like fakeroot can intercept its calls and redirect them.

Follow-up for adecfb3bc0be0def49433277fcad5333893756cc

(cherry picked from commit 696b1263dc78858f96345a366933c66d53ae4899)
src/basic/fs-util.c