1a0699ebfSHans Petter Selasky /*- 2a0699ebfSHans Petter Selasky * Copyright (c) 2017 Mellanox Technologies, Ltd. 3a0699ebfSHans Petter Selasky * All rights reserved. 4a0699ebfSHans Petter Selasky * 5a0699ebfSHans Petter Selasky * Redistribution and use in source and binary forms, with or without 6a0699ebfSHans Petter Selasky * modification, are permitted provided that the following conditions 7a0699ebfSHans Petter Selasky * are met: 8a0699ebfSHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 9a0699ebfSHans Petter Selasky * notice unmodified, this list of conditions, and the following 10a0699ebfSHans Petter Selasky * disclaimer. 11a0699ebfSHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 12a0699ebfSHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 13a0699ebfSHans Petter Selasky * documentation and/or other materials provided with the distribution. 14a0699ebfSHans Petter Selasky * 15a0699ebfSHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16a0699ebfSHans Petter Selasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17a0699ebfSHans Petter Selasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18a0699ebfSHans Petter Selasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19a0699ebfSHans Petter Selasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20a0699ebfSHans Petter Selasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21a0699ebfSHans Petter Selasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22a0699ebfSHans Petter Selasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23a0699ebfSHans Petter Selasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24a0699ebfSHans Petter Selasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25a0699ebfSHans Petter Selasky */ 26a0699ebfSHans Petter Selasky 27*307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_PID_H_ 28*307f78f3SVladimir Kondratyev #define _LINUXKPI_LINUX_PID_H_ 29a0699ebfSHans Petter Selasky 30a0699ebfSHans Petter Selasky #include <sys/param.h> 31a0699ebfSHans Petter Selasky #include <sys/systm.h> 32a0699ebfSHans Petter Selasky #include <sys/proc.h> 33a0699ebfSHans Petter Selasky 34a0699ebfSHans Petter Selasky enum pid_type { 35a0699ebfSHans Petter Selasky PIDTYPE_PID, 36a0699ebfSHans Petter Selasky PIDTYPE_PGID, 37a0699ebfSHans Petter Selasky PIDTYPE_SID, 38a0699ebfSHans Petter Selasky PIDTYPE_MAX 39a0699ebfSHans Petter Selasky }; 40a0699ebfSHans Petter Selasky 41a0699ebfSHans Petter Selasky #define pid_nr(n) (n) 42a0699ebfSHans Petter Selasky #define pid_vnr(n) (n) 43a0699ebfSHans Petter Selasky #define from_kuid_munged(a, uid) (uid) 44a0699ebfSHans Petter Selasky 45a0699ebfSHans Petter Selasky #define pid_task(pid, type) ({ \ 46a0699ebfSHans Petter Selasky struct task_struct *__ts; \ 47a0699ebfSHans Petter Selasky CTASSERT((type) == PIDTYPE_PID); \ 48a0699ebfSHans Petter Selasky __ts = linux_pid_task(pid); \ 49a0699ebfSHans Petter Selasky __ts; \ 50a0699ebfSHans Petter Selasky }) 51a0699ebfSHans Petter Selasky 52a0699ebfSHans Petter Selasky #define get_pid_task(pid, type) ({ \ 53a0699ebfSHans Petter Selasky struct task_struct *__ts; \ 54a0699ebfSHans Petter Selasky CTASSERT((type) == PIDTYPE_PID); \ 55a0699ebfSHans Petter Selasky __ts = linux_get_pid_task(pid); \ 56a0699ebfSHans Petter Selasky __ts; \ 57a0699ebfSHans Petter Selasky }) 58a0699ebfSHans Petter Selasky 5994b9710bSHans Petter Selasky #define get_task_pid(task, type) ({ \ 6094b9710bSHans Petter Selasky CTASSERT((type) == PIDTYPE_PID); \ 6194b9710bSHans Petter Selasky (task)->task_thread->td_tid; \ 6294b9710bSHans Petter Selasky }) 6394b9710bSHans Petter Selasky 64a0699ebfSHans Petter Selasky struct task_struct; 65a0699ebfSHans Petter Selasky extern struct task_struct *linux_pid_task(pid_t); 66a0699ebfSHans Petter Selasky extern struct task_struct *linux_get_pid_task(pid_t); 67a0699ebfSHans Petter Selasky 68*307f78f3SVladimir Kondratyev #endif /* _LINUXKPI_LINUX_PID_H_ */ 69