Files
systemd/src/tmpfiles
Nick c918ac7401 tmpfiles: do not fail --clean when a file disappears during cleanup
dir_cleanup() stores the result of xstatx_full() in r, which is also the
function's return value. If a file is removed between readdir() and
statx(), it is skipped, but when it was the last entry r stays -ENOENT
and --clean fails with EX_CANTCREAT without logging anything. A
successful statx() also overwrote errors recorded for earlier entries.

Use a separate variable for the statx() result.

Reproducer:
  d=$(mktemp -d)
  echo "d $d - - - 1d" >$d.conf
  while :; do touch $d/f{1..200}; rm -f $d/f*; done &
  for i in $(seq 200); do systemd-tmpfiles --clean $d.conf; echo $?; done | sort | uniq -c
  kill %1

Before:
    177 0
     23 73

After:
    200 0

Follow-up for a98a6eb95c.
Follow-up for 10072d8be4.

(cherry picked from commit 4c250e3f1325f91cdee047f7daeaf532abe4af6f)
2026-10-16 17:24:51 +01:00
..