kqueue: avoid infinite loops from symlinks cycles

The semenatics of using kqueue are already slightly different than
inotify, specifically that inotify will give you events for the symlink
itself whereas kqueue will only give events for the target of the
symlink. This preserves that behaviour, that symlinks don't get notified
on, but ensures that circular symlinks don't recurse forever.

This change pushes the resolved filename up through the stack so that
the fileExists map can be properly populated; not doing so would mean
that deleting a cyclical symlink and then replacing it with a file of
the same name would not notify for that file's creation (or subsequent
events) because we would believe that the file already existed.
4 files changed
tree: 87fc30cd42aa1ce4e957bd3fd9bee0e0d733bfa1
  1. .gitignore
  2. .travis.yml
  3. AUTHORS
  4. CHANGELOG.md
  5. CONTRIBUTING.md
  6. example_test.go
  7. fsnotify.go
  8. inotify.go
  9. inotify_poller.go
  10. inotify_poller_test.go
  11. inotify_test.go
  12. integration_test.go
  13. kqueue.go
  14. LICENSE
  15. open_mode_bsd.go
  16. open_mode_darwin.go
  17. README.md
  18. windows.go
README.md

File system notifications for Go

GoDoc Coverage

Go 1.3+ required.

Cross platform: Windows, Linux, BSD and OS X.

AdapterOSStatus
inotifyLinux 2.6.27 or later, Android*Supported Build Status
kqueueBSD, OS X, iOS*Supported Build Status
ReadDirectoryChangesWWindowsSupported Build status
FSEventsOS XPlanned
FENSolaris 11Planned
fanotifyLinux 2.6.37+
USN JournalsWindowsMaybe
PollingAllMaybe

* Android and iOS are untested.

Please see the documentation for usage. Consult the Wiki for the FAQ and further information.

API stability

Two major versions of fsnotify exist.

fsnotify.v0 is API-compatible with howeyc/fsnotify. Bugfixes may be backported, but I recommend upgrading to v1.

import "gopkg.in/fsnotify.v0"

* Refer to the package as fsnotify (without the .v0 suffix).

fsnotify.v1 provides a new API based on this design document. You can import v1 with:

import "gopkg.in/fsnotify.v1"

Further API changes are planned, but a new major revision will be tagged, so you can depend on the v1 API.

Master may have unreleased changes. Use it to test the very latest code or when contributing, but don't expect it to remain API-compatible:

import "github.com/go-fsnotify/fsnotify"

Contributing

Please refer to CONTRIBUTING before opening an issue or pull request.

Example

See example_test.go.

Related Projects