summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-07-02 10:42:58 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-07-02 10:42:58 +0000
commitf334f212d9e8b692e0c92e264a5ec76d8855f3df (patch)
tree79d94e48e80f0e3e7e7b703e3bd0529bb2b578de
parent4bc5ce2c74d772efe353633f59051e227f524bfa (diff)
Notes
-rw-r--r--sys/compat/linuxkpi/common/src/linux_current.c79
1 files changed, 33 insertions, 46 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c
index 7233635eade5..611d10df3383 100644
--- a/sys/compat/linuxkpi/common/src/linux_current.c
+++ b/sys/compat/linuxkpi/common/src/linux_current.c
@@ -155,65 +155,52 @@ linuxkpi_thread_dtor(void *arg __unused, struct thread *td)
put_task_struct(ts);
}
-struct task_struct *
-linux_pid_task(pid_t pid)
+static struct task_struct *
+linux_get_pid_task_int(pid_t pid, const bool do_get)
{
struct thread *td;
struct proc *p;
+ struct task_struct *ts;
- /* try to find corresponding thread */
- td = tdfind(pid, -1);
- if (td != NULL) {
- struct task_struct *ts = td->td_lkpi_task;
- PROC_UNLOCK(td->td_proc);
- return (ts);
- }
-
- /* try to find corresponding procedure */
- p = pfind(pid);
- if (p != NULL) {
- FOREACH_THREAD_IN_PROC(p, td) {
- struct task_struct *ts = td->td_lkpi_task;
- if (ts != NULL) {
- PROC_UNLOCK(p);
- return (ts);
+ if (pid > PID_MAX) {
+ /* try to find corresponding thread */
+ td = tdfind(pid, -1);
+ if (td != NULL) {
+ ts = td->td_lkpi_task;
+ if (do_get && ts != NULL)
+ get_task_struct(ts);
+ PROC_UNLOCK(td->td_proc);
+ return (ts);
+ }
+ } else {
+ /* try to find corresponding procedure */
+ p = pfind(pid);
+ if (p != NULL) {
+ FOREACH_THREAD_IN_PROC(p, td) {
+ ts = td->td_lkpi_task;
+ if (ts != NULL) {
+ if (do_get)
+ get_task_struct(ts);
+ PROC_UNLOCK(p);
+ return (ts);
+ }
}
+ PROC_UNLOCK(p);
}
- PROC_UNLOCK(p);
}
return (NULL);
}
struct task_struct *
-linux_get_pid_task(pid_t pid)
+linux_pid_task(pid_t pid)
{
- struct thread *td;
- struct proc *p;
-
- /* try to find corresponding thread */
- td = tdfind(pid, -1);
- if (td != NULL) {
- struct task_struct *ts = td->td_lkpi_task;
- if (ts != NULL)
- get_task_struct(ts);
- PROC_UNLOCK(td->td_proc);
- return (ts);
- }
+ return (linux_get_pid_task_int(pid, false));
+}
- /* try to find corresponding procedure */
- p = pfind(pid);
- if (p != NULL) {
- FOREACH_THREAD_IN_PROC(p, td) {
- struct task_struct *ts = td->td_lkpi_task;
- if (ts != NULL) {
- get_task_struct(ts);
- PROC_UNLOCK(p);
- return (ts);
- }
- }
- PROC_UNLOCK(p);
- }
- return (NULL);
+struct task_struct *
+linux_get_pid_task(pid_t pid)
+{
+ return (linux_get_pid_task_int(pid, true));
}
bool