2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

pstree: Change arguments in parse_pid_status()

Pass task or thread there.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2017-05-05 19:14:06 +03:00
committed by Andrei Vagin
parent d308a86f2a
commit 096bb4071e
3 changed files with 18 additions and 5 deletions

View File

@@ -96,7 +96,8 @@ extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s);
extern unsigned int parse_pid_loginuid(pid_t pid, int *err, bool ignore_noent);
extern int parse_pid_oom_score_adj(pid_t pid, int *err);
extern int prepare_loginuid(unsigned int value, unsigned int loglevel);
extern int parse_pid_status(pid_t pid, struct seize_task_status *, void *data);
extern int parse_pid_status(pid_t pid, struct seize_task_status *,
struct pstree_item *, struct pid **);
extern int parse_file_locks(void);
extern int get_fd_mntid(int fd, int *mnt_id);

View File

@@ -1037,7 +1037,8 @@ static int cap_parse(char *str, unsigned int *res)
return 0;
}
int parse_pid_status(pid_t pid, struct seize_task_status *ss, void *data)
int parse_pid_status(pid_t pid, struct seize_task_status *ss,
struct pstree_item *item, struct pid **thread)
{
struct proc_status_creds *cr = container_of(ss, struct proc_status_creds, s);
struct bfd f;

View File

@@ -445,6 +445,11 @@ static inline bool child_collected(struct pstree_item *i, pid_t pid)
return false;
}
static int parse_task_status(int pid, struct seize_task_status *ss, void *item)
{
return parse_pid_status(pid, ss, item, NULL);
}
static int collect_task(struct pstree_item *item);
static int collect_children(struct pstree_item *item)
{
@@ -490,7 +495,7 @@ static int collect_children(struct pstree_item *item)
goto free;
}
ret = compel_wait_task(pid, item->pid->real, parse_pid_status, NULL, &creds->s, NULL);
ret = compel_wait_task(pid, item->pid->real, parse_task_status, NULL, &creds->s, c);
if (ret < 0) {
/*
* Here is a race window between parse_children() and seize(),
@@ -666,6 +671,11 @@ static bool creds_dumpable(struct proc_status_creds *parent,
return true;
}
static int parse_thread_status(int pid, struct seize_task_status *ss, void *thread)
{
return parse_pid_status(pid, ss, NULL, thread);
}
static int collect_threads(struct pstree_item *item)
{
struct pid **threads = NULL;
@@ -711,7 +721,8 @@ static int collect_threads(struct pstree_item *item)
if (!opts.freeze_cgroup && compel_interrupt_task(pid))
continue;
ret = compel_wait_task(pid, item_ppid(item), parse_pid_status, NULL, &t_creds.s, NULL);
ret = compel_wait_task(pid, item_ppid(item), parse_thread_status, NULL,
&t_creds.s, &item->threads[item->nr_threads]);
if (ret < 0) {
/*
* Here is a race window between parse_threads() and seize(),
@@ -858,7 +869,7 @@ int collect_pstree(void)
if (!creds)
goto err;
ret = compel_wait_task(pid, -1, parse_pid_status, NULL, &creds->s, NULL);
ret = compel_wait_task(pid, -1, parse_task_status, NULL, &creds->s, root_item);
if (ret < 0)
goto err;