]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/stat-util: avoid access syscall
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 24 Jul 2025 13:09:58 +0000 (15:09 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 27 Jul 2025 11:13:43 +0000 (13:13 +0200)
commitc136be3f04bf2c96e99a7466deb4eb491fb117b2
tree21a89484269b68258a5c48a148857443c2508fe0
parent9154cc7e80787e0c42b547c4305941b316d772d4
basic/stat-util: avoid access syscall

I was looking at strace for systemd-getty-generator and noticed the call to
faccessat2(3</sys>, "", W_OK, AT_EMPTY_PATH), even though we already did
fstatfs(3</sys>), which should give us all the necessary information. Let's
only do this additional check when it's likely to yield something useful, i.e.
for network fses and otherwise skip the syscall.

The call to statvfs is replaced by statfs because that gives us the .f_type
field and allows is_network_fs() to be called.

I'm a bit worried that the is_network_fs() is somewhat costly. This will be
improved in later commits.
src/basic/stat-util.c