mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
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>
43 lines
929 B
Bash
Executable File
43 lines
929 B
Bash
Executable File
#!/bin/sh
|
|
# Verify tmpfiles --clean, removing what is older than the age of an entry
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
DIR=/tmp/clean
|
|
CONF=/tmp/clean.conf
|
|
|
|
clean()
|
|
{
|
|
run "cat > $CONF"
|
|
run "/libexec/finit/tmpfiles --clean $CONF"
|
|
}
|
|
|
|
assert_left()
|
|
{
|
|
assert "Left in $1: $2" "$(texec ls "$1" | tr '\n' ' ')" = "$2"
|
|
}
|
|
|
|
test_teardown()
|
|
{
|
|
say "Running test teardown."
|
|
run "umount $DIR/old/mnt 2>/dev/null; rm -rf $DIR $CONF"
|
|
}
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/lib/setup.sh"
|
|
|
|
run "mkdir -p $DIR/old/mnt $DIR/old/sub $DIR/young; touch $DIR/old/file $DIR/old/sub/file $DIR/young/file"
|
|
run "mount -t tmpfs none $DIR/old/mnt; touch $DIR/old/mnt/file"
|
|
sleep 2
|
|
|
|
sep
|
|
say 'Only what is older than the age is removed, and nothing on another file system'
|
|
clean <<CONF
|
|
d $DIR/old - - - 1s
|
|
d $DIR/young - - - 1h
|
|
CONF
|
|
assert_left $DIR/young "file "
|
|
assert_left $DIR/old "mnt "
|
|
assert_left $DIR/old/mnt "file "
|