@@ -509,4 +509,10 @@ int safe_prctl(const char *file, const int lineno,
#define SAFE_PRCTL(option, arg2, arg3, arg4, arg5) \
safe_prctl(__FILE__, __LINE__, (option), (arg2), (arg3), (arg4), (arg5))
+int safe_symlinkat(const char *file, const int lineno,
+ const char *oldpath, const int newdirfd, const char *newpath);
+
+#define SAFE_SYMLINKAT(oldpath, newdirfd, newpath) \
+ safe_symlinkat(__FILE__, __LINE__, (oldpath), (newdirfd), (newpath))
+
#endif /* TST_SAFE_MACROS_H__ */
@@ -731,3 +731,23 @@ int safe_prctl(const char *file, const int lineno,
return rval;
}
+
+int safe_symlinkat(const char *file, const int lineno,
+ const char *oldpath, const int newdirfd, const char *newpath)
+{
+ int rval;
+
+ rval = symlinkat(oldpath, newdirfd, newpath);
+
+ if (rval == -1) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "symlinkat(%s,%d,%s) failed", oldpath, newdirfd, newpath);
+ } else if (rval) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "Invalid symlinkat(%s,%d,%s) return value %d", oldpath,
+ newdirfd, newpath, rval);
+ }
+
+ return rval;
+}
+