summaryrefslogtreecommitdiff
path: root/rhdropbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'rhdropbox.c')
-rw-r--r--rhdropbox.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/rhdropbox.c b/rhdropbox.c
index 8403ae7..aca0cfb 100644
--- a/rhdropbox.c
+++ b/rhdropbox.c
@@ -37,6 +37,10 @@
#include "utils.h"
#include "sysexec.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
enum cmd_id_enum { ADD, REMOVE, STATUS, LOG, LISTEN };
typedef enum cmd_id_enum cmd_id_t;
@@ -94,11 +98,21 @@ int process_watch(int inotify_fd, read_buffer_t* buffer, watch_list_t* watch_lst
log_printf(DEBUG, "ignoring inotify_rm_watch based events");
}
else {
- char* const argv[] = { opt->script_, path, event->len > 0 ? event->name : "", NULL };
+ struct stat stat_buf;
+ char buf[1024];
+ snprintf(buf, 1024, "%s/%s", path, event->len > 0 ? event->name : "");
+ int err = stat(buf, &stat_buf);
+ if(err < 0) {
+ log_printf(WARNING, "error at stat() for file %s", buf);
+ buf[0] = 0;
+ }
+ else
+ snprintf(buf, 1024, "%lu", stat_buf.st_size);
+
+ char* const argv[] = { opt->script_, path, event->len > 0 ? event->name : "", buf, NULL };
char* const evp[] = { NULL };
rh_exec(opt->script_, argv, evp, child_lst);
- char buf[100];
snprintf(buf, 100, "new file in '%s', name='%s'", path, event->len > 0 ? event->name : "");
log_printf(NOTICE, "%s, executed script %s", buf, opt->script_);
client_t* client;