From d395793fc348c1a731325439285b565513bbf27e Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Mon, 12 Jun 2017 10:54:15 +0200 Subject: [PATCH] Update github.com/zillode/notify dependency (fixes #167) --- vendor/github.com/zillode/notify/doc.go | 7 +- vendor/github.com/zillode/notify/event.go | 2 +- vendor/github.com/zillode/notify/event_fen.go | 29 +++++--- .../zillode/notify/event_inotify.go | 40 +++++------ .../github.com/zillode/notify/event_kqueue.go | 2 +- .../zillode/notify/event_readdcw.go | 14 +++- vendor/github.com/zillode/notify/notify.go | 6 +- .../github.com/zillode/notify/watcher_fen.go | 18 +++-- .../zillode/notify/watcher_fen_cgo.go | 10 +-- .../zillode/notify/watcher_fsevents_cgo.go | 2 +- .../zillode/notify/watcher_inotify.go | 71 ++++++++++--------- .../zillode/notify/watcher_kqueue.go | 13 ++-- .../zillode/notify/watcher_trigger.go | 18 ++--- .../zillode/notify/watchpoint_other.go | 2 +- vendor/manifest | 2 +- 15 files changed, 127 insertions(+), 109 deletions(-) diff --git a/vendor/github.com/zillode/notify/doc.go b/vendor/github.com/zillode/notify/doc.go index 8a99ddd..60543c0 100644 --- a/vendor/github.com/zillode/notify/doc.go +++ b/vendor/github.com/zillode/notify/doc.go @@ -12,11 +12,14 @@ // source file. // // On top of filesystem watchers notify maintains a watchpoint tree, which provides -// strategy for creating and closing filesystem watches and dispatching filesystem +// a strategy for creating and closing filesystem watches and dispatching filesystem // events to user channels. // // An event set is just an event list joint using bitwise OR operator // into a single event value. +// Both the platform-independent (see Constants) and specific events can be used. +// Refer to the event_*.go source files for information about the available +// events. // // A filesystem watch or just a watch is platform-specific entity which represents // a single path registered for notifications for specific event set. Setting a watch @@ -35,6 +38,6 @@ // A watchpoint is a list of user channel and event set pairs for particular // path (watchpoint tree's node). A single watchpoint can contain multiple // different user channels registered to listen for one or more events. A single -// user channel can be registered in one or more watchpoints, recurisve and +// user channel can be registered in one or more watchpoints, recursive and // non-recursive ones as well. package notify diff --git a/vendor/github.com/zillode/notify/event.go b/vendor/github.com/zillode/notify/event.go index e045edc..c128841 100644 --- a/vendor/github.com/zillode/notify/event.go +++ b/vendor/github.com/zillode/notify/event.go @@ -73,7 +73,7 @@ func (e Event) String() string { // // https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/index.html#//apple_ref/doc/constant_group/FSEventStreamEventFlags // -// Under Linux (inotify) Sys() always returns a non-nil *syscall.InotifyEvent +// Under Linux (inotify) Sys() always returns a non-nil *unix.InotifyEvent // value, defined as: // // type InotifyEvent struct { diff --git a/vendor/github.com/zillode/notify/event_fen.go b/vendor/github.com/zillode/notify/event_fen.go index a307938..767f04f 100644 --- a/vendor/github.com/zillode/notify/event_fen.go +++ b/vendor/github.com/zillode/notify/event_fen.go @@ -20,16 +20,27 @@ const ( ) const ( - FileAccess = fileAccess - FileModified = fileModified - FileAttrib = fileAttrib - FileDelete = fileDelete - FileRenameTo = fileRenameTo + // FileAccess is an event reported when monitored file/directory was accessed. + FileAccess = fileAccess + // FileModified is an event reported when monitored file/directory was modified. + FileModified = fileModified + // FileAttrib is an event reported when monitored file/directory's ATTRIB + // was changed. + FileAttrib = fileAttrib + // FileDelete is an event reported when monitored file/directory was deleted. + FileDelete = fileDelete + // FileRenameTo to is an event reported when monitored file/directory was renamed. + FileRenameTo = fileRenameTo + // FileRenameFrom is an event reported when monitored file/directory was renamed. FileRenameFrom = fileRenameFrom - FileTrunc = fileTrunc - FileNoFollow = fileNoFollow - Unmounted = unmounted - MountedOver = mountedOver + // FileTrunc is an event reported when monitored file/directory was truncated. + FileTrunc = fileTrunc + // FileNoFollow is an flag to indicate not to follow symbolic links. + FileNoFollow = fileNoFollow + // Unmounted is an event reported when monitored filesystem was unmounted. + Unmounted = unmounted + // MountedOver is an event reported when monitored file/directory was mounted on. + MountedOver = mountedOver ) var osestr = map[Event]string{ diff --git a/vendor/github.com/zillode/notify/event_inotify.go b/vendor/github.com/zillode/notify/event_inotify.go index 82954a9..1f32bb7 100644 --- a/vendor/github.com/zillode/notify/event_inotify.go +++ b/vendor/github.com/zillode/notify/event_inotify.go @@ -6,7 +6,7 @@ package notify -import "syscall" +import "golang.org/x/sys/unix" // Platform independent event values. const ( @@ -25,18 +25,18 @@ const ( // Inotify specific masks are legal, implemented events that are guaranteed to // work with notify package on linux-based systems. const ( - InAccess = Event(syscall.IN_ACCESS) // File was accessed - InModify = Event(syscall.IN_MODIFY) // File was modified - InAttrib = Event(syscall.IN_ATTRIB) // Metadata changed - InCloseWrite = Event(syscall.IN_CLOSE_WRITE) // Writtable file was closed - InCloseNowrite = Event(syscall.IN_CLOSE_NOWRITE) // Unwrittable file closed - InOpen = Event(syscall.IN_OPEN) // File was opened - InMovedFrom = Event(syscall.IN_MOVED_FROM) // File was moved from X - InMovedTo = Event(syscall.IN_MOVED_TO) // File was moved to Y - InCreate = Event(syscall.IN_CREATE) // Subfile was created - InDelete = Event(syscall.IN_DELETE) // Subfile was deleted - InDeleteSelf = Event(syscall.IN_DELETE_SELF) // Self was deleted - InMoveSelf = Event(syscall.IN_MOVE_SELF) // Self was moved + InAccess = Event(unix.IN_ACCESS) // File was accessed + InModify = Event(unix.IN_MODIFY) // File was modified + InAttrib = Event(unix.IN_ATTRIB) // Metadata changed + InCloseWrite = Event(unix.IN_CLOSE_WRITE) // Writtable file was closed + InCloseNowrite = Event(unix.IN_CLOSE_NOWRITE) // Unwrittable file closed + InOpen = Event(unix.IN_OPEN) // File was opened + InMovedFrom = Event(unix.IN_MOVED_FROM) // File was moved from X + InMovedTo = Event(unix.IN_MOVED_TO) // File was moved to Y + InCreate = Event(unix.IN_CREATE) // Subfile was created + InDelete = Event(unix.IN_DELETE) // Subfile was deleted + InDeleteSelf = Event(unix.IN_DELETE_SELF) // Self was deleted + InMoveSelf = Event(unix.IN_MOVE_SELF) // Self was moved ) var osestr = map[Event]string{ @@ -56,15 +56,15 @@ var osestr = map[Event]string{ // Inotify behavior events are not **currently** supported by notify package. const ( - inDontFollow = Event(syscall.IN_DONT_FOLLOW) - inExclUnlink = Event(syscall.IN_EXCL_UNLINK) - inMaskAdd = Event(syscall.IN_MASK_ADD) - inOneshot = Event(syscall.IN_ONESHOT) - inOnlydir = Event(syscall.IN_ONLYDIR) + inDontFollow = Event(unix.IN_DONT_FOLLOW) + inExclUnlink = Event(unix.IN_EXCL_UNLINK) + inMaskAdd = Event(unix.IN_MASK_ADD) + inOneshot = Event(unix.IN_ONESHOT) + inOnlydir = Event(unix.IN_ONLYDIR) ) type event struct { - sys syscall.InotifyEvent + sys unix.InotifyEvent path string event Event } @@ -72,4 +72,4 @@ type event struct { func (e *event) Event() Event { return e.event } func (e *event) Path() string { return e.path } func (e *event) Sys() interface{} { return &e.sys } -func (e *event) isDir() (bool, error) { return e.sys.Mask&syscall.IN_ISDIR != 0, nil } +func (e *event) isDir() (bool, error) { return e.sys.Mask&unix.IN_ISDIR != 0, nil } diff --git a/vendor/github.com/zillode/notify/event_kqueue.go b/vendor/github.com/zillode/notify/event_kqueue.go index 82e2d8c..422ac87 100644 --- a/vendor/github.com/zillode/notify/event_kqueue.go +++ b/vendor/github.com/zillode/notify/event_kqueue.go @@ -26,7 +26,7 @@ const ( ) const ( - // NoteDelete is an even reported when the unlink() system call was called + // NoteDelete is an event reported when the unlink() system call was called // on the file referenced by the descriptor. NoteDelete = Event(syscall.NOTE_DELETE) // NoteWrite is an event reported when a write occurred on the file diff --git a/vendor/github.com/zillode/notify/event_readdcw.go b/vendor/github.com/zillode/notify/event_readdcw.go index 11ead9e..f7b82de 100644 --- a/vendor/github.com/zillode/notify/event_readdcw.go +++ b/vendor/github.com/zillode/notify/event_readdcw.go @@ -27,7 +27,11 @@ const ( dirmarker ) -// ReadDirectoryChangesW filters. +// ReadDirectoryChangesW filters +// On Windows the following events can be passed to Watch. A different set of +// events (see actions below) are received on the channel passed to Watch. +// For more information refer to +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465(v=vs.85).aspx const ( FileNotifyChangeFileName = Event(syscall.FILE_NOTIFY_CHANGE_FILE_NAME) FileNotifyChangeDirName = Event(syscall.FILE_NOTIFY_CHANGE_DIR_NAME) @@ -48,7 +52,13 @@ const ( // this flag should be declared in: http://golang.org/src/pkg/syscall/ztypes_windows.go const syscallFileNotifyChangeSecurity = 0x00000100 -// ReadDirectoryChangesW actions. +// ReadDirectoryChangesW actions +// The following events are returned on the channel passed to Watch, but cannot +// be passed to Watch itself (see filters above). You can find a table showing +// the relation between actions and filteres at +// https://github.com/rjeczalik/notify/issues/10#issuecomment-66179535 +// The msdn documentation on actions is part of +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364391(v=vs.85).aspx const ( FileActionAdded = Event(syscall.FILE_ACTION_ADDED) << 12 FileActionRemoved = Event(syscall.FILE_ACTION_REMOVED) << 12 diff --git a/vendor/github.com/zillode/notify/notify.go b/vendor/github.com/zillode/notify/notify.go index d159826..293843c 100644 --- a/vendor/github.com/zillode/notify/notify.go +++ b/vendor/github.com/zillode/notify/notify.go @@ -4,7 +4,7 @@ // BUG(rjeczalik): Notify does not collect watchpoints, when underlying watches // were removed by their os-specific watcher implementations. Instead users are -// advised to listen on persistant paths to have guarantee they receive events +// advised to listen on persistent paths to have guarantee they receive events // for the whole lifetime of their applications (to discuss see #69). // BUG(ppknap): Linux (inotify) does not support watcher behavior masks like @@ -58,7 +58,7 @@ var defaultTree = newTree() // If a directory which path was used to create recursive watch under Windows // gets deleted, the OS will not report such event. It is advised to keep in // mind this limitation while setting recursive watchpoints for your application, -// e.g. use persistant paths like %userprofile% or watch additionally parent +// e.g. use persistent paths like %userprofile% or watch additionally parent // directory of a recursive watchpoint in order to receive delete events for it. func Watch(path string, c chan<- EventInfo, events ...Event) error { return defaultTree.Watch(path, c, nil, events...) @@ -76,7 +76,7 @@ func WatchWithFilter(path string, c chan<- EventInfo, // Stop removes all watchpoints registered for c. All underlying watches are // also removed, for which c was the last channel listening for events. // -// Stop does not close c. When Stop returns, it is guranteed that c will +// Stop does not close c. When Stop returns, it is guaranteed that c will // receive no more signals. func Stop(c chan<- EventInfo) { defaultTree.Stop(c) diff --git a/vendor/github.com/zillode/notify/watcher_fen.go b/vendor/github.com/zillode/notify/watcher_fen.go index 60e9a36..dd069f2 100644 --- a/vendor/github.com/zillode/notify/watcher_fen.go +++ b/vendor/github.com/zillode/notify/watcher_fen.go @@ -45,7 +45,7 @@ type watched struct { // Stop implements trigger. func (f *fen) Stop() error { - return f.cf.port_alert(f.p) + return f.cf.portAlert(f.p) } // Close implements trigger. @@ -92,7 +92,7 @@ func (f *fen) Watched(n interface{}) (*watched, int64, error) { // init initializes FEN. func (f *fen) Init() (err error) { - f.p, err = f.cf.port_create() + f.p, err = f.cf.portCreate() return } @@ -106,12 +106,12 @@ func fi2fo(fi os.FileInfo, p string) FileObj { // Unwatch implements trigger. func (f *fen) Unwatch(w *watched) error { - return f.cf.port_dissociate(f.p, FileObj{Name: w.p}) + return f.cf.portDissociate(f.p, FileObj{Name: w.p}) } // Watch implements trigger. func (f *fen) Watch(fi os.FileInfo, w *watched, e int64) error { - return f.cf.port_associate(f.p, fi2fo(fi, w.p), int(e)) + return f.cf.portAssociate(f.p, fi2fo(fi, w.p), int(e)) } // Wait implements trigger. @@ -120,7 +120,7 @@ func (f *fen) Wait() (interface{}, error) { pe PortEvent err error ) - err = f.cf.port_get(f.p, &pe) + err = f.cf.portGet(f.p, &pe) return pe, err } @@ -130,16 +130,14 @@ func (f *fen) IsStop(n interface{}, err error) bool { } func init() { - encode = func(e Event) (o int64) { + encode = func(e Event, dir bool) (o int64) { // Create event is not supported by FEN. Instead FileModified event will // be registered. If this event will be reported on dir which is to be // monitored for Create, dir will be rescanned and Create events will // be generated and returned for new files. In case of files, // if not requested FileModified event is reported, it will be ignored. - if e&Create != 0 { - o = (o &^ int64(Create)) | int64(FileModified) - } - if e&Write != 0 { + o = int64(e &^ Create) + if (e&Create != 0 && dir) || e&Write != 0 { o = (o &^ int64(Write)) | int64(FileModified) } // Following events are 'exception events' and as such cannot be requested diff --git a/vendor/github.com/zillode/notify/watcher_fen_cgo.go b/vendor/github.com/zillode/notify/watcher_fen_cgo.go index 58ac8e8..8ec8ead 100644 --- a/vendor/github.com/zillode/notify/watcher_fen_cgo.go +++ b/vendor/github.com/zillode/notify/watcher_fen_cgo.go @@ -67,7 +67,7 @@ func unix2C(sec int64, nsec int64) (C.time_t, C.long) { return C.time_t(sec), C.long(nsec) } -func (c *cfen) port_associate(p int, fo FileObj, e int) (err error) { +func (c *cfen) portAssociate(p int, fo FileObj, e int) (err error) { cfo := C.newFo() cfo.fo_atime.tv_sec, cfo.fo_atime.tv_nsec = unix2C(fo.Atim.Unix()) cfo.fo_mtime.tv_sec, cfo.fo_mtime.tv_nsec = unix2C(fo.Mtim.Unix()) @@ -78,7 +78,7 @@ func (c *cfen) port_associate(p int, fo FileObj, e int) (err error) { return } -func (c *cfen) port_dissociate(port int, fo FileObj) (err error) { +func (c *cfen) portDissociate(port int, fo FileObj) (err error) { cfo, ok := c.p2fo[fo.Name] if !ok { return errNotWatched @@ -104,7 +104,7 @@ func cfo2fo(cfo *C.struct_file_obj) *FileObj { return &fo } -func (c *cfen) port_get(port int, pe *PortEvent) (err error) { +func (c *cfen) portGet(port int, pe *PortEvent) (err error) { cpe := C.newPe() if _, err = C.port_get(C.int(port), cpe, nil); err != nil { C.free(unsafe.Pointer(cpe)) @@ -118,12 +118,12 @@ func (c *cfen) port_get(port int, pe *PortEvent) (err error) { return } -func (c *cfen) port_create() (int, error) { +func (c *cfen) portCreate() (int, error) { p, err := C.port_create() return int(p), err } -func (c *cfen) port_alert(p int) (err error) { +func (c *cfen) portAlert(p int) (err error) { _, err = C.port_alert(C.int(p), alertSet, C.int(666), nil) return } diff --git a/vendor/github.com/zillode/notify/watcher_fsevents_cgo.go b/vendor/github.com/zillode/notify/watcher_fsevents_cgo.go index ee9631a..5be6463 100644 --- a/vendor/github.com/zillode/notify/watcher_fsevents_cgo.go +++ b/vendor/github.com/zillode/notify/watcher_fsevents_cgo.go @@ -144,7 +144,7 @@ type stream struct { } // NewStream creates a stream for given path, listening for file events and -// calling fn upon receving any. +// calling fn upon receiving any. func newStream(path string, fn streamFunc) *stream { return &stream{ path: path, diff --git a/vendor/github.com/zillode/notify/watcher_inotify.go b/vendor/github.com/zillode/notify/watcher_inotify.go index 3ceaa8f..da016f5 100644 --- a/vendor/github.com/zillode/notify/watcher_inotify.go +++ b/vendor/github.com/zillode/notify/watcher_inotify.go @@ -13,14 +13,15 @@ import ( "runtime" "sync" "sync/atomic" - "syscall" "unsafe" + + "golang.org/x/sys/unix" ) // eventBufferSize defines the size of the buffer given to read(2) function. One // should not depend on this value, since it was arbitrary chosen and may be // changed in the future. -const eventBufferSize = 64 * (syscall.SizeofInotifyEvent + syscall.PathMax + 1) +const eventBufferSize = 64 * (unix.SizeofInotifyEvent + unix.PathMax + 1) // consumersCount defines the number of consumers in producer-consumer based // implementation. Each consumer is run in a separate goroutine and has read @@ -43,7 +44,7 @@ type inotify struct { fd int32 // inotify file descriptor pipefd []int // pipe's read and write descriptors epfd int // epoll descriptor - epes []syscall.EpollEvent // epoll events + epes []unix.EpollEvent // epoll events buffer [eventBufferSize]byte // inotify event buffer wg sync.WaitGroup // wait group used to close main loop c chan<- EventInfo // event dispatcher channel @@ -56,13 +57,13 @@ func newWatcher(c chan<- EventInfo) watcher { fd: invalidDescriptor, pipefd: []int{invalidDescriptor, invalidDescriptor}, epfd: invalidDescriptor, - epes: make([]syscall.EpollEvent, 0), + epes: make([]unix.EpollEvent, 0), c: c, } runtime.SetFinalizer(i, func(i *inotify) { i.epollclose() if i.fd != invalidDescriptor { - syscall.Close(int(i.fd)) + unix.Close(int(i.fd)) } }) return i @@ -82,13 +83,13 @@ func (i *inotify) Rewatch(path string, _, newevent Event) error { // one. If called for the first time, this function initializes inotify filesystem // monitor and starts producer-consumers goroutines. func (i *inotify) watch(path string, e Event) (err error) { - if e&^(All|Event(syscall.IN_ALL_EVENTS)) != 0 { + if e&^(All|Event(unix.IN_ALL_EVENTS)) != 0 { return errors.New("notify: unknown event") } if err = i.lazyinit(); err != nil { return } - iwd, err := syscall.InotifyAddWatch(int(i.fd), path, encode(e)) + iwd, err := unix.InotifyAddWatch(int(i.fd), path, encode(e)) if err != nil { return } @@ -119,13 +120,13 @@ func (i *inotify) lazyinit() error { i.Lock() defer i.Unlock() if atomic.LoadInt32(&i.fd) == invalidDescriptor { - fd, err := syscall.InotifyInit() + fd, err := unix.InotifyInit1(unix.IN_CLOEXEC) if err != nil { return err } i.fd = int32(fd) if err = i.epollinit(); err != nil { - _, _ = i.epollclose(), syscall.Close(int(fd)) // Ignore errors. + _, _ = i.epollclose(), unix.Close(int(fd)) // Ignore errors. i.fd = invalidDescriptor return err } @@ -145,33 +146,33 @@ func (i *inotify) lazyinit() error { // with inotify event queue and the read end of the pipe are added to epoll set. // Note that `fd` member must be set before this function is called. func (i *inotify) epollinit() (err error) { - if i.epfd, err = syscall.EpollCreate1(0); err != nil { + if i.epfd, err = unix.EpollCreate1(0); err != nil { return } - if err = syscall.Pipe(i.pipefd); err != nil { + if err = unix.Pipe(i.pipefd); err != nil { return } - i.epes = []syscall.EpollEvent{ - {Events: syscall.EPOLLIN, Fd: i.fd}, - {Events: syscall.EPOLLIN, Fd: int32(i.pipefd[0])}, + i.epes = []unix.EpollEvent{ + {Events: unix.EPOLLIN, Fd: i.fd}, + {Events: unix.EPOLLIN, Fd: int32(i.pipefd[0])}, } - if err = syscall.EpollCtl(i.epfd, syscall.EPOLL_CTL_ADD, int(i.fd), &i.epes[0]); err != nil { + if err = unix.EpollCtl(i.epfd, unix.EPOLL_CTL_ADD, int(i.fd), &i.epes[0]); err != nil { return } - return syscall.EpollCtl(i.epfd, syscall.EPOLL_CTL_ADD, i.pipefd[0], &i.epes[1]) + return unix.EpollCtl(i.epfd, unix.EPOLL_CTL_ADD, i.pipefd[0], &i.epes[1]) } // epollclose closes the file descriptor created by the call to epoll_create(2) // and two file descriptors opened by pipe(2) function. func (i *inotify) epollclose() (err error) { if i.epfd != invalidDescriptor { - if err = syscall.Close(i.epfd); err == nil { + if err = unix.Close(i.epfd); err == nil { i.epfd = invalidDescriptor } } for n, fd := range i.pipefd { if fd != invalidDescriptor { - switch e := syscall.Close(fd); { + switch e := unix.Close(fd); { case e != nil && err == nil: err = e case e == nil: @@ -187,10 +188,10 @@ func (i *inotify) epollclose() (err error) { // one of the event's consumers. If pipe fd became ready, loop function closes // all file descriptors opened by lazyinit method and returns afterwards. func (i *inotify) loop(esch chan<- []*event) { - epes := make([]syscall.EpollEvent, 1) + epes := make([]unix.EpollEvent, 1) fd := atomic.LoadInt32(&i.fd) for { - switch _, err := syscall.EpollWait(i.epfd, epes, -1); err { + switch _, err := unix.EpollWait(i.epfd, epes, -1); err { case nil: switch epes[0].Fd { case fd: @@ -199,17 +200,17 @@ func (i *inotify) loop(esch chan<- []*event) { case int32(i.pipefd[0]): i.Lock() defer i.Unlock() - if err = syscall.Close(int(fd)); err != nil && err != syscall.EINTR { + if err = unix.Close(int(fd)); err != nil && err != unix.EINTR { panic("notify: close(2) error " + err.Error()) } atomic.StoreInt32(&i.fd, invalidDescriptor) - if err = i.epollclose(); err != nil && err != syscall.EINTR { + if err = i.epollclose(); err != nil && err != unix.EINTR { panic("notify: epollclose error " + err.Error()) } close(esch) return } - case syscall.EINTR: + case unix.EINTR: continue default: // We should never reach this line. panic("notify: epoll_wait(2) error " + err.Error()) @@ -220,22 +221,22 @@ func (i *inotify) loop(esch chan<- []*event) { // read reads events from an inotify file descriptor. It does not handle errors // returned from read(2) function since they are not critical to watcher logic. func (i *inotify) read() (es []*event) { - n, err := syscall.Read(int(i.fd), i.buffer[:]) - if err != nil || n < syscall.SizeofInotifyEvent { + n, err := unix.Read(int(i.fd), i.buffer[:]) + if err != nil || n < unix.SizeofInotifyEvent { return } - var sys *syscall.InotifyEvent - nmin := n - syscall.SizeofInotifyEvent + var sys *unix.InotifyEvent + nmin := n - unix.SizeofInotifyEvent for pos, path := 0, ""; pos <= nmin; { - sys = (*syscall.InotifyEvent)(unsafe.Pointer(&i.buffer[pos])) - pos += syscall.SizeofInotifyEvent + sys = (*unix.InotifyEvent)(unsafe.Pointer(&i.buffer[pos])) + pos += unix.SizeofInotifyEvent if path = ""; sys.Len > 0 { endpos := pos + int(sys.Len) path = string(bytes.TrimRight(i.buffer[pos:endpos], "\x00")) pos = endpos } es = append(es, &event{ - sys: syscall.InotifyEvent{ + sys: unix.InotifyEvent{ Wd: sys.Wd, Mask: sys.Mask, Cookie: sys.Cookie, @@ -268,7 +269,7 @@ func (i *inotify) transform(es []*event) []*event { var multi []*event i.RLock() for idx, e := range es { - if e.sys.Mask&(syscall.IN_IGNORED|syscall.IN_Q_OVERFLOW) != 0 { + if e.sys.Mask&(unix.IN_IGNORED|unix.IN_Q_OVERFLOW) != 0 { es[idx] = nil continue } @@ -317,7 +318,7 @@ func encode(e Event) uint32 { // can be nil when the event should not be passed on. func decode(mask Event, e *event) (syse *event) { if sysmask := uint32(mask) & e.sys.Mask; sysmask != 0 { - syse = &event{sys: syscall.InotifyEvent{ + syse = &event{sys: unix.InotifyEvent{ Wd: e.sys.Wd, Mask: e.sys.Mask, Cookie: e.sys.Cookie, @@ -357,7 +358,7 @@ func (i *inotify) Unwatch(path string) (err error) { return errors.New("notify: path " + path + " is already watched") } fd := atomic.LoadInt32(&i.fd) - if _, err = syscall.InotifyRmWatch(int(fd), uint32(iwd)); err != nil { + if _, err = unix.InotifyRmWatch(int(fd), uint32(iwd)); err != nil { return } i.Lock() @@ -377,12 +378,12 @@ func (i *inotify) Close() (err error) { return nil } for iwd := range i.m { - if _, e := syscall.InotifyRmWatch(int(i.fd), uint32(iwd)); e != nil && err == nil { + if _, e := unix.InotifyRmWatch(int(i.fd), uint32(iwd)); e != nil && err == nil { err = e } delete(i.m, iwd) } - switch _, errwrite := syscall.Write(i.pipefd[1], []byte{0x00}); { + switch _, errwrite := unix.Write(i.pipefd[1], []byte{0x00}); { case errwrite != nil && err == nil: err = errwrite fallthrough diff --git a/vendor/github.com/zillode/notify/watcher_kqueue.go b/vendor/github.com/zillode/notify/watcher_kqueue.go index d5f7788..6d500b7 100644 --- a/vendor/github.com/zillode/notify/watcher_kqueue.go +++ b/vendor/github.com/zillode/notify/watcher_kqueue.go @@ -157,14 +157,15 @@ func (k *kq) IsStop(n interface{}, err error) bool { } func init() { - encode = func(e Event) (o int64) { + encode = func(e Event, dir bool) (o int64) { // Create event is not supported by kqueue. Instead NoteWrite event will - // be registered. If this event will be reported on dir which is to be - // monitored for Create, dir will be rescanned and Create events will - // be generated and returned for new files. In case of files, - // if not requested NoteRename event is reported, it will be ignored. + // be registered for a directory. If this event will be reported on dir + // which is to be monitored for Create, dir will be rescanned + // and Create events will be generated and returned for new files. + // In case of files, if not requested NoteRename event is reported, + // it will be ignored. o = int64(e &^ Create) - if e&Write != 0 { + if (e&Create != 0 && dir) || e&Write != 0 { o = (o &^ int64(Write)) | int64(NoteWrite) } if e&Rename != 0 { diff --git a/vendor/github.com/zillode/notify/watcher_trigger.go b/vendor/github.com/zillode/notify/watcher_trigger.go index f25a6fc..d079d59 100644 --- a/vendor/github.com/zillode/notify/watcher_trigger.go +++ b/vendor/github.com/zillode/notify/watcher_trigger.go @@ -58,7 +58,7 @@ type trigger interface { // encode Event to native representation. Implementation is to be provided by // platform specific implementation. -var encode func(Event) int64 +var encode func(Event, bool) int64 var ( // nat2not matches native events to notify's ones. To be initialized by @@ -145,13 +145,7 @@ func (t *trg) singlewatch(p string, e Event, direct mode, fi os.FileInfo) (err e w.eDir |= e w.eNonDir |= e } - var ee int64 - // Native Write event is added to wait for Create events (Write event on - // directory triggers it's rescan). - if e&Create != 0 && fi.IsDir() { - ee = int64(not2nat[Write]) - } - if err = t.t.Watch(fi, w, encode(w.eDir|w.eNonDir)|ee); err != nil { + if err = t.t.Watch(fi, w, encode(w.eDir|w.eNonDir, fi.IsDir())); err != nil { return } if !ok { @@ -290,7 +284,7 @@ func (t *trg) dir(w *watched, n interface{}, e, ge Event) (evn []event) { // However events for rename must be generated for all monitored files // inside of moved directory, because native impl does not report it independently // for each file descriptor being moved in result of move action on - // parent dirLiczba dostępnych dni urlopowych: 0ectory. + // parent directory. if (ge & (not2nat[Rename] | not2nat[Remove])) != 0 { // Write is reported also for Remove on directory. Because of that // we have to filter it out explicitly. @@ -399,7 +393,7 @@ func (t *trg) monitor() { } } -// process event returned by port_get call. +// process event returned by native call. func (t *trg) process(n interface{}) (evn []event) { t.Lock() w, ge, err := t.t.Watched(n) @@ -414,13 +408,13 @@ func (t *trg) process(n interface{}) (evn []event) { switch fi, err := os.Stat(w.p); { case err != nil: default: - if err = t.t.Watch(fi, w, (encode(w.eDir | w.eNonDir))); err != nil { + if err = t.t.Watch(fi, w, encode(w.eDir|w.eNonDir, fi.IsDir())); err != nil { dbgprintf("trg: %q is no longer watched: %q", w.p, err) t.t.Del(w) } } } - if e == Event(0) { + if e == Event(0) && (!w.fi.IsDir() || (ge&int64(not2nat[Write])) == 0) { t.Unlock() return } diff --git a/vendor/github.com/zillode/notify/watchpoint_other.go b/vendor/github.com/zillode/notify/watchpoint_other.go index 881631c..9bb381d 100644 --- a/vendor/github.com/zillode/notify/watchpoint_other.go +++ b/vendor/github.com/zillode/notify/watchpoint_other.go @@ -15,7 +15,7 @@ func eventmask(ei EventInfo, extra Event) Event { // matches reports a match only when: // // - for user events, when event is present in the given set -// - for internal events, when additionaly both event and set have omit bit set +// - for internal events, when additionally both event and set have omit bit set // // Internal events must not be sent to user channels and vice versa. func matches(set, event Event) bool { diff --git a/vendor/manifest b/vendor/manifest index 2fbbb6e..606764d 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -58,7 +58,7 @@ "importpath": "github.com/zillode/notify", "repository": "https://github.com/zillode/notify", "vcs": "git", - "revision": "df33c1a773b462f936a149c36696c018c047eaa9", + "revision": "d1bed6cba07938d6ca422fa88e3526f6a31ed996", "branch": "master", "notests": true }