[CRIU] [PATCH 04/10] files: Move make_gen_id into separate helper
Cyrill Gorcunov
gorcunov at openvz.org
Tue Feb 28 07:05:43 PST 2017
I'll need it for epoll targets. Thus move it
into header and name more general.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/files.c | 17 +++--------------
criu/include/file-ids.h | 14 ++++++++++++++
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index 324115b1a33a..564ce540ed98 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -265,19 +265,6 @@ static int fixup_overlayfs(struct fd_parms *p, struct fd_link *link)
return 0;
}
-/*
- * The gen_id thing is used to optimize the comparison of shared files.
- * If two files have different gen_ids, then they are different for sure.
- * If it matches, we don't know it and have to call sys_kcmp().
- *
- * 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)
-{
- return ((u32)p->stat.st_dev) ^ ((u32)p->stat.st_ino) ^ ((u32)p->pos);
-}
-
int do_dump_gen_file(struct fd_parms *p, int lfd,
const struct fdtype_ops *ops, struct cr_img *img)
{
@@ -285,7 +272,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 = kcmp_fd_make_gen_id((uint32_t)p->stat.st_dev,
+ (uint32_t)p->stat.st_ino,
+ (uint32_t)p->pos);
e.fd = p->fd;
e.flags = p->fd_flags;
diff --git a/criu/include/file-ids.h b/criu/include/file-ids.h
index 845cfaa9f9db..e796f403a57e 100644
--- a/criu/include/file-ids.h
+++ b/criu/include/file-ids.h
@@ -1,6 +1,8 @@
#ifndef __CR_FILE_IDS_H__
#define __CR_FILE_IDS_H__
+#include <stdint.h>
+
#include "common/compiler.h"
#include "rbtree.h"
@@ -16,4 +18,16 @@ struct fd_parms;
extern int fd_id_generate(pid_t pid, FdinfoEntry *fe, struct fd_parms *p);
extern int fd_id_generate_special(struct fd_parms *p, u32 *id);
+/*
+ * The gen_id thing is used to optimize the comparison of shared files.
+ * If two files have different gen_ids, then they are different for sure.
+ * If it matches, we don't know it and have to call sys_kcmp().
+ *
+ * The kcmp-ids.c engine does this trick, see comments in it for more info.
+ */
+static inline uint32_t kcmp_fd_make_gen_id(uint32_t st_dev, uint32_t st_ino, uint32_t f_pos)
+{
+ return st_dev ^ st_ino ^ f_pos;
+}
+
#endif /* __CR_FILE_IDS_H__ */
--
2.7.4
More information about the CRIU
mailing list