tmpfiles: read all of the age formats in tmpfiles.d(5)

Only one number with one unit was read from the age of an entry.  An
age like this one was taken as two days:

    d /var/tmp 1777 root root 2d12h

What came after the first unit was not looked at.  ms and us were not
known, so 500ms gave no cleaning at all.

Read any number of values with units, us, ms, s, m or min, h, d, and
w, and refuse an age that cannot be read or that overflows.  Add the ~
prefix, which keeps what is right in the directory, and the prefix
that says which timestamps to go by, e.g. "aAmM:" for access and
modification time of files and directories.

Without that prefix the birth time of a file now counts too, as in
tmpfiles.d(5).  It is read with statx(), where the C library has it,
and left out on a file system that has none.

A prefix that names timestamps for files only, or directories only,
leaves the default set for the other.  The age is capped at what a 32
bit time_t holds, and nothing is cleaned when it reaches back past
the epoch.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:03:33 +01:00
1 parent b87d235cf7
commit 9d49eaf4c7
6 files changed
+189 -88

No files matched your search

+5
View File
@@ -21,6 +21,11 @@ All relevant changes are documented in this file.
and the user ones `%u`, `%U`, `%g`, `%G`. Before, an entry with a `%`
in the path was skipped. **Note:** a literal `%` in such an argument,
e.g. in a `w` entry for `core_pattern`, must now be written `%%`
- tmpfiles: the age of an entry can now have several units, as in
`1d12h`, also `ms`, `us`, and `min`. New are the `~` prefix, to keep
what is right in the directory, and a choice of the timestamps to go
by, as in `aAmM:10d`. The birth time of a file now counts too, like
its other timestamps, when the file system has one
- tmpfiles: the `v`, `q`, and `Q` entries now make a plain directory, like
`d`. Finit has no support for btrfs subvolumes, and before the entries
were skipped as unsupported