lib: Add SAFE_MKFIFO()
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/include/safe_macros.h b/include/safe_macros.h
index 1a02a01..ea1e976 100644
--- a/include/safe_macros.h
+++ b/include/safe_macros.h
@@ -256,5 +256,10 @@
#define SAFE_MEMALIGN(cleanup_fn, alignment, size) \
safe_memalign(__FILE__, __LINE__, (cleanup_fn), (alignment), (size))
+int safe_mkfifo(const char *file, const int lineno,
+ void (*cleanup_fn)(void), const char *pathname, mode_t mode);
+#define SAFE_MKFIFO(cleanup_fn, pathname, mode) \
+ safe_mkfifo(__FILE__, __LINE__, (cleanup_fn), (pathname), (mode))
+
#endif /* __SAFE_MACROS_H__ */
#endif /* __TEST_H__ */
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index f482e01..13cc08e 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -737,3 +737,19 @@
return rval;
}
+
+int safe_mkfifo(const char *file, const int lineno,
+ void (*cleanup_fn)(void), const char *pathname, mode_t mode)
+{
+ int rval;
+
+ rval = mkfifo(pathname, mode);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: mkfifo(%s, 0%o) failed",
+ file, lineno, pathname, mode);
+ }
+
+ return rval;
+}