Lines Matching refs:filemon
42 static void filemon_output_event(struct filemon *filemon, const char *fmt, ...)
50 filemon_output(struct filemon *filemon, char *msg, size_t len) in filemon_output() argument
56 if (filemon->fp == NULL) in filemon_output()
69 if (filemon->fp->f_type == DTYPE_VNODE) in filemon_output()
72 error = fo_write(filemon->fp, &auio, filemon->cred, 0, curthread); in filemon_output()
73 if (error != 0 && filemon->error == 0) in filemon_output()
74 filemon->error = error; in filemon_output()
78 filemon_output_event(struct filemon *filemon, const char *fmt, ...) in filemon_output_event() argument
84 len = vsnprintf(filemon->msgbufr, sizeof(filemon->msgbufr), fmt, ap); in filemon_output_event()
87 if (len >= sizeof(filemon->msgbufr)) in filemon_output_event()
88 len = sizeof(filemon->msgbufr) - 1; in filemon_output_event()
89 filemon_output(filemon, filemon->msgbufr, len); in filemon_output_event()
96 struct filemon *filemon; in filemon_wrapper_chdir() local
99 if ((filemon = filemon_proc_get(curproc)) != NULL) { in filemon_wrapper_chdir()
100 if ((error = copyinstr(uap->path, filemon->fname1, in filemon_wrapper_chdir()
101 sizeof(filemon->fname1), NULL)) != 0) { in filemon_wrapper_chdir()
102 filemon->error = error; in filemon_wrapper_chdir()
106 filemon_output_event(filemon, "C %d %s\n", in filemon_wrapper_chdir()
107 curproc->p_pid, filemon->fname1); in filemon_wrapper_chdir()
109 filemon_drop(filemon); in filemon_wrapper_chdir()
120 struct filemon *filemon; in filemon_event_process_exec() local
122 if ((filemon = filemon_proc_get(p)) != NULL) { in filemon_event_process_exec()
123 filemon_output_event(filemon, "E %d %s\n", in filemon_event_process_exec()
130 priv_check_cred(filemon->cred, PRIV_DEBUG_DIFFCRED) != 0) { in filemon_event_process_exec()
136 KASSERT(p->p_filemon == filemon, in filemon_event_process_exec()
138 " filemon %p", __func__, p, filemon)); in filemon_event_process_exec()
144 filemon_drop(filemon); in filemon_event_process_exec()
154 struct filemon *filemon; in _filemon_wrapper_openat() local
158 if ((filemon = filemon_proc_get(curproc)) != NULL) { in _filemon_wrapper_openat()
163 if ((error = copyinstr(upath, filemon->fname1, in _filemon_wrapper_openat()
164 sizeof(filemon->fname1), NULL)) != 0) { in _filemon_wrapper_openat()
165 filemon->error = error; in _filemon_wrapper_openat()
169 if (filemon->fname1[0] != '/' && fd != AT_FDCWD) { in _filemon_wrapper_openat()
178 filemon_output_event(filemon, "A %d %s\n", in _filemon_wrapper_openat()
179 curproc->p_pid, filemon->fname1); in _filemon_wrapper_openat()
196 filemon_output_event(filemon, "R %d %s%s%s\n", in _filemon_wrapper_openat()
198 atpath[0] != '\0' ? "/" : "", filemon->fname1); in _filemon_wrapper_openat()
201 filemon_output_event(filemon, "%c %d %s%s%s\n", in _filemon_wrapper_openat()
204 atpath[0] != '\0' ? "/" : "", filemon->fname1); in _filemon_wrapper_openat()
206 filemon_drop(filemon); in _filemon_wrapper_openat()
239 struct filemon *filemon; in filemon_wrapper_rename() local
242 if ((filemon = filemon_proc_get(curproc)) != NULL) { in filemon_wrapper_rename()
243 if (((error = copyinstr(uap->from, filemon->fname1, in filemon_wrapper_rename()
244 sizeof(filemon->fname1), NULL)) != 0) || in filemon_wrapper_rename()
245 ((error = copyinstr(uap->to, filemon->fname2, in filemon_wrapper_rename()
246 sizeof(filemon->fname2), NULL)) != 0)) { in filemon_wrapper_rename()
247 filemon->error = error; in filemon_wrapper_rename()
251 filemon_output_event(filemon, "M %d '%s' '%s'\n", in filemon_wrapper_rename()
252 curproc->p_pid, filemon->fname1, filemon->fname2); in filemon_wrapper_rename()
254 filemon_drop(filemon); in filemon_wrapper_rename()
265 struct filemon *filemon; in _filemon_wrapper_link() local
268 if ((filemon = filemon_proc_get(curproc)) != NULL) { in _filemon_wrapper_link()
269 if (((error = copyinstr(upath1, filemon->fname1, in _filemon_wrapper_link()
270 sizeof(filemon->fname1), NULL)) != 0) || in _filemon_wrapper_link()
271 ((error = copyinstr(upath2, filemon->fname2, in _filemon_wrapper_link()
272 sizeof(filemon->fname2), NULL)) != 0)) { in _filemon_wrapper_link()
273 filemon->error = error; in _filemon_wrapper_link()
277 filemon_output_event(filemon, "L %d '%s' '%s'\n", in _filemon_wrapper_link()
278 curproc->p_pid, filemon->fname1, filemon->fname2); in _filemon_wrapper_link()
280 filemon_drop(filemon); in _filemon_wrapper_link()
320 struct filemon *filemon; in filemon_event_process_exit() local
322 if ((filemon = filemon_proc_get(p)) != NULL) { in filemon_event_process_exit()
323 filemon_output_event(filemon, "X %d %d %d\n", in filemon_event_process_exit()
331 KASSERT(p->p_filemon == NULL || p->p_filemon == filemon, in filemon_event_process_exit()
333 "filemon %p or NULL", __func__, p, filemon)); in filemon_event_process_exit()
334 if (p->p_filemon == filemon) in filemon_event_process_exit()
337 filemon_drop(filemon); in filemon_event_process_exit()
345 struct filemon *filemon; in filemon_wrapper_unlink() local
348 if ((filemon = filemon_proc_get(curproc)) != NULL) { in filemon_wrapper_unlink()
349 if ((error = copyinstr(uap->path, filemon->fname1, in filemon_wrapper_unlink()
350 sizeof(filemon->fname1), NULL)) != 0) { in filemon_wrapper_unlink()
351 filemon->error = error; in filemon_wrapper_unlink()
355 filemon_output_event(filemon, "D %d %s\n", in filemon_wrapper_unlink()
356 curproc->p_pid, filemon->fname1); in filemon_wrapper_unlink()
358 filemon_drop(filemon); in filemon_wrapper_unlink()
369 struct filemon *filemon; in filemon_event_process_fork() local
371 if ((filemon = filemon_proc_get(p1)) != NULL) { in filemon_event_process_fork()
372 filemon_output_event(filemon, "F %d %d\n", in filemon_event_process_fork()
382 if (p1->p_filemon == filemon) { in filemon_event_process_fork()
389 p2->p_filemon = filemon_acquire(filemon); in filemon_event_process_fork()
390 ++filemon->proccnt; in filemon_event_process_fork()
395 filemon_drop(filemon); in filemon_event_process_fork()