Skip to content

Commit

Permalink
IDEA-81568 (ignore FS events from /private unless asked explicitly)
Browse files Browse the repository at this point in the history
  • Loading branch information
trespasserw committed Jun 9, 2014
1 parent 236752e commit 5ec97cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Binary file modified bin/mac/fsnotifier
Binary file not shown.
26 changes: 19 additions & 7 deletions native/fsNotifier/mac/fsnotifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
#include <pthread.h>
#include <sys/mount.h>

#define PRIVATE_DIR "/private/"
#define PRIVATE_LEN 9

static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static bool report_private = true;

static void reportEvent(char *event, char *path) {
int len = 0;
Expand All @@ -32,15 +36,15 @@ static void reportEvent(char *event, char *path) {
}

pthread_mutex_lock(&lock);

fputs(event, stdout);
fputc('\n', stdout);
if (path != NULL) {
fwrite(path, len, 1, stdout);
if (report_private || strncasecmp(path, PRIVATE_DIR, PRIVATE_LEN) != 0) {
fputs(event, stdout);
fputc('\n', stdout);
if (path != NULL) {
fwrite(path, len, 1, stdout);
fputc('\n', stdout);
}
fflush(stdout);
}

fflush(stdout);
pthread_mutex_unlock(&lock);
}

Expand Down Expand Up @@ -128,14 +132,22 @@ static char command[2048];

static void ParseRoots() {
CFMutableArrayRef roots = CFArrayCreateMutable(NULL, 0, NULL);
bool has_private_root = false;

while (TRUE) {
fscanf(stdin, "%s", command);
if (strcmp(command, "#") == 0 || feof(stdin)) break;
char* path = command[0] == '|' ? command + 1 : command;
CFArrayAppendValue(roots, strdup(path));
if (strcmp(path, "/") == 0 || strncasecmp(path, PRIVATE_DIR, PRIVATE_LEN) == 0) {
has_private_root = true;
}
}

pthread_mutex_lock(&lock);
report_private = has_private_root;
pthread_mutex_unlock(&lock);

PrintMountedFileSystems(roots);

for (int i = 0; i < CFArrayGetCount(roots); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private static String getExecutableName(final boolean withSubDir) {

private static boolean isUpToDate(File executable) {
long length = SystemInfo.isWindows ? 71208 :
SystemInfo.isMac ? 13924 :
SystemInfo.isMac ? 13984 :
SystemInfo.isLinux ? SystemInfo.isAMD64 ? 29155 : 22791 :
-1;
return length < 0 || length == executable.length();
Expand Down

0 comments on commit 5ec97cf

Please sign in to comment.