summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-16 21:46:06 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commitc6ae1d5ea25ed266ee2bda924179ec715c99e762 (patch)
treefe049e031c3c6070d4fb767189c551e3d1ba8e00 /util/nvmutil/nvmutil.c
parent6e6ab09cb034afb6f96eefc781f891db5fb98e91 (diff)
comment
also improved the macro, making it stricter Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 5401c2eb..10b42598 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -714,11 +714,25 @@ ino_t tmp_ino;
int tmp_fd = -1;
char *tname = NULL;
+/*
+ * Used for checking whether.
+ * a file is a file via stat().
+ *
+ * Portable macro for compatibility
+ * with older unix e.g. v7 unix (has S_IFREG),
+ * 4.2bsd (has S_IFMT) or POSIX (has S_ISREG)
+ *
+ * Fallback works where S_IFREG == 0100000
+ * (classic unix bitmask)
+ */
+
#ifndef S_ISREG
-#ifdef S_IFMT
-#define S_ISREG(m) (((m) & (S_IFMT)) == (S_IFREG))
+#if defined(S_IFMT) && defined(S_IFREG)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#elif defined(S_IFREG)
+#define S_ISREG(m) (((m) & S_IFREG) != 0)
#else
-#define S_ISREG(m) (((m) & (S_IFREG)) == (S_IFREG))
+#error "can't determine types with stat()"
#endif
#endif