clsync
privileged.h
Go to the documentation of this file.
1 /*
2  clsync - file tree sync utility based on inotify/kqueue
3 
4  Copyright (C) 2013-2014 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any 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. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifdef HL_LOCK_TRIES_AUTO
21 # define IF_HL_LOCK_TRIES_AUTO(a) a
22 #else
23 # define IF_HL_LOCK_TRIES_AUTO(a) {}
24 #endif
25 
26 #ifdef CAPABILITIES_SUPPORT
27 
28 enum priv_callid {
29  PC_DEFAULT = 0,
30  PC_SYNC_INIIALSYNC_WALK_FTS_OPEN,
31  PC_SYNC_INIIALSYNC_WALK_FTS_READ,
32  PC_SYNC_INIIALSYNC_WALK_FTS_CLOSE,
33  PC_SYNC_MARK_WALK_FTS_OPEN,
34  PC_SYNC_MARK_WALK_FTS_READ,
35  PC_SYNC_MARK_WALK_FTS_CLOSE,
36  PC_INOTIFY_ADD_WATCH_DIR,
37 
38  PC_MON_HANDLE_LSTAT64,
39 
40  PC_MAX
41 };
42 
43 extern int ( *_privileged_lstat64 ) (
44  const char *path, stat64_t *buf
45 # ifdef HL_LOCK_TRIES_AUTO
46  , int callid
47 # endif
48 );
49 
50 extern FTS * ( *_privileged_fts_open ) (
51  char * const *path_argv,
52  int options,
53  int ( *compar ) ( const FTSENT **, const FTSENT ** )
54 # ifdef HL_LOCK_TRIES_AUTO
55  , int callid
56 # endif
57 );
58 
59 extern FTSENT * ( *_privileged_fts_read ) (
60  FTS *ftsp
61 # ifdef HL_LOCK_TRIES_AUTO
62  , int callid
63 # endif
64 );
65 
66 extern int ( *_privileged_fts_close ) (
67  FTS *ftsp
68 # ifdef HL_LOCK_TRIES_AUTO
69  , int callid
70 # endif
71 );
72 
73 extern int ( *_privileged_inotify_init ) ();
74 extern int ( *_privileged_inotify_init1 ) ( int flags );
75 
76 extern int ( *_privileged_inotify_add_watch ) (
77  int fd,
78  const char *pathname,
79  uint32_t mask
80 # ifdef HL_LOCK_TRIES_AUTO
81  , int callid
82 # endif
83 );
84 
85 extern int ( *_privileged_inotify_rm_watch ) (
86  int fd,
87  int wd
88 );
89 
90 #ifdef CGROUP_SUPPORT
91 extern int ( *_privileged_clsync_cgroup_deinit ) ( ctx_t *ctx_p );
92 #endif
93 
94 extern pid_t ( *_privileged_waitpid ) ( pid_t pid, int *status, int options );
95 
96 extern int privileged_check();
97 
98 # ifdef HL_LOCK_TRIES_AUTO
99 # define privileged_lstat64(a,b,c) _privileged_lstat64(a,b,c)
100 # define privileged_fts_open(a,b,c,d) _privileged_fts_open(a,b,c,d)
101 # define privileged_fts_read(a,b) _privileged_fts_read(a,b)
102 # define privileged_fts_close(a,b) _privileged_fts_close(a,b)
103 # define privileged_inotify_add_watch(a,b,c,d) _privileged_inotify_add_watch(a,b,c,d)
104 # else
105 # define privileged_lstat64(a,b,c) _privileged_lstat64(a,b)
106 # define privileged_fts_open(a,b,c,d) _privileged_fts_open(a,b,c)
107 # define privileged_fts_read(a,b) _privileged_fts_read(a)
108 # define privileged_fts_close(a,b) _privileged_fts_close(a)
109 # define privileged_inotify_add_watch(a,b,c,d) _privileged_inotify_add_watch(a,b,c)
110 # endif
111 
112 # define privileged_inotify_init _privileged_inotify_init
113 # define privileged_inotify_init1 _privileged_inotify_init1
114 # define privileged_inotify_rm_watch _privileged_inotify_rm_watch
115 # define privileged_clsync_cgroup_deinit _privileged_clsync_cgroup_deinit
116 # define privileged_waitpid _privileged_waitpid
117 
118 #else
119 
120 # define privileged_check(...) {}
121 
122 # define privileged_lstat64(a,b,c) lstat64(a,b)
123 # define privileged_fts_open(a,b,c,d) fts_open(a,b,c)
124 # define privileged_fts_read(a,b) fts_read(a)
125 # define privileged_fts_close(a,b) fts_close(a)
126 # define privileged_inotify_init inotify_init
127 # define privileged_inotify_init1 inotify_init1
128 # define privileged_inotify_add_watch(a,b,c,d) inotify_add_watch(a,b,c)
129 # define privileged_inotify_rm_watch inotify_rm_watch
130 # ifdef CGROUP_SUPPORT
131 # define privileged_clsync_cgroup_deinit clsync_cgroup_deinit
132 # endif
133 # define privileged_waitpid waitpid
134 #endif
135 
136 extern int ( *_privileged_kill_child ) (
137  pid_t pid,
138  int sig,
139  char ignoreerrors
140 );
141 
142 extern int ( *_privileged_fork_execvp ) (
143  const char *file,
144  char *const argv[]
145 );
146 
147 #define privileged_kill_child _privileged_kill_child
148 #define privileged_fork_execvp _privileged_fork_execvp
149 
150 extern int privileged_init ( struct ctx *ctx_p );
151 extern int privileged_deinit ( struct ctx *ctx_p );
152 
ctx
Definition: ctx.h:315
_privileged_kill_child
int(* _privileged_kill_child)(pid_t pid, int sig, char ignoreerrors)
Definition: privileged.c:174
privileged_deinit
int privileged_deinit(struct ctx *ctx_p)
Definition: privileged.c:2087
argv
char ** argv
Definition: main.c:2725
HL_LOCK_TRIES_AUTO
#define HL_LOCK_TRIES_AUTO
Definition: configuration.h:205
privileged_init
int privileged_init(struct ctx *ctx_p)
Definition: privileged.c:1909
privileged_check
#define privileged_check(...)
Definition: privileged.h:120
stat64_t
struct stat64 stat64_t
Definition: port-hacks.h:65
_privileged_fork_execvp
int(* _privileged_fork_execvp)(const char *file, char *const argv[])
Definition: privileged.c:173
ctx_p
ctx_t * ctx_p
Definition: mon_kqueue.c:85