[CRIU] [PATCH v5 17/19] files: make_gen_id -- Promote to be general helper

Cyrill Gorcunov gorcunov at gmail.com
Wed Jul 4 18:51:45 MSK 2018


It is used in files tree generation so we will need
reuse for epoll sake.

Also use the whole 64 bit offset to shuffle bits more.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/files.c         | 11 ++++++++---
 criu/include/files.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 4c5808af4282..b8406b49f52f 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -315,9 +315,12 @@ static int fixup_overlayfs(struct fd_parms *p, struct fd_link *link)
  * The kcmp-ids.c engine does this trick, see comments in it for more info.
  */
 
-static u32 make_gen_id(const struct fd_parms *p)
+uint32_t make_gen_id(uint32_t st_dev, uint32_t st_ino, uint64_t pos)
 {
-	return ((u32)p->stat.st_dev) ^ ((u32)p->stat.st_ino) ^ ((u32)p->pos);
+	uint32_t pos_hi = pos >> 32;
+	uint32_t pos_low = pos & 0xffffffff;
+
+	return st_dev ^ st_ino ^ pos_hi ^ pos_low;
 }
 
 int do_dump_gen_file(struct fd_parms *p, int lfd,
@@ -326,7 +329,9 @@ int do_dump_gen_file(struct fd_parms *p, int lfd,
 	int ret = -1;
 
 	e->type	= ops->type;
-	e->id	= make_gen_id(p);
+	e->id	= make_gen_id((uint32_t)p->stat.st_dev,
+			      (uint32_t)p->stat.st_ino,
+			      (uint64_t)p->pos);
 	e->fd	= p->fd;
 	e->flags = p->fd_flags;
 
diff --git a/criu/include/files.h b/criu/include/files.h
index 052222b4fc56..c490d2a98803 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -64,6 +64,7 @@ struct fd_parms {
 }
 
 extern int fill_fdlink(int lfd, const struct fd_parms *p, struct fd_link *link);
+extern uint32_t make_gen_id(uint32_t st_dev, uint32_t st_ino, uint64_t pos);
 
 struct file_desc;
 
-- 
2.14.4



More information about the CRIU mailing list