systemd-tmpfiles: exclude "lost+found" from "D" lines
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 16.7k
- Forks
- 4.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 140
Description
systemd version the issue has been seen with
systemd v241-1 (from Debian buster repositories)
Same issue with current git checkout (commit 1eacc47)
Used distribution
Debian 10 x64
Expected behaviour you didn't see
lost+found not getting touched by systemd-tmpfiles
Unexpected behaviour you saw
lost+found gets cleaned up
Steps to reproduce the problem
Debian systems truncate their /tmp at boot via systemd-tmpfiles-setup.service, configured as
D /tmp 1777 root root -
On our machines /tmp is a separate partition (on LVM, but that should not matter) with ext4 so it is its own mountpoint and contains a lost+found directory.
Since the configurations states TRUNCATE_DIRECTORY we run into this FIXME: https://github.com/systemd/systemd/blob/master/src/tmpfiles/tmpfiles.c#L2143
I replaced the FIXME and a similar one at https://github.com/systemd/systemd/blob/master/src/tmpfiles/tmpfiles.c#L2118 with the call to dir_cleanup() and it seems to fix our problem. But I do not know if that breaks anything else or how to properly handle the cutoff parameter in this case.
Do you have any pointers how to tackle this? I would be happy to submit a pull request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/tmpfiles/tmpfiles.c at the FIXME locations around lines 2118 and 2143, and read how D lines invoke directory cleanup, including the cutoff parameter. Use the reported ext4 /tmp reproduction to verify the behavior. Done means systemd-tmpfiles leaves lost+found untouched while still applying the requested cleanup elsewhere.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100