Git Product home page Git Product logo

fanotify_watch's Introduction

fanotify_watch

This tool allows you watch filesystem events using Linux fanotify(7) API. It has a Mac brother http://github.com/proger/fsevent_watch.

This is a fork of Canonical's tool fatrace: https://launchpad.net/fatrace

The tool differs from the original in the following ways:

  • removed power-usage-report
  • flags -s and -o are removed as redundant
  • the tool does not read process names on every event by default (see -n option)
  • output buffer is flushed after processing each event buffer
  • FAN_ACCESS-like events are ignored (see caveats)

Awesomeness

  • the output is cute and parseable
  • as usual, the tool is composable enough to be used to even develop itself

% sudo ./fanotify_watch -c | egrep --line-buffered "$PWD.*\.[ch]$" | tee /dev/stderr | xargs -t -n1 -I% make
6445    CW  /tank/proger/fanotify_watch/fanotify_watch.c
make
cc -O2 -g -Wall -Wextra -Werror   -c -o fanotify_watch.o fanotify_watch.c
cc  -o fanotify_watch fanotify_watch.o

Caveats

  • fanotify(7) does not support tracking file deletion/renames
  • fanotify_watch primarily tracks FAN_CLOSE_WRITE (writable file closed) that signals for very probable file write event
    • note that some tools may write the file under a different name and then rename it, this may go unnoticed
  • as of Linux 3.10 fanotify(7) needs you to be root (hence sudo)
    • you can use suid binaries at your own risk though
  • fanotify(7) does not work on nfs and sshfs mounts (at least when i tested)
  • GPL-3, sorry

fanotify_watch's People

Contributors

lambdaterm avatar proger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fanotify_watch's Issues

error: implicit declaration of function ‘major’

Under Fedora 35:

cc -O2 -g -Wall -Wextra -Werror   -c -o fanotify_watch.o fanotify_watch.c
fanotify_watch.c: In function ‘print_event’:
fanotify_watch.c:124:19: error: implicit declaration of function ‘major’ [-Werror=implicit-function-declaration]
  124 |                   major (st.st_dev), minor (st.st_dev), st.st_ino);
      |                   ^~~~~
fanotify_watch.c:124:38: error: implicit declaration of function ‘minor’ [-Werror=implicit-function-declaration]
  124 |                   major (st.st_dev), minor (st.st_dev), st.st_ino);
      |                                      ^~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: fanotify_watch.o] Error 1

This could be fixed by

#include <sys/sysmacros.h>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.