Signed-off-by: Andrey Vagin <avagin@xxxxxxxxxx> --- include/uapi/linux/task_diag.h | 1 + kernel/taskdiag.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/task_diag.h b/include/uapi/linux/task_diag.h index 9e4c3c4..e1d09e6 100644 --- a/include/uapi/linux/task_diag.h +++ b/include/uapi/linux/task_diag.h @@ -150,6 +150,7 @@ static inline struct task_diag_vma_stat *task_diag_vma_stat(struct task_diag_vma #define TASK_DIAG_DUMP_ALL 0 #define TASK_DIAG_DUMP_CHILDREN 1 +#define TASK_DIAG_DUMP_THREAD 2 struct task_diag_pid { __u64 show_flags; diff --git a/kernel/taskdiag.c b/kernel/taskdiag.c index 8e00c3e..dc319bf 100644 --- a/kernel/taskdiag.c +++ b/kernel/taskdiag.c @@ -559,8 +559,15 @@ static struct task_struct *iter_start(struct task_iter *iter) } switch (iter->req.dump_strategy) { - case TASK_DIAG_DUMP_CHILDREN: + case TASK_DIAG_DUMP_THREAD: + if (iter->parent == NULL) + return ERR_PTR(-ESRCH); + + iter->pos = iter->cb->args[0]; + iter->task = task_first_tid(iter->parent, 0, iter->pos, iter->ns); + return iter->task; + case TASK_DIAG_DUMP_CHILDREN: if (iter->parent == NULL) return ERR_PTR(-ESRCH); @@ -581,6 +588,12 @@ static struct task_struct *iter_start(struct task_iter *iter) static struct task_struct *iter_next(struct task_iter *iter) { switch (iter->req.dump_strategy) { + case TASK_DIAG_DUMP_THREAD: + iter->pos++; + iter->task = task_next_tid(iter->task); + iter->cb->args[0] = iter->pos; + iter->cb->args[1] = task_pid_nr_ns(iter->task, iter->ns); + return iter->task; case TASK_DIAG_DUMP_CHILDREN: iter->pos++; iter->task = task_next_child(iter->parent, iter->task, iter->pos); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html