Skip to content

Commit 5a52d24

Browse files
committed
filemonitor improvements
1 parent 3a567c0 commit 5a52d24

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

UTILS/FileIOGraph/monitor_fileaccess_v2.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,19 @@ int main(int argc, char **argv)
124124
struct fanotify_event_metadata *metadata;
125125

126126
// init fanotify
127+
128+
// with this we can observe specific root directories
129+
auto ROOT_PATH_ENV = getenv("FILEACCESS_MON_ROOTPATH");
130+
std::string root_path = "/";
131+
if (ROOT_PATH_ENV) {
132+
std::cerr << "Observing file access below " << root_path << "\n";
133+
root_path = std::string(ROOT_PATH_ENV);
134+
}
135+
127136
CHK(fan = fanotify_init(FAN_CLASS_NOTIF, O_RDONLY), -1);
128137
CHK(fanotify_mark(fan, FAN_MARK_ADD | FAN_MARK_MOUNT,
129138
FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE | FAN_EVENT_ON_CHILD,
130-
AT_FDCWD, "/"),
139+
AT_FDCWD, root_path.c_str()),
131140
-1);
132141

133142
// read env for filtering

0 commit comments

Comments
 (0)