Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import monitor tool from DragonflyBSD #30

Closed
wants to merge 4 commits into from

Conversation

ricardobranco777
Copy link

@ricardobranco777 ricardobranco777 commented Feb 2, 2024

  • Import monitor tool from DragonflyBSD.
  • Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE & NOTE_READ supported by FreeBSD & NetBSD 10.
  • Add support for NOTE_TRUNCATE supported by OpenBSD.

Also trying with FreeBSD: freebsd/freebsd-src#1087

usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
Copy link

@riastradh riastradh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks, this seems like a good idea! I noted some minor style nits, and I have one substantive suggestion: pass the paths through vis(3) and generally make the output format reliably parseable, so that it can be safely fed through awk or otherwise reliably ingested by other programs. What do you think?

usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
usr.bin/monitor/monitor.c Outdated Show resolved Hide resolved
Comment on lines +172 to +175
if (VerboseOpt && fstat(kev->ident, &st) == 0 &&
S_ISREG(st.st_mode)) {
printf(" %10jd", (intmax_t)st.st_size);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be presented differently so the format is more easily parseable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be presented differently so the format is more easily parseable?

Any suggestion. The size is always shown in a predictable field for awk.

@ricardobranco777
Copy link
Author

ricardobranco777 commented Feb 8, 2024

Cool, thanks, this seems like a good idea! I noted some minor style nits, and I have one substantive suggestion: pass the paths through vis(3) and generally make the output format reliably parseable, so that it can be safely fed through awk or otherwise reliably ingested by other programs. What do you think?

I think I addressed all your suggestions. The only bug though is that a file should no longer be monitored after a delete event, since it no longer catches events after that.

I no longer think this tool belongs at all to base but examples instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants