lib/safe_macros: add readlink()
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 9fa6ac4..5a05c84 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -409,6 +409,23 @@
return rval;
}
+ssize_t safe_readlink(const char *file, const int lineno,
+ void (cleanup_fn)(void), const char *path,
+ char *buf, size_t bufsize)
+{
+ ssize_t rval;
+
+ rval = readlink(path, buf, bufsize);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: readlink(%s,%p,%zu) failed",
+ file, lineno, path, buf, bufsize);
+ }
+
+ return rval;
+}
+
int safe_symlink(const char *file, const int lineno,
void (cleanup_fn)(void), const char *oldpath,
const char *newpath)