summaryrefslogtreecommitdiffstats
path: root/src/fuser.h
blob: 4500ec5f957a437d73fc710f7ff98933058cbde0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* Option Flags */
typedef unsigned short opt_type;

#define OPT_VERBOSE 1
#define OPT_ALLFILES 2
#define OPT_MOUNTS 4
#define OPT_KILL 8
#define OPT_INTERACTIVE 16
#define OPT_SILENT 32
#define OPT_USER 64
#define OPT_ISMOUNTPOINT 128
#define OPT_WRITE 256
#define OPT_ALWAYSSTAT 512

struct procs {
	pid_t pid;
	uid_t uid;
	char access;
	char proc_type;
	char *username;
	char *command;
	struct procs *next;
};

/* For the access field above */
#define ACCESS_CWD 1
#define ACCESS_EXE 2
#define ACCESS_FILE 4
#define ACCESS_ROOT 8
#define ACCESS_MMAP 16
#define ACCESS_FILEWR 32

/* For the proc_type field above */
#define PTYPE_NORMAL 0
#define PTYPE_MOUNT 1
#define PTYPE_KNFSD 2
#define PTYPE_SWAP 3

struct names {
	char *filename;
	unsigned char name_space;
	struct stat st;
	struct procs *matched_procs;
	struct names *next;
};

struct ip_connections {
	struct names *name;
	unsigned long lcl_port;
	unsigned long rmt_port;
	struct in_addr rmt_address;
	struct ip_connections *next;
};

struct ip6_connections {
	struct names *name;
	unsigned long lcl_port;
	unsigned long rmt_port;
	struct in6_addr rmt_address;
	struct ip6_connections *next;
};

struct inode_list {
	struct names *name;
	dev_t	device;
	ino_t	inode;
	struct inode_list *next;
};

struct device_list {
	struct names *name;
	dev_t	device;
	struct device_list *next;
};

struct unixsocket_list {
	char *sun_name;
	ino_t	inode;
	ino_t	net_inode;
	dev_t	dev;
	struct unixsocket_list *next;
};

struct mount_list {
	char *mountpoint;
	struct mount_list *next;
};

#if defined (__GNUC__) && defined(WITH_MOUNTINFO_LIST)
# include "lists.h"
typedef struct mntinfo_s {
    list_t   this;
    int id, parid;
    dev_t     dev;
    size_t   nlen;
    char  *mpoint;
} mntinfo_t;
#else
# undef WITH_MOUNTINFO_LIST
#endif

#define NAMESPACE_FILE 0
#define NAMESPACE_TCP 1
#define NAMESPACE_UDP 2

#ifndef PATH_MAX
#define PATH_MAX 4096
#endif /* PATH_MAX */

#define KNFSD_EXPORTS "/proc/fs/nfs/exports"
#define PROC_MOUNTS "/proc/mounts"
#define PROC_SWAPS "/proc/swaps"