[CRIU] [PATCH] files: declare fd_params->pos as off_t

Andrew Vagin avagin at openvz.org
Wed Aug 28 17:22:52 EDT 2013


From: root <root at raspberrypi.(none)>

Currently pos has type unsigned long, so its size depends on
architecture. pos is saved as 64-bit value in the image file and it
isn't restored, if it is equal to -1. Due to convertation on 32-bit
platforms -1 is converted into UINT_MAX and we get error on restore.

$ zdtm.sh ns/static/tun
...
(00.398513)      5: Error (files-reg.c:534): Can't restore file pos: Illegal seek
(00.398888)      5: Error (files-reg.c:489): Can't open file /dev/net/tun: Illegal seek
...
id: 0x15 flags: 0x2 pos: 0x000000ffffffff fown: { uid: 0 euid: 0 signum: 0 pid_type: 0 pid: 0 }  name: "/dev/net/tun"

crtools is compiled with _FILE_OFFSET_BITS=64, so off_t is always 64-bit.

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 files.c         | 4 ++--
 include/files.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/files.c b/files.c
index 37dc89f..d8085ee 100644
--- a/files.c
+++ b/files.c
@@ -133,7 +133,7 @@ int do_dump_gen_file(struct fd_parms *p, int lfd,
 	if (ret < 0)
 		return -1;
 
-	pr_info("fdinfo: type: 0x%2x flags: %#o/%#o pos: 0x%8lx fd: %d\n",
+	pr_info("fdinfo: type: 0x%2x flags: %#o/%#o pos: 0x%8"PRIx64" fd: %d\n",
 		ops->type, p->flags, (int)p->fd_flags, p->pos, p->fd);
 
 	return pb_write_one(fdinfo, &e, PB_FDINFO);
@@ -179,7 +179,7 @@ static int fill_fd_params(struct parasite_ctl *ctl, int fd, int lfd,
 
 	fown_entry__init(&p->fown);
 
-	pr_info("%d fdinfo %d: pos: 0x%16lx flags: %16o/%#x\n",
+	pr_info("%d fdinfo %d: pos: 0x%16"PRIx64" flags: %16o/%#x\n",
 		ctl->pid.real, fd, p->pos, p->flags, (int)p->fd_flags);
 
 	ret = fcntl(lfd, F_GETSIG, 0);
diff --git a/include/files.h b/include/files.h
index c92f3ed..2e3ac14 100644
--- a/include/files.h
+++ b/include/files.h
@@ -35,7 +35,7 @@ struct fd_link {
 
 struct fd_parms {
 	int		fd;
-	unsigned long	pos;
+	off_t		pos;
 	unsigned int	flags;
 	char		fd_flags;
 	struct stat	stat;
-- 
1.8.3.1



More information about the CRIU mailing list