Skip to content

Commit 2e521a2

Browse files
committed
exit: add internal include file with helpers
Move struct wait_opts and waitid_info into kernel/exit.h, and include function declarations for the recently added helpers. Make them non-static as well. This is in preparation for adding a waitid operation through io_uring. With the abtracted helpers, this is now possible. Signed-off-by: Jens Axboe <[email protected]>
1 parent eda7e9d commit 2e521a2

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

kernel/exit.c

+7-25
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
#include <asm/unistd.h>
7575
#include <asm/mmu_context.h>
7676

77+
#include "exit.h"
78+
7779
/*
7880
* The default value should be high enough to not crash a system that randomly
7981
* crashes its kernel from time to time, but low enough to at least not permit
@@ -1037,26 +1039,6 @@ SYSCALL_DEFINE1(exit_group, int, error_code)
10371039
return 0;
10381040
}
10391041

1040-
struct waitid_info {
1041-
pid_t pid;
1042-
uid_t uid;
1043-
int status;
1044-
int cause;
1045-
};
1046-
1047-
struct wait_opts {
1048-
enum pid_type wo_type;
1049-
int wo_flags;
1050-
struct pid *wo_pid;
1051-
1052-
struct waitid_info *wo_info;
1053-
int wo_stat;
1054-
struct rusage *wo_rusage;
1055-
1056-
wait_queue_entry_t child_wait;
1057-
int notask_error;
1058-
};
1059-
10601042
static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
10611043
{
10621044
return wo->wo_type == PIDTYPE_MAX ||
@@ -1520,7 +1502,7 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk)
15201502
return 0;
15211503
}
15221504

1523-
static bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
1505+
bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
15241506
{
15251507
if (!eligible_pid(wo, p))
15261508
return false;
@@ -1590,7 +1572,7 @@ static int do_wait_pid(struct wait_opts *wo)
15901572
return 0;
15911573
}
15921574

1593-
static long __do_wait(struct wait_opts *wo)
1575+
long __do_wait(struct wait_opts *wo)
15941576
{
15951577
long retval;
15961578

@@ -1662,9 +1644,9 @@ static long do_wait(struct wait_opts *wo)
16621644
return retval;
16631645
}
16641646

1665-
static int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
1666-
struct waitid_info *infop, int options,
1667-
struct rusage *ru)
1647+
int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
1648+
struct waitid_info *infop, int options,
1649+
struct rusage *ru)
16681650
{
16691651
unsigned int f_flags = 0;
16701652
struct pid *pid = NULL;

kernel/exit.h

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
#ifndef LINUX_WAITID_H
3+
#define LINUX_WAITID_H
4+
5+
struct waitid_info {
6+
pid_t pid;
7+
uid_t uid;
8+
int status;
9+
int cause;
10+
};
11+
12+
struct wait_opts {
13+
enum pid_type wo_type;
14+
int wo_flags;
15+
struct pid *wo_pid;
16+
17+
struct waitid_info *wo_info;
18+
int wo_stat;
19+
struct rusage *wo_rusage;
20+
21+
wait_queue_entry_t child_wait;
22+
int notask_error;
23+
};
24+
25+
bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p);
26+
long __do_wait(struct wait_opts *wo);
27+
int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
28+
struct waitid_info *infop, int options,
29+
struct rusage *ru);
30+
#endif

0 commit comments

Comments
 (0)