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 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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 : { -- cgit v1.2.3