@@ -503,4 +503,11 @@ int safe_sscanf(const char *file, const int lineno, const char *restrict buffer,
#define SAFE_SSCANF(buffer, format, ...) \
safe_sscanf(__FILE__, __LINE__, (buffer), (format), ##__VA_ARGS__)
+struct statx;
+int safe_statx(const char *file, const int lineno,
+ int dirfd, const char *pathname, int flags, unsigned int mask,
+ struct statx *buf);
+#define SAFE_STATX(dirfd, pathname, flags, mask, buf) \
+ safe_statx(__FILE__, __LINE__, (dirfd), (pathname), (flags), (mask), (buf))
+
#endif /* TST_SAFE_MACROS_H__ */
@@ -20,6 +20,7 @@
#include "tst_safe_macros.h"
#include "lapi/personality.h"
#include "lapi/pidfd.h"
+#include "lapi/stat.h"
int safe_access(const char *file, const int lineno,
const char *pathname, int mode)
@@ -710,3 +711,24 @@ int safe_mprotect(const char *file, const int lineno,
return rval;
}
+
+int safe_statx(const char *file, const int lineno,
+ int dirfd, const char *pathname, int flags, unsigned int mask,
+ struct statx *buf)
+{
+ int rval;
+
+ rval = statx(dirfd, pathname, flags, mask, buf);
+
+ if (rval == -1) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "statx(%d,%s,%d,%u,%p) failed", dirfd, pathname, flags, mask, buf);
+ } else if (rval) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "Invalid statx(%d,%s,%d,%u,%p) return value %d",
+ dirfd, pathname, flags, mask, buf,
+ rval);
+ }
+
+ return rval;
+}