mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
mnt: Factor out mntns nsid creation on restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
aca33ac402
commit
8d5822d9cb
3 changed files with 24 additions and 24 deletions
|
|
@ -50,6 +50,7 @@ extern int switch_ns(int pid, struct ns_desc *nd, int *rst);
|
|||
extern int restore_ns(int rst, struct ns_desc *nd);
|
||||
|
||||
extern int dump_task_ns_ids(struct pstree_item *);
|
||||
extern struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd);
|
||||
extern int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd);
|
||||
extern struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd);
|
||||
|
||||
|
|
|
|||
17
mount.c
17
mount.c
|
|
@ -1423,24 +1423,15 @@ static int rst_collect_local_mntns(void)
|
|||
{
|
||||
struct ns_id *nsid;
|
||||
|
||||
nsid = shmalloc(sizeof(struct ns_id));
|
||||
if (nsid == NULL)
|
||||
nsid = rst_new_ns_id(0, getpid(), &mnt_ns_desc);
|
||||
if (!nsid)
|
||||
return -1;
|
||||
|
||||
nsid->nd = &mnt_ns_desc;
|
||||
nsid->id = 0;
|
||||
nsid->pid = getpid();
|
||||
futex_set(&nsid->created, 1);
|
||||
|
||||
mntinfo = collect_mntinfo(nsid);
|
||||
if (mntinfo == NULL)
|
||||
if (!mntinfo)
|
||||
return -1;
|
||||
|
||||
nsid->next = ns_ids;
|
||||
ns_ids = nsid;
|
||||
|
||||
pr_info("Add namespace %d pid %d\n", nsid->id, nsid->pid);
|
||||
|
||||
futex_set(&nsid->created, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
30
namespaces.c
30
namespaces.c
|
|
@ -117,6 +117,24 @@ struct ns_id *ns_ids = NULL;
|
|||
static unsigned int ns_next_id = 1;
|
||||
unsigned long root_ns_mask = 0;
|
||||
|
||||
struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd)
|
||||
{
|
||||
struct ns_id *nsid;
|
||||
|
||||
nsid = shmalloc(sizeof(*nsid));
|
||||
if (nsid) {
|
||||
nsid->nd = nd;
|
||||
nsid->id = id;
|
||||
nsid->pid = pid;
|
||||
futex_set(&nsid->created, 0);
|
||||
|
||||
nsid->next = ns_ids;
|
||||
ns_ids = nsid;
|
||||
}
|
||||
|
||||
return nsid;
|
||||
}
|
||||
|
||||
int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd)
|
||||
{
|
||||
struct ns_id *nsid;
|
||||
|
|
@ -129,20 +147,10 @@ int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd)
|
|||
}
|
||||
}
|
||||
|
||||
nsid = shmalloc(sizeof(struct ns_id));
|
||||
if (nsid == NULL)
|
||||
if (rst_new_ns_id(id, pid, nd) == NULL)
|
||||
return -1;
|
||||
|
||||
nsid->nd = nd;
|
||||
nsid->id = id;
|
||||
nsid->pid = pid;
|
||||
futex_set(&nsid->created, 0);
|
||||
|
||||
nsid->next = ns_ids;
|
||||
ns_ids = nsid;
|
||||
|
||||
pr_info("Add namespace %d pid %d\n", nsid->id, nsid->pid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue