integrate inotify syscalls

This commit is contained in:
Dominic Breuker
2018-02-09 09:50:31 +01:00
parent 1e1df9ac71
commit e681208a4a
5 changed files with 199 additions and 69 deletions

View File

@@ -0,0 +1,25 @@
package inotify
import (
"fmt"
"golang.org/x/sys/unix"
)
const events = unix.IN_ALL_EVENTS
type watcher struct {
wd int
dir string
}
func newWatcher(fd int, dir string, ping chan struct{}) (*watcher, error) {
wd, errno := unix.InotifyAddWatch(fd, dir, events)
if wd == -1 {
return nil, fmt.Errorf("adding watcher on %s: %d", dir, errno)
}
return &watcher{
wd: wd,
dir: dir,
}, nil
}