Skip to content

Commit

Permalink
Thrift endpoint to start/stop FAM
Browse files Browse the repository at this point in the history
Summary:
## Context

File Access Monitor(FAM) is a tool to monitor file system access, aiming to find out EdenFS crawlers. The tool will be implemented after [the toolchain is ready](https://docs.google.com/document/d/1MDSp3pdS5zycPiPcNDPOnBYWB4aDRoCT7D-qUA-PnKI/edit?usp=sharing). Before that, we are going to use this [third-party binary](https://github.com/objective-see/FileMonitor).

This diff stack focuses on integrating the binary into Eden package and spawn a process from privHelper because of the required privileged permission.

## This Diff

- Thrift endpoints to start FAM
- Thrift endpoints to stop FAM

When starting FAM, specify which mount point should be monitored. The path of the output file will be returned.

When stopping FAM, no arguments needed.

Reviewed By: jdelliot

Differential Revision: D67488770

fbshipit-source-id: 77361e24ed10b33ca114c4c7c2629a24392337aa
  • Loading branch information
lXXXw authored and facebook-github-bot committed Feb 3, 2025
1 parent a575025 commit 031c222
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions third-party/watchman/src/eden/fs/service/eden.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,52 @@ struct ChangesSinceV2Params {
7: optional list<string> excludedSuffixes;
}

/*
* Return value of the startFileAccessMonitor API
*
* pid - The process ID for the started File Access Monitor(FAM) binary if started
* successfully.
*
* tmpOutputPath - The path of FAM output file
*/
struct StartFileAccessMonitorResult {
1: pid_t pid;
2: PathString tmpOutputPath;
}

/*
* Return value of the stopFileAccessMonitor API
*
* tmpOutputPath - The path to the file which file access events are dumped to.
*
* specifiedOutputPath - If set, it tells the caller if a specified output path was provided.
*
* shouldUpload - It tells the caller if FAM is started with the request to upload the output file.
*/
struct StopFileAccessMonitorResult {
1: PathString tmpOutputPath;
2: PathString specifiedOutputPath;
3: bool shouldUpload;
}

/**
* Argument to startFileAccessMonitor API
*
* paths - A list of paths monitored by File Access Monitor(FAM).
*
* specifiedOutputPath - If provided, this is the destination where the file written
* by FAM will be moved to. This is only stored as part of the state of FAM. No
* writes will be made to this path.
*
* shouldUpload - It indicates if the output file should be uploaded. This is only
* stored as part of the state of FAM.
*/
struct StartFileAccessMonitorParams {
1: list<PathString> paths;
2: optional PathString specifiedOutputPath;
3: bool shouldUpload;
}

service EdenService extends fb303_core.BaseService {
list<MountInfo> listMounts() throws (1: EdenError ex);
void mount(1: MountArgument info) throws (1: EdenError ex);
Expand Down Expand Up @@ -2810,4 +2856,10 @@ service EdenService extends fb303_core.BaseService {
ChangesSinceV2Result changesSinceV2(1: ChangesSinceV2Params params) throws (
1: EdenError ex,
);

StartFileAccessMonitorResult startFileAccessMonitor(
1: StartFileAccessMonitorParams params,
) throws (1: EdenError ex);

StopFileAccessMonitorResult stopFileAccessMonitor() throws (1: EdenError ex);
}

0 comments on commit 031c222

Please sign in to comment.