tmpfiles: extend "Age" to accept an "age-by" argument
authorSrinidhi Kaushik <shrinidhi.kaushik@gmail.com>
Tue, 8 Jun 2021 10:19:48 +0000 (15:49 +0530)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Jun 2021 16:24:58 +0000 (18:24 +0200)
commit7f7a50dd157b3bfb4282c3cc3a56671121eabe24
treed1fd075986945edbf504e85d264352a807c7cc97
parent66973219c0f2569041df69ad368fdb0ebdb8ff78
tmpfiles: extend "Age" to accept an "age-by" argument

For "systemd-tmpfiles --cleanup", when the "Age" parameter
is specified, the criteria for deletion is determined from
the path's last modification timestamp ("mtime"), its last
access timestamp ("atime") and its last status change
timestamp ("ctime").

For instance, if one of those paths to be cleaned up are
opened, it results in the modification of "atime", which
results file system entry to not be removed because the
default aging algorithm would skip the entry.

Add an optional "age-by" argument by extending the "Age"
parameter to restrict the clean-up for a particular type
of file timestamp, which can be specified in "tmpfiles.d"
as follows:

  [age-by:]cleanup-age, where age-by is "[abcmACBM]+"

For example:

  d /foo/bar - - - abM:1m -

Would clean-up any files that were not accessed and created,
or directories that were not modified less than a minute ago
in "/foo/bar".

Fixes: #17002
man/tmpfiles.d.xml
src/tmpfiles/tmpfiles.c
test/units/testsuite-22.12.sh [new file with mode: 0755]