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>
An entry with the age 0 was read as having no age, so nothing in its
directory was ever cleaned:
d /var/spool/work - - - 0
tmpfiles --clean t.conf
In tmpfiles.d(5) age 0 means everything in the directory is removed
on each clean. parse_age() returned 0 for both.
It now returns -1 for no age and for one it cannot read, and with
age 0 the timestamps are not looked at.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The x and X entries were read and ignored, so a path that a package
had marked to be left alone was cleaned like the rest:
d /var/tmp - - - 30d
x /var/tmp/keep
tmpfiles --clean t.conf
This removed what was old in /var/tmp/keep.
Gather the x and X entries of all files in a pass before the cleaning,
they may come after the entry they apply to, or in another file. x
keeps the path and what is in it, X the path alone. A directory that
is not empty afterwards is no longer warned about.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Cleaning the directory of an entry with an age went into whatever was
mounted below it:
d /srv - - - 10d
tmpfiles --clean t.conf
With a disk mounted on /srv/data this removed every file on it older
than ten days.
Give nftw() FTW_MOUNT, so it stays on the file system of the directory.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>