diff --git a/bin/linux/fsnotifier b/bin/linux/fsnotifier index e4b7dcb6b24c..3d90bedafc45 100755 Binary files a/bin/linux/fsnotifier and b/bin/linux/fsnotifier differ diff --git a/bin/linux/fsnotifier64 b/bin/linux/fsnotifier64 index 8a73a32e167f..6427e4b31599 100755 Binary files a/bin/linux/fsnotifier64 and b/bin/linux/fsnotifier64 differ diff --git a/native/fsNotifier/linux/fsnotifier.h b/native/fsNotifier/linux/fsnotifier.h index b8dd17b38831..0b3e52705513 100644 --- a/native/fsNotifier/linux/fsnotifier.h +++ b/native/fsNotifier/linux/fsnotifier.h @@ -61,14 +61,19 @@ void set_inotify_callback(void (* callback)(char*, int)); int get_inotify_fd(); int get_watch_count(); bool watch_limit_reached(); -int watch(const char* root); +int watch(const char* root, array* mounts); void unwatch(int id); bool process_inotify_input(); void close_inotify(); // reads one line from stream, trims trailing carriage return if any -// returns pointer to the internal buffer (will be overwriten on next call) +// returns pointer to the internal buffer (will be overwritten on next call) char* read_line(FILE* stream); + +// path comparison +bool is_parent_path(const char* parent_path, const char* child_path); + + #endif diff --git a/native/fsNotifier/linux/inotify.c b/native/fsNotifier/linux/inotify.c index 443c67a13d97..bfb117d51347 100644 --- a/native/fsNotifier/linux/inotify.c +++ b/native/fsNotifier/linux/inotify.c @@ -216,7 +216,15 @@ static void rm_watch(int wd, bool update_parent) { } -static int walk_tree(const char* path, watch_node* parent, bool recursive) { +static int walk_tree(const char* path, watch_node* parent, bool recursive, array* mounts) { + for (int j=0; jd_name); - int subdir_id = walk_tree(subdir, table_get(watches, id), recursive); + int subdir_id = walk_tree(subdir, table_get(watches, id), recursive, mounts); if (subdir_id < 0 && subdir_id != ERR_IGNORE) { rm_watch(id, true); id = subdir_id; @@ -270,7 +278,7 @@ static int walk_tree(const char* path, watch_node* parent, bool recursive) { } -int watch(const char* root) { +int watch(const char* root, array* mounts) { bool recursive = true; if (root[0] == '|') { root++; @@ -297,7 +305,7 @@ int watch(const char* root) { return ERR_IGNORE; } - return walk_tree(root, NULL, recursive); + return walk_tree(root, NULL, recursive, mounts); } @@ -326,7 +334,7 @@ static bool process_inotify_event(struct inotify_event* event) { } if (is_dir && ((event->mask & IN_CREATE) == IN_CREATE || (event->mask & IN_MOVED_TO) == IN_MOVED_TO)) { - int result = walk_tree(path, node, true); + int result = walk_tree(path, node, true, NULL); if (result < 0 && result != ERR_IGNORE) { return false; } diff --git a/native/fsNotifier/linux/main.c b/native/fsNotifier/linux/main.c index 4bd2727c224c..381c6826de1e 100644 --- a/native/fsNotifier/linux/main.c +++ b/native/fsNotifier/linux/main.c @@ -320,23 +320,31 @@ static bool register_roots(array* new_roots, array* unwatchable, array* mounts) continue; } - char* skip = NULL; + array* inner_mounts = array_create(5); + CHECK_NULL(inner_mounts, false); + + bool skip = false; for (int j=0; j= 0) { watch_root* root = malloc(sizeof(watch_root)); diff --git a/native/fsNotifier/linux/make.sh b/native/fsNotifier/linux/make.sh index 9d6ffc01ea87..4dc3657ab777 100755 --- a/native/fsNotifier/linux/make.sh +++ b/native/fsNotifier/linux/make.sh @@ -4,4 +4,7 @@ clang -m32 -O2 -Wall -std=c99 -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -o fsnotifier ma if [ $? -eq 0 ] ; then echo "compiling 64-bit version" clang -m64 -O2 -Wall -std=c99 -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -o fsnotifier64 main.c inotify.c util.c + if [ $? -eq 0 ] ; then + chmod 755 fsnotifier fsnotifier64 + fi fi diff --git a/native/fsNotifier/linux/util.c b/native/fsNotifier/linux/util.c index 6e09a9053d80..179b3105a422 100644 --- a/native/fsNotifier/linux/util.c +++ b/native/fsNotifier/linux/util.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -188,3 +188,10 @@ char* read_line(FILE* stream) { } return input_buf; } + + +bool is_parent_path(const char* parent_path, const char* child_path) { + size_t parent_len = strlen(parent_path); + return strncmp(parent_path, child_path, parent_len) == 0 && + (parent_len == strlen(child_path) || child_path[parent_len] == '/'); +}