]> go.fuhry.dev Git - fsnotify.git/log
fsnotify.git
3 years agoDon't use unkeyed structs in fen watcher
Martin Tournoij [Thu, 13 Oct 2022 06:08:46 +0000 (08:08 +0200)]
Don't use unkeyed structs in fen watcher

Might as well change sendEvent() to just accept the name and Op.

3 years agoDon't run illumos as root in the CI (#517)
Martin Tournoij [Thu, 13 Oct 2022 04:56:56 +0000 (06:56 +0200)]
Don't run illumos as root in the CI (#517)

Fixes #515

3 years agoUpdate changelog, README
Martin Tournoij [Thu, 13 Oct 2022 01:27:31 +0000 (03:27 +0200)]
Update changelog, README

3 years agoAdd FEN backend to support illumos and Solaris (#371)
Nahum Shalman [Thu, 13 Oct 2022 01:25:12 +0000 (21:25 -0400)]
Add FEN backend to support illumos and Solaris (#371)

Add support for illumos and Solaris.

Co-authored-by: Martin Tournoij <martin@arp242.net>
3 years agoUpdate ChangeLog
Martin Tournoij [Thu, 13 Oct 2022 01:18:11 +0000 (03:18 +0200)]
Update ChangeLog

3 years agoTweak the docs a bit
Martin Tournoij [Thu, 13 Oct 2022 01:10:35 +0000 (03:10 +0200)]
Tweak the docs a bit

3 years agoAdd test for re-adding a renamed file (#508)
Martin Tournoij [Thu, 15 Sep 2022 16:42:57 +0000 (18:42 +0200)]
Add test for re-adding a renamed file (#508)

Ref: #503

3 years agoUpdate x/sys
Martin Tournoij [Thu, 8 Sep 2022 16:47:14 +0000 (18:47 +0200)]
Update x/sys

3 years agoUpdate x/sys
Martin Tournoij [Fri, 26 Aug 2022 00:18:56 +0000 (02:18 +0200)]
Update x/sys

3 years agoAdd test to see what happens if you watch a symlink (#498)
Martin Tournoij [Wed, 10 Aug 2022 17:33:57 +0000 (19:33 +0200)]
Add test to see what happens if you watch a symlink (#498)

3 years agoClarify doc comment on WatchList() (#499)
Martin Tournoij [Wed, 10 Aug 2022 17:03:32 +0000 (19:03 +0200)]
Clarify doc comment on WatchList() (#499)

3 years agoAdd note about README version
Martin Tournoij [Wed, 10 Aug 2022 15:11:24 +0000 (17:11 +0200)]
Add note about README version

Fixes #497

3 years agoUpdate documentation and examples (#496)
Martin Tournoij [Wed, 10 Aug 2022 15:10:01 +0000 (17:10 +0200)]
Update documentation and examples (#496)

Update some documentation and add various examples. I added the examples
as subcommands of ./cmd/fsnotify, so they're directly runnable, and it's
at least guaranteed they compile.

This adds some simpler test cases so it's easier to verify it actually
works as documented on all platforms, and it adds internal.Debug() for
all platforms, which is useful in dev.

Fixes 49
Fixes 74
Fixes 94
Fixes 122
Fixes 238
Fixes 372
Fixes 401

3 years agoMove some inotify-tests to run on all backends; test that state is cleaned up after...
Martin Tournoij [Mon, 8 Aug 2022 13:56:08 +0000 (15:56 +0200)]
Move some inotify-tests to run on all backends; test that state is cleaned up after Remove (#494)

This moves a number of tests from backend_inotify_test.go to
fsnotify_test.go, as they're not really inotify-specific. In particular,
it moves the "stress test", which creates a bunch of events/files. It
also expands this test to (potentially) create many more than just 1,000
files, depending on how many the system will allow.

Unfortunately these tests seem pretty flaky on kqueue platforms, where
they're allowed to fail for now (failing the test won't fail the test
run). This seems to expose some existing limits/problems that need to
fixed in a future PR.

Also test that the internal state is cleaned up with TestRemoveState().
The Windows backend doesn't have a test for it (or rather, it doesn't
run) as it *doesn't* clean the state properly, but I found it too
confusing to fix 🤷 Need to spend some time on that in the future.

Reorder/rename some GitHub Actions test runs to show nicer in the UI.

Fixes #42
Fixes #268

3 years agoMove some files around
Martin Tournoij [Sat, 6 Aug 2022 18:24:59 +0000 (20:24 +0200)]
Move some files around

This will be useful once we start splitting out "systems" and "backends"
a bit more, e.g. when polling support is added.

3 years agoPort minor test changes from fen-v2 branch; make LICENSE text not ugly
Martin Tournoij [Sat, 6 Aug 2022 18:03:28 +0000 (20:03 +0200)]
Port minor test changes from fen-v2 branch; make LICENSE text not ugly

Also remove the copyright headers on the files; the license text
doesn't require them, forbids removing them, and they add nothing IMHO,
and it's a few more lines to scroll past every time you open a file.

3 years agowindows: simplify a bit (#493)
Martin Tournoij [Sat, 6 Aug 2022 17:56:40 +0000 (19:56 +0200)]
windows: simplify a bit (#493)

The sys* constants were used in the old golang.org/x/exp/winfsnotify
package on which this is based, but haven't been in use for a long time.

Remove the "one shot", "dir only", and "ignore" options as they were
never set. Also don't send "sysFSQOVERFLOW" as an event if the buffer is
too long; we already send an error and it's just a weird magical number
you get.

This could be simplified greatly more by removing the whole
sysFS… → windows.FILE_NOTIFY… → sysFS… conversions, but that's for
another day.

3 years agoall: add Watcher.{sendEvent,sendError} (#492)
Martin Tournoij [Sat, 6 Aug 2022 17:10:41 +0000 (19:10 +0200)]
all: add Watcher.{sendEvent,sendError} (#492)

Add a helper function instead of doing a select on w.done and w.Errors
or w.Events every time.

Also move most functions to methods on the Watcher.

3 years agokqueue: don't set up watchers on unreadable files (#479)
Martin Tournoij [Sat, 6 Aug 2022 16:40:15 +0000 (18:40 +0200)]
kqueue: don't set up watchers on unreadable files (#479)

Watching an entire directory would fail if it contains a file we can't
read due to permission errors. That's obviously not ideal, so just skip
the file.

Also add a test for trying to watch a directory where the permissions
are denied, and test the error is what's expected; this prevents
regressions like in #393.

Fixes #439

3 years agoUpdate changelog
Martin Tournoij [Sat, 6 Aug 2022 16:29:03 +0000 (18:29 +0200)]
Update changelog

3 years agokqueue: remove timeout from unix.Kevent() (#480)
Martin Tournoij [Sat, 6 Aug 2022 16:17:18 +0000 (18:17 +0200)]
kqueue: remove timeout from unix.Kevent() (#480)

The timeout for unix.Kevent() is causing issues; every 100ms it will do a new
unix.Kevent() syscall, which isn't too efficient: even if you have just one
change an hour, you will still keep calling kevent() ten times per second,
resulting in a needlessly high CPU usage.

Without a timeout, kevent() will block indefinitely until there are some events,
which is much more efficient. We can't just remove the timout however, since we
can't interrupt the kevent() call on FreeBSD and NetBSD, and it will hang
forever. This issue is described in more detail here:
https://github.com/fsnotify/fsnotify/pull/262#issuecomment-1201655890

To solve this we register a new kevent() with the file descriptor set to the
closepipe; when this pipe is closed an event is sent and kevent() will stop
blocking.

This is a rebased version of #124.

Fixes #89
Fixes #237
Fixes #333
Supersedes and closes #124
Supersedes and closes #262
Supersedes and closes #334

Co-authored-by: Felix Lange <fjl@twurst.com>
3 years agowindows: test symlinks (#491)
Martin Tournoij [Fri, 5 Aug 2022 21:45:16 +0000 (23:45 +0200)]
windows: test symlinks (#491)

Symlinks are supported since Windows Vista; there's no reason to not
test it.

3 years agowindows: run TestWatchRename/rename_overwriting_existing_file (#490)
Martin Tournoij [Fri, 5 Aug 2022 19:52:45 +0000 (21:52 +0200)]
windows: run TestWatchRename/rename_overwriting_existing_file (#490)

This Skip() was added in 2013 (c825c6d) with "Windows cannot overwrite
file on rename", but it seems to work fine. os.Rename() is also
documented as "If newpath already exists and is not a directory, Rename
replaces it", so if it *doesn't* work it's a bug in os.Rename(). Maybe
os.Rename() behaved different nine years ago.

3 years agoUse "os.Rename()" in tests instead of "mv"
Martin Tournoij [Fri, 5 Aug 2022 15:03:18 +0000 (17:03 +0200)]
Use "os.Rename()" in tests instead of "mv"

This was added in 00f2dfd (2011): "BSD Test: Need to use outside program
to trigger some events". All tests pass fine with just os.Rename(), so
just use that.

Might add another real-world test in the future for common tools like
mv, cp, vi, etc. because they don't always behave the same as library
calls, but calling mv in *only* the mv() helper is rather odd.

This also renames a few things in the kqueue helper for clarity, and
uses map[string]struct{} if we just use them for lookups to an
allocation (I originally tried to fix #488, but gave up on that for now,
hence the kqueue changes).

3 years agocmd/fsnotify: fix time.Format() string
Martin Tournoij [Thu, 4 Aug 2022 21:23:11 +0000 (23:23 +0200)]
cmd/fsnotify: fix time.Format() string

3 years agowindows: replace syscall with golang.org/x/sys/windows
Martin Tournoij [Thu, 4 Aug 2022 00:38:52 +0000 (02:38 +0200)]
windows: replace syscall with golang.org/x/sys/windows

Specifically to address #364; syscall.GetQueuedCompletionStatus()
contains a bug that can't be fixed in a backwards-compatible way, so
they didn't. Once you use sys/windows for one thing, you gotta use it
for everything.

I ran the tests with -count=100 locally, and it all seems fine.

Fixes #364

3 years agowindows: replace "e" with "err" for error variables
Martin Tournoij [Thu, 4 Aug 2022 00:36:16 +0000 (02:36 +0200)]
windows: replace "e" with "err" for error variables

3 years agowindows: increase buffer size from 4K to 64K (#485)
Martin Tournoij [Thu, 4 Aug 2022 01:25:38 +0000 (03:25 +0200)]
windows: increase buffer size from 4K to 64K (#485)

People are running in to trouble because the 4K buffer can overflow;
see: #72.

This is not a "real" fix, but I think a 64K buffer is acceptable even on
memory-limited machines; no one is running the Windows on an Arduino,
and even with something like 128M of memory, the extra 124K is basically
negligible. There is also no real performance difference between
allocating a large array vs. a small array: they're both comparable.

It should probably be enough for most applications. Need to look in the
future to either dynamically grow the size, or allow setting it similar
to what tilt does as mentioned in #72.

3 years agoci: update to use Go 1.19, kick off fewer builds, update x/sys (#484)
Martin Tournoij [Wed, 3 Aug 2022 13:36:21 +0000 (15:36 +0200)]
ci: update to use Go 1.19, kick off fewer builds, update x/sys (#484)

We need to update x/sys to support GOARCH=loong64, which is new in Go
1.19.

Also kick off fewer builds; they regularly get hung in the queue as we
have quite a few test jobs now.

3 years agoRemove CLA section in contributing
Martin Tournoij [Wed, 3 Aug 2022 12:50:33 +0000 (14:50 +0200)]
Remove CLA section in contributing

Not really needed anymore as far as I can tell:
https://github.com/fsnotify/fsnotify/issues/193#issuecomment-1203909130

3 years agoNeed Linux 5.9 for a useful fanotify we can use
Martin Tournoij [Wed, 3 Aug 2022 12:13:14 +0000 (14:13 +0200)]
Need Linux 5.9 for a useful fanotify we can use

3 years agoUpdate CONTRIBUTING.md
Martin Tournoij [Tue, 2 Aug 2022 08:09:56 +0000 (10:09 +0200)]
Update CONTRIBUTING.md

3 years agoRemove PULL_REQUEST_TEMPLATE
Martin Tournoij [Tue, 2 Aug 2022 07:11:07 +0000 (09:11 +0200)]
Remove PULL_REQUEST_TEMPLATE

It's annoying as I need to keep deleting the template, and it doesn't provide that much value IMO.

3 years agoRun tests in illumos (#481)
Martin Tournoij [Mon, 1 Aug 2022 22:58:19 +0000 (00:58 +0200)]
Run tests in illumos (#481)

Doesn't really test anything yet, but should do soon.

3 years agoUpdate ChangeLog
Martin Tournoij [Sun, 31 Jul 2022 20:44:24 +0000 (22:44 +0200)]
Update ChangeLog

3 years ago[bugfix] close handle when remWatch open in getIno (#288)
jie [Sun, 31 Jul 2022 20:42:51 +0000 (04:42 +0800)]
[bugfix] close handle when remWatch open in getIno (#288)

* [bugfix] close handle when remWatch open in getIno

* Use new tests

Note: the tests pass even without the syscall.CloseHandle()

Co-authored-by: jie <jie@tt.com>
Co-authored-by: Martin Tournoij <martin@arp242.net>
3 years agowindows: update watch paths when renaming directories with sub-watches (#370)
Arne Groskurth [Sun, 31 Jul 2022 19:16:05 +0000 (21:16 +0200)]
windows: update watch paths when renaming directories with sub-watches (#370)

Fixes #259
Fixes #243

Co-authored-by: Martin Tournoij <martin@arp242.net>
3 years agoRewrite tests (#478)
Martin Tournoij [Sun, 31 Jul 2022 18:03:10 +0000 (20:03 +0200)]
Rewrite tests (#478)

Rewrite tests

This rewrites quite a lot of tests to be much more easily readable.

While working on #472 I wanted to check "how do renames behave now?",
and found this quite hard as most test cases were >90% "plumbing", and
seeing "what file operations does this do?" and "what events do we get?"
was not very easy.

So refactor the lot, based on some work I did in #472:

- Add a bunch of "shell-like" helper functions so you're not forever
  typing error checks, filepath.Join(), and eventSeparator(). Just
  touch(t, tmp, "file") will create a file in tmp.

- Add eventCollector type which will collect all events in in a slice,
  replacing the previous "counter". This also ensures that the Watcher
  is closed within a second (this removes a lot of duplicate code).

  This is also much more precise than merely counting events; before
  random events could get emitted but if you weren't counting those then
  you'd never know.

  Downside is that some tests are a bit more flaky now as some
  behaviours are not always consistent in various edge cases; these are
  pre-existing bugs.

- Add Events (plural) type (only for tests), and helper function to
  create this from a string like:

      REMOVE  /link
      CREATE  /link
      WRITE   /link

  Which makes seeing which events are received, diffing them, etc. much
  easier.

- Add Parallel() for most tests; reduces runtime on my system from ~12
  seconds to ~6 seconds.

All in all it reduces the integrations_test.go from 1279 lines to 405
lines and it's quite easy to see which events are expected for which
operations, which should make things a lot easier going forward.

3 years agoAdd {Event,Op}.Has() (#477)
Martin Tournoij [Sat, 30 Jul 2022 15:28:03 +0000 (17:28 +0200)]
Add {Event,Op}.Has() (#477)

Using:

if event.Op&fsnotify.Create == fsnotify.Create {
}

is overly verbose and awkward; a Has() method makes this much nicer:

if event.Has(fsnotify.Create) {
}

PR #76 was previously rejected; I think that HasCreate() etc. is
overkill, but a Has() method makes the library quite a bit more
convenient IMO.

I added it to both the Event and Op to avoid confusion; with this we can
change the Op field to be private in a future v2.

Fixes #107

3 years agoDocument that /proc and /sys won't work
Martin Tournoij [Sat, 30 Jul 2022 12:31:21 +0000 (14:31 +0200)]
Document that /proc and /sys won't work

Fixes #78

3 years agoClarify FAQ on goroutines
Martin Tournoij [Sat, 30 Jul 2022 11:15:01 +0000 (13:15 +0200)]
Clarify FAQ on goroutines

Fixes #71

3 years agomacos: retry if open() returns EINTR (#475)
Martin Tournoij [Sat, 30 Jul 2022 10:54:27 +0000 (12:54 +0200)]
macos: retry if open() returns EINTR (#475)

Retry the unix.Open() if the error returned is EINTR; looking around the
web it seems many systems handle it like this. This is also what
os.Open() does:
https://github.com/golang/go/commit/50d0ee0c98ea21f818d2daa9bc21ef51861a2ef9

Fixes #354

3 years agoFix lint (#476)
Martin Tournoij [Sat, 30 Jul 2022 10:53:47 +0000 (12:53 +0200)]
Fix lint (#476)

Didn't run for some reasons; something with the actions cache:

/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/b9a1abd7-273e-449f-b255-5e8e947b3f97/cache.tzst -P -C /home/runner/work/fsnotify/fsnotify
Error: /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/sys@v0.0.0-20220412211240-33da011f77ad/windows/race0.go: Cannot open: File exists
Error: /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/sys@v0.0.0-20220412211240-33da011f77ad/windows/types_windows.go: Cannot open: File exists

Replace it with staticcheck; which is nicer anyway.

3 years agodebian 6 test: deal with multiple packages (#474)
Martin Tournoij [Fri, 29 Jul 2022 23:33:19 +0000 (01:33 +0200)]
debian 6 test: deal with multiple packages (#474)

* debian 6 test: deal with multiple packages

The ./cmd/fsnotify doesn't have any tests, but sooner or later we'll
have subpackages so deal with it properly now.

* Cache vagrant boxes

3 years agoRemove AUTHORS file
Martin Tournoij [Fri, 29 Jul 2022 21:00:44 +0000 (23:00 +0200)]
Remove AUTHORS file

This goes back to when this library was part of golang.org/x/...; the "Google lawyers" said that an AUTHORS file was needed, but seems they changed their minds and it got removed from Go last week and decided that the git log is enough:
https://github.com/golang/go/commit/774fa58d1d3c9926709e108afdf83af7010bde72

I don't think there's much value keeping it here, and it's one more thing that can be forgotten (it's already out of date). The authorship is preserved in the git log, and if that's good enough for Google's lawyers then it's good enough for me.

3 years agoUpdate README: split out FAQ to "Platform-specific notes"
Martin Tournoij [Fri, 29 Jul 2022 20:15:40 +0000 (22:15 +0200)]
Update README: split out FAQ to "Platform-specific notes"

It's a bit clearer to document it like this.

Also some other minor changes to the README.

Fixes #457

3 years agoinotify: don't ignore events for files that don't exist (#470)
Martin Tournoij [Fri, 29 Jul 2022 18:31:09 +0000 (20:31 +0200)]
inotify: don't ignore events for files that don't exist (#470)

This is quite an odd check, leading to an inconsistent event stream,
which also doesn't match what other platforms do. If you do a "CREATE +
MODIFY + REMOVE" in quick succession then you probably *want* all three
events. If you don't want to operate on non-existing files, then you can
check this in your application code.

You need to do that already, since this check is far from reliable. In
the time between this check and the application code doing something
with an event the file may have been deleted already.

I looked a bit at the history of this, and looks like it was added in
2013 with cc2c34e; issue 36 refers to this issue on the old repo, which
mentions it fixes a memory leak: https://github.com/howeyc/fsnotify/issues/36

I can't reproduce that at all; using the CLI from #463 modified to print
the memory and running:

for i in $(seq 0 10000); { touch $i; rm $i }

Memory stays at about 100/110K in both the current main branch and this.

So I think it should be safe to remove.

3 years agoTweak comment regarding relative paths (#466)
Martin Tournoij [Fri, 29 Jul 2022 18:29:25 +0000 (20:29 +0200)]
Tweak comment regarding relative paths (#466)

Clarify what "relative" means here.

Fixes #362

3 years agoAdd cmd/fsnotify (#463)
Martin Tournoij [Fri, 29 Jul 2022 18:28:45 +0000 (20:28 +0200)]
Add cmd/fsnotify (#463)

This adds a little example that can be run:

% go run ./cmd/fsnotify **/*
12:76:11.4710 watching; press ^C to exit
12:76:13.6549   1 REMOVE                "cmd/fsnotify/4913"
12:76:13.6550   2 RENAME                "cmd/fsnotify/main.go"
12:76:13.6550   3 RENAME                "cmd/fsnotify/main.go"
12:76:13.6612   4 CREATE                "cmd/fsnotify/main.go"
12:76:13.6612   5 WRITE      (modified) "cmd/fsnotify/main.go"
12:76:13.6614   6 WRITE      (modified) "cmd/fsnotify/main.go"
12:76:13.6648   7 CHMOD                 "cmd/fsnotify/main.go"
12:76:15.2919   8 CREATE                "cmd/fsnotify/4913"
12:76:15.2919   9 REMOVE                "cmd/fsnotify/4913"
12:76:15.2922  10 CHMOD                 "cmd/fsnotify/main.go"
12:76:15.2923  11 REMOVE                "cmd/fsnotify/main.go"
12:76:15.2925  12 RENAME                "cmd/fsnotify/main.go"
12:76:15.2986  13 CREATE                "cmd/fsnotify/main.go"
12:76:15.2986  14 WRITE      (modified) "cmd/fsnotify/main.go"
12:76:15.2988  15 WRITE      (modified) "cmd/fsnotify/main.go"
12:76:15.3024  16 CHMOD                 "cmd/fsnotify/main.go"
^C

It's mostly the same as the example in the README, except that it takes
paths from the commandline and aligns things a bit nicer.

This is useful for documentation and experimentation. For example, while
reviewing some PRs I found it useful to quickly get an overview of "what
does fsnotify do now, and what does it do with this patch?"

3 years agokqueue: better error if watching a file fails (#471)
Martin Tournoij [Fri, 29 Jul 2022 18:28:22 +0000 (20:28 +0200)]
kqueue: better error if watching a file fails (#471)

kqueue requires opening a file descriptor for every file; so we read the
directory and do that. If this failed the error was quite unclear; for
example:

"/tmp/fsnotify_permission_denied/": permission denied

This puts the filepath in there:

"/tmp/fsnotify_permission_denied/": "/tmp/fsnotify_permission_denied/test2.log": permission denied

Fixes #270

3 years agoReplace Use of Kthread-blocking Epoll with Poller Read, Remove Per-Event LStats on...
OtoMAN [Sun, 24 Jul 2022 10:50:47 +0000 (03:50 -0700)]
Replace Use of Kthread-blocking Epoll with Poller Read, Remove Per-Event LStats on Linux #433 (#434)

* Replaced use of raw epoll with netpoller read

* Remove Debian 6 Vagrant test; it's in #469 now

* Added ignoreLinux lstats back in

* Update test

Co-authored-by: Martin Tournoij <martin@arp242.net>
3 years agoTest some more things in CI (#469)
Martin Tournoij [Sun, 24 Jul 2022 09:22:52 +0000 (11:22 +0200)]
Test some more things in CI (#469)

* Test some more things in CI

- Test all GOOS/GOARCH combinations by looping over "go tool dist list";
this just tests if it compiles.

- Add a Vagrant box to test Debian 6 / Linux 2.6.32; this was adapted
from @horahoradev's patch at #434.

- Update the minimum version requirements: we test Linux 2.6.32 now and
  turns out that's also the minimum version [Go supports] in recent
  releases, so just set it to that.

  Need Go 1.16 for retract in go.mod. I don't know, maybe we can just
  remove the retract? Latest Debian ships with Go 1.15.

  [Go supports]: https://github.com/golang/go/issues/45964

- Test both Go 1.16 and 1.18 (the lowest supported version and newest
  version). I guess we could also test 1.17, but the CI already takes
  somewhat long and I can't recall ever having a situation where an
  intermediate version failed.

- Test macOS 11 and 12; macOS 10.15 will (probably) end support in
  November, so probably not worth supporting this. GitHub will [remove]
  support for this at the end of August.

  [remove]: https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22/

- Test OpenBSD, NetBSD.

- Move "lint" to its own YAML file.

Future work:

- Actually run tests for all systems Go supports. Bit pointless right
  now as many of these don't do anything. Currently untested are
  Solaris, illumios, plan9, AIX, Android, iOS, DragonflyBSD, WASM.

  Some of these might be difficult (AIX, iOS, Android), but haven't
  looked in to it. I tried setting up Solaris with the
  vmactions/solaris, but it doesn't seem to have an easy way to install
  Go.

- GitHub only [supports] Windows Server 2019 and 2022; probabably also
  want to test Server 2016, but GitHub dropped support for this. Can
  maybe use AppVeyor(?)

  [supports]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners

- Could maybe test older versions of BSD, too. Not sure of it's worth
  it.

* Skip TestFsnotifyMultipleOperations on NetBSD

This test doesn't seem to work; I'm sure it passed at least once in the
CI, but locally I can't seem to get it to work.

Fails with:

=== RUN   TestFsnotifyMultipleOperations
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": CREATE
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": WRITE
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": REMOVE|RENAME
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": CREATE
     integration_test.go:186: incorrect number of rename+delete events received after 500 ms (2 vs 1)
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": REMOVE
     integration_test.go:114: event received: "/tmp/fsnotify2194826986": REMOVE|WRITE

For reference, this is the output on Linux and OpenBSD (the output is
identical):

=== RUN   TestFsnotifyMultipleOperations
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": CREATE
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": WRITE
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": RENAME
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": CREATE
     integration_test.go:190: calling Close()
     integration_test.go:192: waiting for the event channel to become closed...
     integration_test.go:195: event channel closed

* Fix "too many open files" on Debian 6, maybe

I guess this started failing after I rebased on main; let's see if a
small sleep works to clean up the file descriptors.

3 years agoAdd missing changelog for 1.4.{8,9} (#468)
Martin Tournoij [Sun, 24 Jul 2022 09:22:28 +0000 (11:22 +0200)]
Add missing changelog for 1.4.{8,9} (#468)

Just copied from the releases page: https://github.com/fsnotify/fsnotify/releases

Fixes #332

3 years agoinotify: fix race in Close() (#465)
Martin Tournoij [Fri, 22 Jul 2022 05:22:49 +0000 (07:22 +0200)]
inotify: fix race in Close() (#465)

Would sometimes fail with:

panic: close of closed channel

goroutine 204 [running]:
github.com/fsnotify/fsnotify.(*Watcher).Close(0xc0003e6410)
         /home/martin/code/Golib/fsnotify/inotify.go:82 +0x66
created by github.com/fsnotify/fsnotify.TestCloseRace
         /home/martin/code/Golib/fsnotify/integration_test.go:1256 +0x1a5
exit status 2

Because isClosed() might return "false" for two goroutines, and then
they will both try to close it, resulting in the panic.

Fixes #367

3 years agoClarify README on network drives (#467)
Martin Tournoij [Fri, 22 Jul 2022 05:22:31 +0000 (07:22 +0200)]
Clarify README on network drives (#467)

3 years agoUpdate link to CONTRIBUTING in the README (#464)
John Olheiser [Fri, 22 Jul 2022 01:37:07 +0000 (20:37 -0500)]
Update link to CONTRIBUTING in the README (#464)

3 years agoUpdate documentation for linux systems (max_user_watches) (#287)
Sascha Grunert [Thu, 21 Jul 2022 11:52:49 +0000 (13:52 +0200)]
Update documentation for linux systems (max_user_watches) (#287)

* Update documentation for linux systems

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
* Rewrite a bit for clarity

Co-authored-by: Martin Tournoij <martin@arp242.net>
3 years agobump up GitHub Actions (#461)
ICHINOSE Shogo [Thu, 21 Jul 2022 11:32:59 +0000 (20:32 +0900)]
bump up GitHub Actions (#461)

- bump actions/setup-go from v2 to v3
- bump actions/checkout from v2 to v3
- bump vmactions/freebsd-vm from v0.1.5 to v0.2.0

3 years agoDo not suppress Chmod on non-existent file (#260)
Kir Kolyshkin [Thu, 21 Jul 2022 11:32:11 +0000 (04:32 -0700)]
Do not suppress Chmod on non-existent file (#260)

Currently fsnotify suppresses a Chmod event if the file does not exist
when the event is received.

This makes it impossible to use fsnotify to detect when an opened file
is removed. In such case the Linux kernel sends IN_ATTRIB event,
as described in inotify(7) man page:

> IN_ATTRIB (*)
>        Metadata  changed—for example, permissions (e.g., chmod(2)),
>        timestamps (e.g., utimensat(2)), extended attributes  (setx‐
>        attr(2)), link count (since Linux 2.6.25; e.g., for the tar‐
>        get of link(2) and for unlink(2)), and user/group ID  (e.g.,
>        chown(2)).

(to clarify, in this very case it's link count that changes).

To fix:
 * Modify the code to only suppress MODIFY and CREATE events.
 * Add a test case to verify Chmod event is delivered.

While at it, fix the comment in ignoreLinux() to use the up-to-date
terminology (event ops).

A test case is added.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
3 years agokqueue: Make watcher.Close() O(n) instead of O(n^2) (#233)
Nick Santos [Thu, 21 Jul 2022 10:20:14 +0000 (11:20 +0100)]
kqueue: Make watcher.Close() O(n) instead of O(n^2) (#233)

In the old implementation watcher.Close() would clone the list of
watches and then run Remove() on that, and every Remove() call would
iterate over the full list of watches.

This stores the watches more efficiently so that Remove() doesn't need
to iterate over the full list: instead of merely a path → fd map, it
also stores a parent-path → list-of-files.

No functional changes, just a performance improvement.

3 years agostrings.Builder instead of bytes.Buffer (#285)
Ilan Pillemer [Thu, 21 Jul 2022 07:39:21 +0000 (08:39 +0100)]
strings.Builder instead of bytes.Buffer (#285)

3 years agoExplicit mutext (un)locking (#462)
John Olheiser [Thu, 21 Jul 2022 07:25:52 +0000 (02:25 -0500)]
Explicit mutext (un)locking (#462)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
3 years agoUse common error when removing an unwatched file (#460)
Martin Tournoij [Thu, 21 Jul 2022 03:06:57 +0000 (05:06 +0200)]
Use common error when removing an unwatched file (#460)

The errors returned by the various implementations of the watcher are all different
which makes handling them difficult. This PR follows the suggestion in:
https://github.com/fsnotify/fsnotify/pull/455#issuecomment-1146037157 by @mattn
to create a common error which is wrapped by the implementations.

Replaces: https://github.com/fsnotify/fsnotify/pull/455
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
3 years agowindows: protect access to isClosed with mutex (#454)
Robert Fratto [Thu, 21 Jul 2022 03:06:40 +0000 (23:06 -0400)]
windows: protect access to isClosed with mutex (#454)

isClosed may be read and modified concurrently if the Windows Watcher is
closed at the same time as a new entry being added. This change protects
isClosed to prevent race conditions.

The order of fields for the Windows Watcher have been rearranged to
group fields protected by the mutex together.

3 years agoTest Go 1.18
Martin Tournoij [Thu, 21 Jul 2022 02:13:51 +0000 (04:13 +0200)]
Test Go 1.18

3 years agoThis project is archived (#459)
Nathan Youngman [Fri, 8 Jul 2022 16:16:12 +0000 (10:16 -0600)]
This project is archived (#459)

3 years agoPrepare for v1.5.4 (#448)
ICHINOSE Shogo [Wed, 27 Apr 2022 02:06:09 +0000 (11:06 +0900)]
Prepare for v1.5.4 (#448)

* Update Changelog
* Retracted v1.5.3

3 years agoWindows: add missing defer to Watcher.WatchList (#447)
Sojamann [Sun, 24 Apr 2022 03:11:44 +0000 (03:11 +0000)]
Windows: add missing defer to Watcher.WatchList (#447)

3 years agoREADME.md: link to pkg.go.dev for golang.org/x/sys package (#441)
Tobias Klauser [Sun, 24 Apr 2022 03:11:16 +0000 (05:11 +0200)]
README.md: link to pkg.go.dev for golang.org/x/sys package (#441)

Also add a link to the syscall package and remove some trailing
whitespaces.

3 years agogo.mod: use latest x/sys (#444)
Kevin Burke [Sun, 24 Apr 2022 02:56:16 +0000 (19:56 -0700)]
go.mod: use latest x/sys (#444)

This version contains several upgrades including a newer version of
glibc and some bug fixes.

3 years agoFix compilation for OpenBSD (#443)
mattn [Thu, 21 Apr 2022 18:01:20 +0000 (03:01 +0900)]
Fix compilation for OpenBSD (#443)

Closes #442

3 years agoAdd a feature to return the directories and files that are being monitored (#374)
NitroCao [Thu, 21 Apr 2022 06:46:51 +0000 (14:46 +0800)]
Add a feature to return the directories and files that are being monitored (#374)

* Add a feature to return the directories and files that are being monitored

* add WatchList() method for bsd and windows platforms

* preallocate space for the array to be returned

3 years agoFix potential crash on windows if raw.FileNameLength exceeds syscall.MAX_PATH (#361)
Hangkun Ung [Wed, 26 Jan 2022 13:21:14 +0000 (08:21 -0500)]
Fix potential crash on windows if raw.FileNameLength exceeds syscall.MAX_PATH (#361)

* Fix crash on windows if raw.FileNameLength exceeds syscall.MAX_PATH

* Add comment

* Update windows.go

3 years agoAllow build on unsupported GOOS (#424)
Tobias Klauser [Tue, 25 Jan 2022 02:13:06 +0000 (03:13 +0100)]
Allow build on unsupported GOOS (#424)

In cases where fsnotify is a transitive dependency of a package, it
might need to be built on platforms not supported (yet), e.g. aix.
Provide an empty implemention for these cases, so depending packages
don't need to add workarounds.

Replaces #314

3 years agoAdd FreeBSD testing in Github Actions (#419)
Roey Darwish Dror [Mon, 24 Jan 2022 01:28:23 +0000 (03:28 +0200)]
Add FreeBSD testing in Github Actions (#419)

Fixes #389

3 years agoIntegration Tests: consistent sleeps with informative names (#422)
Nahum Shalman [Thu, 20 Jan 2022 02:37:34 +0000 (21:37 -0500)]
Integration Tests: consistent sleeps with informative names (#422)

* Change 1ms sleeps to 50ms
* Use const variable names to indicate why we are sleeping

3 years agoEnable cross-compilation builds on PRs (#423)
Nahum Shalman [Thu, 20 Jan 2022 02:33:55 +0000 (21:33 -0500)]
Enable cross-compilation builds on PRs (#423)

3 years agoRe-enable tests for PRs (#415)
Nahum Shalman [Thu, 20 Jan 2022 01:31:12 +0000 (20:31 -0500)]
Re-enable tests for PRs (#415)

It would be good to re-enable tests on PRs.

3 years agoDon't set poller.fd twice in newFdPoller (#406)
Tobias Klauser [Wed, 19 Jan 2022 14:22:52 +0000 (15:22 +0100)]
Don't set poller.fd twice in newFdPoller (#406)

In newEmptyPoller when creating the poller using newEmptyPoller(fd), the
fd field of the poller instance is already set. There is no need to set
it again.

3 years agoRun cross-compilation builds on every push (#420)
Nahum Shalman [Wed, 19 Jan 2022 02:29:44 +0000 (21:29 -0500)]
Run cross-compilation builds on every push (#420)

This would have caught #389 and should
catch build failures for supported targets.

3 years agofix go vet warnings: call to (*T).Fatalf from a non-test goroutine (#416)
Ichinose Shogo [Mon, 17 Jan 2022 14:35:07 +0000 (23:35 +0900)]
fix go vet warnings: call to (*T).Fatalf from a non-test goroutine (#416)

3 years agoFinal Notice: Maintainers Wanted
Nathan Youngman [Fri, 14 Jan 2022 07:26:03 +0000 (00:26 -0700)]
Final Notice: Maintainers Wanted

3 years agomaintainers wanted
Nathan Youngman [Fri, 14 Jan 2022 05:07:14 +0000 (22:07 -0700)]
maintainers wanted

3 years agorevise contributing
Nathan Youngman [Fri, 14 Jan 2022 04:38:49 +0000 (21:38 -0700)]
revise contributing

3 years agoupdate readme
Nathan Youngman [Fri, 14 Jan 2022 04:35:17 +0000 (21:35 -0700)]
update readme

3 years agoTest on Go 1.18 and two most recent versions (#411)
Nathan Youngman [Fri, 14 Jan 2022 03:49:28 +0000 (20:49 -0700)]
Test on Go 1.18 and two most recent versions (#411)

* Test on Go 1.18 and two most recent versions

* on push

* ci

3 years agoUpdate issue templates (#410)
Nathan Youngman [Fri, 14 Jan 2022 03:02:46 +0000 (20:02 -0700)]
Update issue templates (#410)

* Update issue templates

* remove old issue template

3 years agoRemoved dead link
Loïc Vernet [Thu, 7 May 2020 14:06:57 +0000 (16:06 +0200)]
Removed dead link

4 years agoprepare 1.5.1, retract 1.5.0
Nathan Youngman [Tue, 24 Aug 2021 19:33:30 +0000 (13:33 -0600)]
prepare 1.5.1, retract 1.5.0

4 years agoRevert "Add AddRaw to not follow symlinks + Fix link folloing on Windows (#289)"
Nathan Youngman [Tue, 24 Aug 2021 19:09:43 +0000 (13:09 -0600)]
Revert "Add AddRaw to not follow symlinks + Fix link folloing on Windows (#289)"

This reverts commit e2e95171bc7c7402864e613c8b00a768fbcc2380.

4 years agorevise pull request template
Nathan Youngman [Tue, 24 Aug 2021 00:34:28 +0000 (18:34 -0600)]
revise pull request template

4 years agov1.5.0 preparation (#380)
Oliver Bristow [Wed, 18 Aug 2021 22:48:34 +0000 (23:48 +0100)]
v1.5.0 preparation (#380)

4 years agoAdd AddRaw to not follow symlinks + Fix link folloing on Windows (#289)
Oliver Bristow [Wed, 18 Aug 2021 21:08:44 +0000 (22:08 +0100)]
Add AddRaw to not follow symlinks + Fix link folloing on Windows (#289)

4 years agoUpdate test matrix for go 1.17 stable release (#385)
Nahum Shalman [Tue, 17 Aug 2021 14:33:47 +0000 (10:33 -0400)]
Update test matrix for go 1.17 stable release (#385)

4 years agoadd //go:build lines + add 1.17.0-rc2 to test matrix (#377)
Ichinose Shogo [Wed, 4 Aug 2021 20:19:43 +0000 (05:19 +0900)]
add //go:build lines + add 1.17.0-rc2 to test matrix (#377)

4 years agoUpdate x/sys to latest (#379)
Nahum Shalman [Wed, 4 Aug 2021 19:53:11 +0000 (15:53 -0400)]
Update x/sys to latest (#379)

4 years agoDrop support/testing for Go 1.11 and earlier (#381)
Nahum Shalman [Wed, 4 Aug 2021 19:46:51 +0000 (15:46 -0400)]
Drop support/testing for Go 1.11 and earlier (#381)

4 years agoRemove Travis CI and references
Oliver Bristow [Sun, 1 Aug 2021 10:11:11 +0000 (11:11 +0100)]
Remove Travis CI and references

4 years agoAdd lint+vet+old versions to GitHub Action
Oliver Bristow [Sun, 1 Aug 2021 09:19:38 +0000 (10:19 +0100)]
Add lint+vet+old versions to GitHub Action

4 years agointroduce GitHub Actions
Ichinose Shogo [Sat, 31 Jul 2021 07:13:10 +0000 (16:13 +0900)]
introduce GitHub Actions