Commit 198c9365 authored by Pavel Emelyanov's avatar Pavel Emelyanov

pstree: Add helper for adding helpers to pstree

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 87d68fca
......@@ -240,17 +240,15 @@ static int open_remap_dead_process(struct reg_file_info *rfi,
}
}
helper = alloc_pstree_item_with_rst();
helper = alloc_pstree_helper();
if (!helper)
return -1;
helper->sid = root_item->sid;
helper->pgid = root_item->pgid;
helper->pid.virt = rfe->remap_id;
helper->state = TASK_HELPER;
helper->parent = root_item;
list_add_tail(&helper->sibling, &root_item->children);
task_entries->nr_helpers++;
pr_info("Added a helper for restoring /proc/%d\n", helper->pid.virt);
......
......@@ -62,6 +62,7 @@ extern void free_pstree(struct pstree_item *root_item);
extern struct pstree_item *__alloc_pstree_item(bool rst);
#define alloc_pstree_item() __alloc_pstree_item(false)
#define alloc_pstree_item_with_rst() __alloc_pstree_item(true)
extern struct pstree_item *alloc_pstree_helper(void);
extern struct pstree_item *root_item;
extern struct pstree_item *pstree_item_next(struct pstree_item *item);
......
......@@ -189,6 +189,20 @@ struct pstree_item *__alloc_pstree_item(bool rst)
return item;
}
struct pstree_item *alloc_pstree_helper(void)
{
struct pstree_item *ret;
ret = alloc_pstree_item_with_rst();
if (ret) {
ret->state = TASK_HELPER;
rsti(ret)->clone_flags = CLONE_FILES | CLONE_FS;
task_entries->nr_helpers++;
}
return ret;
}
/* Deep first search on children */
struct pstree_item *pstree_item_next(struct pstree_item *item)
{
......@@ -457,17 +471,14 @@ static int prepare_pstree_ids(void)
if (item->sid == root_item->sid || item->sid == item->pid.virt)
continue;
helper = alloc_pstree_item_with_rst();
helper = alloc_pstree_helper();
if (helper == NULL)
return -1;
helper->sid = item->sid;
helper->pgid = item->sid;
helper->pid.virt = item->sid;
helper->state = TASK_HELPER;
helper->parent = root_item;
rsti(helper)->clone_flags = CLONE_FILES | CLONE_FS;
list_add_tail(&helper->sibling, &helpers);
task_entries->nr_helpers++;
pr_info("Add a helper %d for restoring SID %d\n",
helper->pid.virt, helper->sid);
......@@ -578,17 +589,14 @@ static int prepare_pstree_ids(void)
if (current_pgid == item->pgid)
continue;
helper = alloc_pstree_item_with_rst();
helper = alloc_pstree_helper();
if (helper == NULL)
return -1;
helper->sid = item->sid;
helper->pgid = item->pgid;
helper->pid.virt = item->pgid;
helper->state = TASK_HELPER;
helper->parent = item;
rsti(helper)->clone_flags = CLONE_FILES | CLONE_FS;
list_add(&helper->sibling, &item->children);
task_entries->nr_helpers++;
rsti(item)->pgrp_leader = helper;
pr_info("Add a helper %d for restoring PGID %d\n",
......
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