Commit 605b9be8 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

files: make_gen_id -- Promote to be general helper

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: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 67bd254a
......@@ -303,9 +303,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,
......@@ -314,7 +317,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;
......
......@@ -63,6 +63,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment