mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
file-ids: Report whether a new id was generated
This will be required to determine whether we should dump the respective file, or it was already dumped and we just re-use its id in fdinfo_entry. For special fd-s the ID is always new. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
16
file-ids.c
16
file-ids.c
@@ -154,7 +154,7 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct fd_id_entry *fd_id_generate_sub(struct fd_id_entry *e,
|
static struct fd_id_entry *fd_id_generate_sub(struct fd_id_entry *e,
|
||||||
pid_t pid, struct fdinfo_entry *fe)
|
pid_t pid, struct fdinfo_entry *fe, int *new_id)
|
||||||
{
|
{
|
||||||
struct rb_node *node = e->subtree_root.rb_node;
|
struct rb_node *node = e->subtree_root.rb_node;
|
||||||
struct fd_id_entry *sub = NULL;
|
struct fd_id_entry *sub = NULL;
|
||||||
@@ -182,10 +182,12 @@ static struct fd_id_entry *fd_id_generate_sub(struct fd_id_entry *e,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rb_link_and_balance(&e->subtree_root, &sub->subtree_node, parent, new);
|
rb_link_and_balance(&e->subtree_root, &sub->subtree_node, parent, new);
|
||||||
|
*new_id = 1;
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct fd_id_entry *fd_id_generate_gen(pid_t pid, struct fdinfo_entry *fe)
|
static struct fd_id_entry *fd_id_generate_gen(pid_t pid,
|
||||||
|
struct fdinfo_entry *fe, int *new_id)
|
||||||
{
|
{
|
||||||
struct rb_node *node = fd_id_root.rb_node;
|
struct rb_node *node = fd_id_root.rb_node;
|
||||||
struct fd_id_entry *e = NULL;
|
struct fd_id_entry *e = NULL;
|
||||||
@@ -202,7 +204,7 @@ static struct fd_id_entry *fd_id_generate_gen(pid_t pid, struct fdinfo_entry *fe
|
|||||||
else if (fe->id > this->genid)
|
else if (fe->id > this->genid)
|
||||||
node = node->rb_right, new = &((*new)->rb_right);
|
node = node->rb_right, new = &((*new)->rb_right);
|
||||||
else
|
else
|
||||||
return fd_id_generate_sub(this, pid, fe);
|
return fd_id_generate_sub(this, pid, fe, new_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
e = alloc_fd_id_entry(pid, fe);
|
e = alloc_fd_id_entry(pid, fe);
|
||||||
@@ -210,6 +212,7 @@ static struct fd_id_entry *fd_id_generate_gen(pid_t pid, struct fdinfo_entry *fe
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rb_link_and_balance(&fd_id_root, &e->node, parent, new);
|
rb_link_and_balance(&fd_id_root, &e->node, parent, new);
|
||||||
|
*new_id = 1;
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -217,16 +220,17 @@ static struct fd_id_entry *fd_id_generate_gen(pid_t pid, struct fdinfo_entry *fe
|
|||||||
int fd_id_generate(pid_t pid, struct fdinfo_entry *fe)
|
int fd_id_generate(pid_t pid, struct fdinfo_entry *fe)
|
||||||
{
|
{
|
||||||
struct fd_id_entry *fid;
|
struct fd_id_entry *fid;
|
||||||
|
int new_id = 0;
|
||||||
|
|
||||||
if (fd_is_special(fe)) {
|
if (fd_is_special(fe)) {
|
||||||
fe->id = fd_id_entries_subid++;
|
fe->id = fd_id_entries_subid++;
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fid = fd_id_generate_gen(pid, fe);
|
fid = fd_id_generate_gen(pid, fe, &new_id);
|
||||||
if (!fid)
|
if (!fid)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
fe->id = fid->subid;
|
fe->id = fid->subid;
|
||||||
return 0;
|
return new_id;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user