1 /*
2 * proc-llist.h
3 * Copyright (c) 2009, 2020 Red Hat Inc.
4 * All Rights Reserved.
5 *
6 * This software may be freely redistributed and/or modified under the
7 * terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 * Boston, MA 02110-1335, USA.
20 *
21 * Authors:
22 * Steve Grubb <[email protected]>
23 */
24
25 #ifndef PROC_HEADER
26 #define PROC_HEADER
27
28 #include "config.h"
29 #include <sys/types.h> /* Ensure types in _lnode are defined on all systems */
30
31
32 /* This is the node of the linked list. Any data elements that are per
33 * record goes here. */
34 typedef struct _lnode{
35 pid_t ppid; // parent process ID
36 pid_t pid; // process ID
37 uid_t uid; // user ID
38 char *cmd; // command run by user
39 unsigned long inode; // inode of socket
40 char *capabilities; // Text of partial capabilities
41 char *bounds; // Text for bounding set
42 char *ambient; // Text for ambient set
43 struct _lnode* next; // Next node pointer
44 } lnode;
45
46 /* This is the linked list head. Only data elements that are 1 per
47 * event goes here. */
48 typedef struct {
49 lnode *head; // List head
50 lnode *cur; // Pointer to current node
51 unsigned int cnt; // How many items in this list
52 } llist;
53
54 void list_create(llist *l);
list_get_cur(llist * l)55 static inline lnode *list_get_cur(llist *l) { return l->cur; }
56 void list_append(llist *l, lnode *node);
57 void list_clear(llist* l);
58
59 /* Given a message type, find the matching node */
60 lnode *list_find_inode(llist *l, unsigned long i);
61
62 #endif
63
64