[CRIU] [commit] files.c: Use RW API

crtools-bot for Pavel Emelyanov gorcunov at gmail.com
Tue Feb 7 08:18:25 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
--------------->
commit 75cb79973e111da24fa304040294a4a2856c90b0
Author: Pavel Emelyanov <xemul at parallels.com>
Date:   Tue Feb 7 15:49:04 2012 +0400

    files.c: Use RW API
    
    Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 files.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/files.c b/files.c
index 2350049..1b700e4 100644
--- a/files.c
+++ b/files.c
@@ -156,7 +156,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
 
 int prepare_fd_pid(int pid)
 {
-	int fdinfo_fd;
+	int fdinfo_fd, ret = 0;
 	u32 type = 0;
 
 	fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
@@ -168,29 +168,25 @@ int prepare_fd_pid(int pid)
 	}
 
 	while (1) {
-		int ret;
 		struct fdinfo_entry e;
 
-		ret = read(fdinfo_fd, &e, sizeof(e));
-		if (ret == 0)
+		ret = read_img_eof(fdinfo_fd, &e);
+		if (ret <= 0)
 			break;
-		if (ret != sizeof(e)) {
-			pr_perror("%d: Read fdinfo failed %d (expected %li)",
-				  pid, ret, sizeof(e));
-			return -1;
-		}
+
 		if (e.len)
 			lseek(fdinfo_fd, e.len, SEEK_CUR);
 
 		if (fd_is_special(&e))
 			continue;
 
-		if (collect_fd(pid, &e))
-			return -1;
+		ret = collect_fd(pid, &e);
+		if (ret < 0)
+			break;
 	}
 
 	close(fdinfo_fd);
-	return 0;
+	return ret;
 }
 
 static int open_fe_fd(struct fdinfo_entry *fe, int fd)


More information about the CRIU mailing list