From: Martin Schwenke Date: Sun, 1 Mar 2026 00:01:57 +0000 (+1100) Subject: ctdb-tests: Call real stat from stat stub to get mtime X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd0e097499f9c981be24f03da59b56e8ffadb3c7;p=thirdparty%2Fsamba.git ctdb-tests: Call real stat from stat stub to get mtime Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/UNIT/eventscripts/stubs/stat b/ctdb/tests/UNIT/eventscripts/stubs/stat index bc854cf60a5..4e1fa86a8f1 100755 --- a/ctdb/tests/UNIT/eventscripts/stubs/stat +++ b/ctdb/tests/UNIT/eventscripts/stubs/stat @@ -8,9 +8,12 @@ usage() format="" -while getopts "c:h:?" opt; do +# Mix of Linux and FreeBSD options +while getopts "c:f:t:h:?" opt; do case "$opt" in c) format="$OPTARG" ;; + f) format="$OPTARG" ;; + t) : ;; # Ignore and assume seconds since epoch \? | h) usage ;; esac done @@ -39,6 +42,22 @@ fake_inode() } if [ -n "$format" ]; then + case "$format" in + "%m" | "%Y") + # Want the real platform because we want to run the + # platform version of stat + . /etc/os-release + case "$ID" in + freebsd) + exec /usr/bin/stat -f '%m' -t '%s' "$@" + ;; + *) + exec /usr/bin/stat -c "%Y" "$@" + ;; + esac + ;; + esac + rc=0 for f; do if [ ! -e "$f" ]; then