From 594ccb33936e34d889f4bca674371d67c33e9f8e Mon Sep 17 00:00:00 2001 From: Tom Cort Date: Tue, 27 Nov 2007 00:45:12 -0500 Subject: [PATCH] Add some skeleton code for inotify. It doesn't do much yet, just setup a watch on the current working directory and exit. More work still needs to be done (obviously). --- inotify.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ inotify.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 inotify.c create mode 100644 inotify.h diff --git a/inotify.c b/inotify.c new file mode 100644 index 0000000..4413dd7 --- /dev/null +++ b/inotify.c @@ -0,0 +1,55 @@ +/* + * inoclam - Inotify+ClamAV virus scanner + * Copyright (C) 2007 Vermont Department of Taxes + * + * 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 . + * + * Contributor(s): + * Tom Cort + */ + +#include +#include +#include +#include + +#include "inotify.h" +#include "sig.h" + +/** + * Watch the specified directory for changes and call contains_virus() + * @param basedir the directory to watch. + */ +void inotify_main(char *basedir) { + int fd; + uint32_t wd; + + fd = inotify_init(); + if (fd == -1) { + daemon_log(LOG_ERR, "(%s:%u) inotify_init failed: %s", __FILE__, __LINE__, strerror(errno)); + } + + wd = inotify_add_watch(fd, ".", IN_ALL_EVENTS); + + daemon_log(LOG_INFO, "(%s:%u) entering inotify loop", __FILE__, __LINE__); + + do { + + } while (!exit_now); + + daemon_log(LOG_INFO, "(%s:%u) leaving inotify loop", __FILE__, __LINE__); + + inotify_rm_watch(fd, wd); + close(fd); +} diff --git a/inotify.h b/inotify.h new file mode 100644 index 0000000..cb2291a --- /dev/null +++ b/inotify.h @@ -0,0 +1,31 @@ +/* + * inoclam - Inotify+ClamAV virus scanner + * Copyright (C) 2007 Vermont Department of Taxes + * + * 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 . + * + * Contributor(s): + * Tom Cort + */ + +#ifndef __INOTIFY_H +#define __INOTIFY_H + +/** + * Watch the specified directory for changes and call contains_virus() + * @param basedir the directory to watch. + */ +void inotify_main(char *basedir); + +#endif -- 2.11.4.GIT