[CRIU] [PATCH 08/11] criu: util -- Add __read_fd_link helper

Cyrill Gorcunov gorcunov at openvz.org
Tue Aug 2 08:34:34 PDT 2016


From: Cyrill Gorcunov <gorcunov at virtuozzo.com>

Same as read_fd_link but uses local static buffer,
suitable when need to print path for logging.

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/include/util.h |  1 +
 criu/util.c         | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/criu/include/util.h b/criu/include/util.h
index e297f68bd301..b1301bbb2c66 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -186,6 +186,7 @@ extern int is_empty_dir(int dirfd);
 #define PSFDS	(sizeof("/proc/self/fd/2147483647"))
 
 extern int read_fd_link(int lfd, char *buf, size_t size);
+extern char *__read_fd_link(int fd);
 
 #define USEC_PER_SEC	1000000L
 #define NSEC_PER_SEC    1000000000L
diff --git a/criu/util.c b/criu/util.c
index 4598f343d93f..e0044ff5928e 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -556,6 +556,18 @@ int read_fd_link(int lfd, char *buf, size_t size)
 	return ret;
 }
 
+char *__read_fd_link(int fd)
+{
+	static char buf[PATH_MAX];
+	int ret;
+
+	ret = read_fd_link(fd, buf, sizeof(buf));
+	if (ret < 0)
+		buf[0] = '\0';
+
+	return buf;
+}
+
 int is_anon_link_type(char *link, char *type)
 {
 	char aux[32];
-- 
2.7.4



More information about the CRIU mailing list