SAFE_MACROS: Add chmod() and fchmod()
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index e8795ef..7bc3f04 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -530,3 +530,33 @@
return rval;
}
+
+int safe_chmod(const char *file, const int lineno,
+ void (cleanup_fn)(void), const char *path, mode_t mode)
+{
+ int rval;
+
+ rval = chmod(path, mode);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "chmod failed at %s:%d", file, lineno);
+ }
+
+ return rval;
+}
+
+int safe_fchmod(const char *file, const int lineno,
+ void (cleanup_fn)(void), int fd, mode_t mode)
+{
+ int rval;
+
+ rval = fchmod(fd, mode);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "fchmod failed at %s:%d", file, lineno);
+ }
+
+ return rval;
+}