Branch data Line data Source code
1 : : #ifndef __CR_PSTREE_H__
2 : : #define __CR_PSTREE_H__
3 : :
4 : : #include "list.h"
5 : : #include "pid.h"
6 : : #include "image.h"
7 : : #include "rst_info.h"
8 : : #include "protobuf/core.pb-c.h"
9 : :
10 : : /*
11 : : * That's the init process which usually inherit
12 : : * all orphaned children in the system.
13 : : */
14 : : #define INIT_PID (1)
15 : : struct pstree_item {
16 : : struct pstree_item *parent;
17 : : struct list_head children; /* list of my children */
18 : : struct list_head sibling; /* linkage in my parent's children list */
19 : :
20 : : struct pid pid;
21 : : pid_t pgid;
22 : : pid_t sid;
23 : : pid_t born_sid;
24 : :
25 : : int state; /* TASK_XXX constants */
26 : :
27 : : int nr_threads; /* number of threads */
28 : : struct pid *threads; /* array of threads */
29 : : CoreEntry **core;
30 : : TaskKobjIdsEntry *ids;
31 : :
32 : : struct rst_info rst[0];
33 : : };
34 : :
35 : 1862 : static inline int shared_fdtable(struct pstree_item *item) {
36 [ + - ][ + - ]: 483 : return (item->parent && item->parent->state != TASK_HELPER &&
37 [ + - ]: 483 : item->ids &&
38 [ + - ]: 483 : item->parent->ids &&
39 [ + + ][ + + ]: 1414 : item->ids->files_id &&
40 : 483 : item->ids->files_id == item->parent->ids->files_id);
41 : : }
42 : :
43 : : extern void free_pstree(struct pstree_item *root_item);
44 : : extern struct pstree_item *__alloc_pstree_item(bool rst);
45 : : #define alloc_pstree_item() __alloc_pstree_item(false)
46 : : #define alloc_pstree_item_with_rst() __alloc_pstree_item(true)
47 : :
48 : : extern struct pstree_item *root_item;
49 : : extern struct pstree_item *pstree_item_next(struct pstree_item *item);
50 : : #define for_each_pstree_item(pi) \
51 : : for (pi = root_item; pi != NULL; pi = pstree_item_next(pi))
52 : :
53 : : extern bool restore_before_setsid(struct pstree_item *child);
54 : : extern int prepare_pstree(void);
55 : :
56 : : extern int dump_pstree(struct pstree_item *root_item);
57 : : extern bool pid_in_pstree(pid_t pid);
58 : :
59 : : struct task_entries;
60 : : extern struct task_entries *task_entries;
61 : :
62 : : extern int get_task_ids(struct pstree_item *);
63 : : extern struct _TaskKobjIdsEntry *root_ids;
64 : :
65 : : extern void core_entry_free(CoreEntry *core);
66 : : extern CoreEntry *core_entry_alloc(int alloc_thread_info, int alloc_tc);
67 : : extern int pstree_alloc_cores(struct pstree_item *item);
68 : : extern void pstree_free_cores(struct pstree_item *item);
69 : :
70 : : extern int collect_pstree_ids(void);
71 : :
72 : : #endif /* __CR_PSTREE_H__ */
|