[CRIU] [PATCH 07/21] dump: Use read_proc_selffd_link in
dump_one_reg_file
Cyrill Gorcunov
gorcunov at openvz.org
Wed Jun 6 18:21:47 EDT 2012
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-dump.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 94ff67a..1b6c2f6 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -46,7 +46,6 @@
# error No x86-32 support yet
#endif
-static char big_buffer[PATH_MAX];
static char loc_buf[PAGE_SIZE];
static struct pstree_item *root_item = NULL;
@@ -280,22 +279,18 @@ static int check_path_remap(char *path, const struct stat *ost, int lfd, u32 id)
static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
{
- char fd_str[128];
- int len, rfd;
struct reg_file_entry rfe;
+ char *path;
+ int len, rfd;
- snprintf(fd_str, sizeof(fd_str), "/proc/self/fd/%d", lfd);
- len = readlink(fd_str, big_buffer, sizeof(big_buffer) - 1);
- if (len < 0) {
- pr_perror("Can't readlink %s", fd_str);
- return len;
- }
+ path = read_proc_selffd_link(lfd, &len);
+ if (!path)
+ return -1;
- big_buffer[len] = '\0';
pr_info("Dumping path for %d fd via self %d [%s]\n",
- p->fd, lfd, big_buffer);
+ p->fd, lfd, path);
- if (check_path_remap(big_buffer, &p->stat, lfd, id))
+ if (check_path_remap(path, &p->stat, lfd, id))
return -1;
rfe.len = len;
@@ -308,7 +303,7 @@ static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
if (write_img(rfd, &rfe))
return -1;
- if (write_img_buf(rfd, big_buffer, len))
+ if (write_img_buf(rfd, path, len))
return -1;
return 0;
--
1.7.7.6
More information about the CRIU
mailing list