From 09db31c7264e370fbbafab81a0c30b1ac1b80514 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 18 Dec 2016 15:50:34 -0500 Subject: Make inotify.Inotify more robust; remove inotify.Watcher. BREAKING CHANGE. --- inotify/syscall.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'inotify/syscall.go') diff --git a/inotify/syscall.go b/inotify/syscall.go index d1b5140..0a0c2f0 100644 --- a/inotify/syscall.go +++ b/inotify/syscall.go @@ -1,4 +1,4 @@ -// Copyright 2015 Luke Shumaker . +// Copyright 2015-2016 Luke Shumaker . // // This is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as @@ -29,35 +29,35 @@ func newPathError(op string, path string, err error) error { } // Create and initialize inotify instance. -func inotify_init() (file, error) { - fd, errno := syscall.InotifyInit() - return file(fd), os.NewSyscallError("inotify_init", errno) +func sys_inotify_init() (inFd, error) { + fd, err := syscall.InotifyInit() + return inFd(fd), os.NewSyscallError("inotify_init", err) } // Create and initialize inotify instance. -func inotify_init1(flags int) (file, error) { - fd, errno := syscall.InotifyInit1(flags) - return file(fd), os.NewSyscallError("inotify_init1", errno) +func sys_inotify_init1(flags int) (inFd, error) { + fd, err := syscall.InotifyInit1(flags) + return inFd(fd), os.NewSyscallError("inotify_init1", err) } // Add watch of object NAME to inotify instance FD. Notify about // events specified by MASK. -func inotify_add_watch(fd file, name string, mask Mask) (Wd, error) { - wd, errno := syscall.InotifyAddWatch(int(fd), name, uint32(mask)) - return Wd(wd), newPathError("inotify_add_watch", name, errno) +func sys_inotify_add_watch(fd inFd, name string, mask Mask) (Wd, error) { + wd, err := syscall.InotifyAddWatch(int(fd), name, uint32(mask)) + return Wd(wd), newPathError("inotify_add_watch", name, err) } // Remove the watch specified by WD from the inotify instance FD. -func inotify_rm_watch(fd file, wd Wd) error { - success, errno := syscall.InotifyRmWatch(int(fd), uint32(wd)) +func sys_inotify_rm_watch(fd inFd, wd Wd) error { + success, err := syscall.InotifyRmWatch(int(fd), uint32(wd)) switch success { case -1: - if errno == nil { + if err == nil { panic("should never happen") } - os.NewSyscallError("inotify_rm_watch", errno) + os.NewSyscallError("inotify_rm_watch", err) case 0: - if errno != nil { + if err != nil { panic("should never happen") } return nil @@ -65,11 +65,11 @@ func inotify_rm_watch(fd file, wd Wd) error { panic("should never happen") } -func sysclose(fd file) error { +func sys_close(fd inFd) error { return os.NewSyscallError("close", syscall.Close(int(fd))) } -func sysread(fd file, p []byte) (int, error) { +func sys_read(fd inFd, p []byte) (int, error) { n, err := syscall.Read(int(fd), p) return n, os.NewSyscallError("read", err) } -- cgit v1.2.3