Skip to content

Commit daccbf3

Browse files
axboeopsiff
authored andcommitted
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 <axboe@kernel.dk> (cherry picked from commit 2e521a2) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent d83c8b4 commit daccbf3

2 files changed

Lines changed: 37 additions & 25 deletions

File tree

kernel/exit.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
#include <asm/haoc/iee-token.h>
7878
#endif
7979

80+
#include "exit.h"
81+
8082
/*
8183
* The default value should be high enough to not crash a system that randomly
8284
* crashes its kernel from time to time, but low enough to at least not permit
@@ -1046,26 +1048,6 @@ SYSCALL_DEFINE1(exit_group, int, error_code)
10461048
return 0;
10471049
}
10481050

1049-
struct waitid_info {
1050-
pid_t pid;
1051-
uid_t uid;
1052-
int status;
1053-
int cause;
1054-
};
1055-
1056-
struct wait_opts {
1057-
enum pid_type wo_type;
1058-
int wo_flags;
1059-
struct pid *wo_pid;
1060-
1061-
struct waitid_info *wo_info;
1062-
int wo_stat;
1063-
struct rusage *wo_rusage;
1064-
1065-
wait_queue_entry_t child_wait;
1066-
int notask_error;
1067-
};
1068-
10691051
static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
10701052
{
10711053
return wo->wo_type == PIDTYPE_MAX ||
@@ -1529,7 +1511,7 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk)
15291511
return 0;
15301512
}
15311513

1532-
static bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
1514+
bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
15331515
{
15341516
if (!eligible_pid(wo, p))
15351517
return false;
@@ -1599,7 +1581,7 @@ static int do_wait_pid(struct wait_opts *wo)
15991581
return 0;
16001582
}
16011583

1602-
static long __do_wait(struct wait_opts *wo)
1584+
long __do_wait(struct wait_opts *wo)
16031585
{
16041586
long retval;
16051587

@@ -1671,9 +1653,9 @@ static long do_wait(struct wait_opts *wo)
16711653
return retval;
16721654
}
16731655

1674-
static int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
1675-
struct waitid_info *infop, int options,
1676-
struct rusage *ru)
1656+
int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
1657+
struct waitid_info *infop, int options,
1658+
struct rusage *ru)
16771659
{
16781660
unsigned int f_flags = 0;
16791661
struct pid *pid = NULL;

kernel/exit.h

Lines changed: 30 additions & 0 deletions
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)