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

How to notify for write operations only? (using -m inotify_monitor on linux) #322

Open
pmorch opened this issue May 10, 2024 · 0 comments
Open

Comments

@pmorch
Copy link

pmorch commented May 10, 2024

I was expecting only to see notifications for "write" operations that modify the file system. Is that a valid assumption?

I get 6 notifications from /bin/ls emptyDir. Am I misunderstanding something fundamental here?

Details

Terminal one:

$ mkdir emptyDir

# This uses -m inotify_monitor
$ fswatch -xr emptyDir
/home/pmorch/emptyDir IsDir
/home/pmorch/emptyDir PlatformSpecific
/home/pmorch/emptyDir IsDir
/home/pmorch/emptyDir PlatformSpecific
/home/pmorch/emptyDir IsDir
/home/pmorch/emptyDir PlatformSpecific

Why am I notified when starting up fswatch? Clearly nobody is writing to emptyDir yet.

Terminal two:

$ /bin/ls emptyDir
(no output from empty emptyDir)

But then in terminal one I see:

/home/pmorch/emptyDir IsDir
/home/pmorch/emptyDir PlatformSpecific
/home/pmorch/emptyDir IsDir
/home/pmorch/emptyDir PlatformSpecific
/home/pmorch/emptyDir IsDir
/home/pmorch/emptyDir PlatformSpecific

Why does /bin/ls emptyDir create 6 events?

If I use the non-standard -m poll_monitor I get events only for modifications.

How do I use the default inotify_monitor and only get notified for modifications? And if that is possible, why isn't it the default like it apparently is for -m poll_monitor?

Versions and environment

I've tried on machine1:

  • fswatch 1.14.0 installed with apt-get on a custom Debian-based distro
  • fswatch 1.17.1 installed from nix
  • on an ext4 file system

on machine2:

  • NixOS 23.11
  • fswatch 1.17.1
  • btrfs file system
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

No branches or pull requests

1 participant