From 6c8a81097fd305d428891377433d7d88ba1119fd Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 26 May 2024 14:41:33 +0000 Subject: library api's: _util_ (utility helper interfaces) namespace overhaul. --- src/util/tpax_stat_compare.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/util/tpax_stat_compare.c (limited to 'src/util/tpax_stat_compare.c') diff --git a/src/util/tpax_stat_compare.c b/src/util/tpax_stat_compare.c new file mode 100644 index 0000000..2de6922 --- /dev/null +++ b/src/util/tpax_stat_compare.c @@ -0,0 +1,41 @@ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include "tpax_driver_impl.h" + +#define TPAX_STAT_COMPARE(member) \ + if (src -> member - dst -> member) \ + return (src -> member > dst -> member) \ + ? (1) : (-1) + +int tpax_util_stat_compare( + const struct stat * src, + const struct stat * dst) +{ + TPAX_STAT_COMPARE(st_dev); + TPAX_STAT_COMPARE(st_ino); + + TPAX_STAT_COMPARE(st_mode); + TPAX_STAT_COMPARE(st_uid); + TPAX_STAT_COMPARE(st_gid); + + TPAX_STAT_COMPARE(st_rdev); + TPAX_STAT_COMPARE(st_size); + TPAX_STAT_COMPARE(st_blksize); + TPAX_STAT_COMPARE(st_blocks); + + TPAX_STAT_COMPARE(st_mtim.tv_sec); + TPAX_STAT_COMPARE(st_mtim.tv_nsec); + + return 0; +} -- cgit v1.2.3