From 8a03334e27393fc2031f071830f9605f4373b0be Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Fri, 19 May 2023 20:22:15 -0700 Subject: [PATCH] FS: added support of OpenBSD for fs.stat() and friends. --- auto/stat | 18 ++++++++++++++++++ external/njs_fs_module.c | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/auto/stat b/auto/stat index 12b209a8..57816be0 100644 --- a/auto/stat +++ b/auto/stat @@ -40,6 +40,24 @@ njs_feature_test="#include . auto/feature +njs_feature="stat.__st_birthtim" +njs_feature_name=NJS_HAVE__STAT_BIRTHTIM +njs_feature_incs= +njs_feature_libs= +njs_feature_test="#include + + int main(void) { + struct stat st; + + if (fstat(0, &st) != 0) { + return 1; + } + + return (int) st.__st_birthtim.tv_sec; + }" +. auto/feature + + njs_feature="stat.st_atim" njs_feature_name=NJS_HAVE_STAT_ATIM njs_feature_incs= diff --git a/external/njs_fs_module.c b/external/njs_fs_module.c index 9ae1b7c7..64c13504 100644 --- a/external/njs_fs_module.c +++ b/external/njs_fs_module.c @@ -3399,8 +3399,6 @@ njs_fs_to_stat(njs_stat_t *dst, struct stat *st) dst->st_mtim.tv_nsec = st->st_mtimespec.tv_nsec; dst->st_ctim.tv_sec = st->st_ctimespec.tv_sec; dst->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec; - dst->st_birthtim.tv_sec = st->st_birthtimespec.tv_sec; - dst->st_birthtim.tv_nsec = st->st_birthtimespec.tv_nsec; #elif (NJS_HAVE_STAT_ATIM) @@ -3414,6 +3412,9 @@ njs_fs_to_stat(njs_stat_t *dst, struct stat *st) #if (NJS_HAVE_STAT_BIRTHTIM) dst->st_birthtim.tv_sec = st->st_birthtim.tv_sec; dst->st_birthtim.tv_nsec = st->st_birthtim.tv_nsec; +#elif (NJS_HAVE__STAT_BIRTHTIM) + dst->st_birthtim.tv_sec = st->__st_birthtim.tv_sec; + dst->st_birthtim.tv_nsec = st->__st_birthtim.tv_nsec; #else dst->st_birthtim.tv_sec = st->st_ctim.tv_sec; dst->st_birthtim.tv_nsec = st->st_ctim.tv_nsec; -- 2.47.3