privileged.h
3.91 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
clsync - file tree sync utility based on inotify/kqueue
Copyright (C) 2013-2014 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HL_LOCK_TRIES_AUTO
# define IF_HL_LOCK_TRIES_AUTO(a) a
#else
# define IF_HL_LOCK_TRIES_AUTO(a) {}
#endif
#ifdef CAPABILITIES_SUPPORT
enum priv_callid {
PC_DEFAULT = 0,
PC_SYNC_INIIALSYNC_WALK_FTS_OPEN,
PC_SYNC_INIIALSYNC_WALK_FTS_READ,
PC_SYNC_INIIALSYNC_WALK_FTS_CLOSE,
PC_SYNC_MARK_WALK_FTS_OPEN,
PC_SYNC_MARK_WALK_FTS_READ,
PC_SYNC_MARK_WALK_FTS_CLOSE,
PC_INOTIFY_ADD_WATCH_DIR,
PC_MAX
};
extern FTS *(*_privileged_fts_open) (
char * const *path_argv,
int options,
int (*compar)(const FTSENT **, const FTSENT **)
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern FTSENT *(*_privileged_fts_read) (
FTS *ftsp
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern int (*_privileged_fts_close) (
FTS *ftsp
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern int (*_privileged_inotify_init) ();
extern int (*_privileged_inotify_init1) (int flags);
extern int (*_privileged_inotify_add_watch) (
int fd,
const char *pathname,
uint32_t mask
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern int (*_privileged_inotify_rm_watch) (
int fd,
int wd
);
#ifdef CGROUP_SUPPORT
extern int (*_privileged_clsync_cgroup_deinit) (ctx_t *ctx_p);
#endif
extern pid_t (*_privileged_waitpid) (pid_t pid, int *status, int options);
extern int privileged_check();
# ifdef HL_LOCK_TRIES_AUTO
# define privileged_fts_open(a,b,c,d) _privileged_fts_open(a,b,c,d)
# define privileged_fts_read(a,b) _privileged_fts_read(a,b)
# define privileged_fts_close(a,b) _privileged_fts_close(a,b)
# define privileged_inotify_add_watch(a,b,c,d) _privileged_inotify_add_watch(a,b,c,d)
# else
# define privileged_fts_open(a,b,c,d) _privileged_fts_open(a,b,c)
# define privileged_fts_read(a,b) _privileged_fts_read(a)
# define privileged_fts_close(a,b) _privileged_fts_close(a)
# define privileged_inotify_add_watch(a,b,c,d) _privileged_inotify_add_watch(a,b,c)
# endif
# define privileged_inotify_init _privileged_inotify_init
# define privileged_inotify_init1 _privileged_inotify_init1
# define privileged_inotify_rm_watch _privileged_inotify_rm_watch
# define privileged_clsync_cgroup_deinit _privileged_clsync_cgroup_deinit
# define privileged_waitpid _privileged_waitpid
#else
# define privileged_check(...) {}
# define privileged_fts_open(a,b,c,d) fts_open(a,b,c)
# define privileged_fts_read(a,b) fts_read(a)
# define privileged_fts_close(a,b) fts_close(a)
# define privileged_inotify_init inotify_init
# define privileged_inotify_init1 inotify_init1
# define privileged_inotify_add_watch(a,b,c,d) inotify_add_watch(a,b,c)
# define privileged_inotify_rm_watch inotify_rm_watch
# ifdef CGROUP_SUPPORT
# define privileged_clsync_cgroup_deinit clsync_cgroup_deinit
# endif
# define privileged_waitpid waitpid
#endif
extern int (*_privileged_kill_child)(
pid_t pid,
int sig,
char ignoreerrors
);
extern int (*_privileged_fork_execvp)(
const char *file,
char *const argv[]
);
#define privileged_kill_child _privileged_kill_child
#define privileged_fork_execvp _privileged_fork_execvp
extern int privileged_init(struct ctx *ctx_p);
extern int privileged_deinit(struct ctx *ctx_p);