IDEA-81568 (ignore FS events from /private unless asked explicitly)

This commit is contained in:
Roman Shevchenko
2014-06-09 22:00:38 +04:00
parent 236752eb3b
commit 5ec97cf37b
3 changed files with 20 additions and 8 deletions
Binary file not shown.
+19 -7
View File
@@ -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;
@@ -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);
}
@@ -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++) {
@@ -217,7 +217,7 @@ public class FileWatcher {
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();