Skip to content

macos: record the files each process opens - #29

Draft
LalitMaganti wants to merge 1 commit into
macos-record-2from
macos-record-3
Draft

LalitMaganti wants to merge 1 commit into
macos-record-2from
macos-record-3

Conversation

@LalitMaganti

@LalitMaganti LalitMaganti commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Records the files each process opens on macOS.

Third of seven steps towards #2. Stacked on #28.

Why

File events let a recording link each file to the step that wrote it and the steps that read it. The kernel reports each path the way the program passed it, which is often relative. Buildprof has to work out the full path itself.

Changes

  • Working directories: Buildprof follows each process's working directory through chdir and fchdir. A new process starts with its parent's.
  • Descriptors: Buildprof also follows the path behind each open file descriptor, through open, dup, dup2, fcntl and close-on-exec. This resolves paths given relative to a directory descriptor.
  • Resolving: each reported path is resolved against the right directory. Opening / is the one open the kernel reports no path for, so it is handled separately.
  • Flags: open flags are stored with Linux's numbers, so the UI reads them the same way on both platforms.
  • --no-file-events: the flag now has an effect on macOS, and produces a smaller recording. Collection costs about the same either way, because the events that carry working directories are needed regardless.

A path that goes through a relative symbolic link loses its starting directory. #31 recovers most of those.

Testing

Unit tests cover translating open flags, a new process inheriting its parent's directory and descriptors, ignoring unrelated processes, and normalizing paths.

This was referenced Sep 16, 2026
@LalitMaganti
LalitMaganti added this pull request to stack #32 September 16, 2026 12:57
@LalitMaganti
LalitMaganti removed this pull request from stack #32 October 18, 2026 02:40
@LalitMaganti
LalitMaganti added this pull request to stack #48 October 18, 2026 02:40
@LalitMaganti
LalitMaganti force-pushed the macos-record-3 branch 2 times, most recently from 1d0a127 to fa58647 Compare October 18, 2026 06:13
@LalitMaganti
LalitMaganti force-pushed the macos-record-3 branch 2 times, most recently from 9cb176f to 6202236 Compare October 18, 2026 08:23
@LalitMaganti LalitMaganti changed the title [DNM] macos: record the files each process opens macos: record the files each process opens Oct 18, 2026
The kernel reports each path as the program passed it, without resolving
it. A path can be relative to a working directory or to a directory
descriptor. Opening the root reports no path at all. Buildprof therefore
follows each process's working directory and the paths behind its open
descriptors, and resolves each path against them. Open flags are stored
with Linux's numbers, so the UI reads them the same way on both
platforms.

Recordings now carry file events, so --no-file-events makes a smaller
recording on macOS. Collection costs about the same either way, because
the same kernel events carry the working directories.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant