From 6ba4a6f86811eaa264734012694f5181b00f9abe Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 12 Sep 2023 13:45:47 +0000 Subject: posixify eltest for time checks Signed-off-by: Laurent Bercot --- src/execline/eltest.c | 8 +++++--- tools/gen-multicall.sh | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/execline/eltest.c b/src/execline/eltest.c index 34321c5..d49539d 100644 --- a/src/execline/eltest.c +++ b/src/execline/eltest.c @@ -7,8 +7,10 @@ #include #include +#include #include #include +#include #include enum eltest_opnum_e @@ -360,7 +362,7 @@ static int eltest_run (struct eltest_node_s const *tree, unsigned int root) { struct stat st ; if (stat(tree[tree[root].arg1].data, &st) == -1) return 0 ; - return (st.st_mtime > st.st_atime) ; + return timespec_cmp(&st.ST_MTIM, &st.ST_ATIM) > 0 ; } case T_EUID : { @@ -385,14 +387,14 @@ static int eltest_run (struct eltest_node_s const *tree, unsigned int root) struct stat st1, st2 ; if (stat(tree[tree[root].arg1].data, &st1) == -1) return 0 ; if (stat(tree[tree[root].arg2].data, &st2) == -1) return 1 ; - return st1.st_mtime > st2.st_mtime ; + return timespec_cmp(&st1.ST_MTIM, &st2.ST_MTIM) > 0 ; } case T_OLDER : { struct stat st1, st2 ; if (stat(tree[tree[root].arg1].data, &st1) == -1) return 1 ; if (stat(tree[tree[root].arg2].data, &st2) == -1) return 0 ; - return st1.st_mtime < st2.st_mtime ; + return timespec_cmp(&st1.ST_MTIM, &st2.ST_MTIM) < 0 ; } case T_DEVINO : { diff --git a/tools/gen-multicall.sh b/tools/gen-multicall.sh index fc702ba..959d87b 100755 --- a/tools/gen-multicall.sh +++ b/tools/gen-multicall.sh @@ -17,6 +17,8 @@ cat < #include "exlsn.h" +#include + typedef int main_func (int, char **, char const *const *) ; typedef main_func *main_func_ref ; -- cgit 1.4.1