From a20173a42df64515c0a5d1c5fba0c056a633a441 Mon Sep 17 00:00:00 2001 From: Bert Münnich Date: Wed, 17 May 2017 20:16:16 +0200 Subject: Detect all file overwrites in autoreload_inotify mv(1) inside the same filesystem was not detected. Supporting this case made it necessary to always watch the directory. Turns out the logic and state keeping between arl_setup() and arl_handle() is easier, when using different watch descriptors for the file and the directory and not using a oneshot descriptor for the file. Requiring an absolute canonical path for arl_setup() simplifies dir and base name splitting. No need for dirname(3) and basename(3) anymore. --- autoreload.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'autoreload.h') diff --git a/autoreload.h b/autoreload.h index 6a3053c..bb30eb6 100644 --- a/autoreload.h +++ b/autoreload.h @@ -23,13 +23,14 @@ typedef struct { int fd; - int wd; - bool watching_dir; + int wd_dir; + int wd_file; + char *filename; } arl_t; -void arl_cleanup(arl_t*); -bool arl_handle(arl_t*, const char*); void arl_init(arl_t*); -void arl_setup(arl_t*, const char*); +void arl_cleanup(arl_t*); +void arl_setup(arl_t*, const char* /* result of realpath(3) */); +bool arl_handle(arl_t*); #endif /* AUTORELOAD_H */ -- cgit v1.2.3-54-g00ecf