@@ -122,6 +122,10 @@ int safe_symlink(const char *file, const int lineno,
void (cleanup_fn)(void), const char *oldpath,
const char *newpath);
+int safe_symlinkat(const char *file, const int lineno,
+ void (cleanup_fn)(void), const char *oldpath,
+ const int newdirfd, const char *newpath);
+
ssize_t safe_write(const char *file, const int lineno,
void (cleanup_fn)(void), enum safe_write_opts len_strict,
int fildes, const void *buf, size_t nbyte);
@@ -191,6 +191,9 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
#define SAFE_SYMLINK(oldpath, newpath) \
safe_symlink(__FILE__, __LINE__, NULL, (oldpath), (newpath))
+#define SAFE_SYMLINKAT(oldpath, newdirfd, newpath) \
+ safe_symlinkat(__FILE__, __LINE__, NULL, (oldpath), (newdirfd), (newpath))
+
#define SAFE_WRITE(len_strict, fildes, buf, nbyte) \
safe_write(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
@@ -527,6 +527,26 @@ int safe_symlink(const char *file, const int lineno,
return rval;
}
+int safe_symlinkat(const char *file, const int lineno,
+ void (cleanup_fn)(void), const char *oldpath,
+ const int newdirfd, const char *newpath)
+{
+ int rval;
+
+ rval = symlinkat(oldpath, newdirfd, newpath);
+
+ if (rval == -1) {
+ tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+ "symlinkat(%s,%d,%s) failed", oldpath, newdirfd, newpath);
+ } else if (rval) {
+ tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+ "Invalid symlinkat(%s,%d,%s) return value %d", oldpath,
+ newdirfd, newpath, rval);
+ }
+
+ return rval;
+}
+
ssize_t safe_write(const char *file, const int lineno, void (cleanup_fn) (void),
enum safe_write_opts len_strict, int fildes, const void *buf,
size_t nbyte)