]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Call real stat from stat stub to get mtime
authorMartin Schwenke <mschwenke@ddn.com>
Sun, 1 Mar 2026 00:01:57 +0000 (11:01 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 9 Jul 2026 16:02:43 +0000 (16:02 +0000)
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/UNIT/eventscripts/stubs/stat

index bc854cf60a51bc02a8a121cc60cbd5d3b4d8c785..4e1fa86a8f1c7a2ab83f3a129e875e8f70df0f29 100755 (executable)
@@ -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