]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: add inotify on Linux
authorBalazs Lecz <leczb@google.com>
Mon, 27 Sep 2010 15:44:26 +0000 (11:44 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 27 Sep 2010 15:44:26 +0000 (11:44 -0400)
R=rsc
CC=golang-dev
https://golang.org/cl/2241045

12 files changed:
src/pkg/syscall/mkerrors.sh
src/pkg/syscall/syscall_linux.go
src/pkg/syscall/types_linux.c
src/pkg/syscall/zerrors_linux_386.go
src/pkg/syscall/zerrors_linux_amd64.go
src/pkg/syscall/zerrors_linux_arm.go
src/pkg/syscall/zsyscall_linux_386.go
src/pkg/syscall/zsyscall_linux_amd64.go
src/pkg/syscall/zsyscall_linux_arm.go
src/pkg/syscall/ztypes_linux_386.go
src/pkg/syscall/ztypes_linux_amd64.go
src/pkg/syscall/ztypes_linux_arm.go

index b3ed0f627e741edfd91ec4ba0eb4f1fc4f7f20c7..48274b9808215a8e4cb811b8087448736f4f34ea 100755 (executable)
@@ -23,6 +23,7 @@ includes_Linux='
 
 #include <sys/types.h>
 #include <sys/epoll.h>
+#include <sys/inotify.h>
 #include <linux/ptrace.h>
 #include <linux/wait.h>
 '
@@ -84,6 +85,7 @@ done
 
                $2 ~ /^E[A-Z0-9_]+$/ ||
                $2 ~ /^SIG[^_]/ ||
+               $2 ~ /^IN_/ ||
                $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|EVFILT|EV|SHUT|PROT|MAP)_/ ||
                $2 == "SOMAXCONN" ||
                $2 == "NAME_MAX" ||
index 8ee9bebae8bb6069cb4a909ee2a1b5b9b4d11192..19c9cc3d90fd34f461556426099a26b4c5157940 100644 (file)
@@ -593,6 +593,10 @@ func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0)
 //sys  Getrlimit(resource int, rlim *Rlimit) (errno int)
 //sys  Getrusage(who int, rusage *Rusage) (errno int)
 //sys  Gettid() (tid int)
+//sys   InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, errno int)
+//sys   InotifyInit() (fd int, errno int)
+//sys   InotifyInit1(flags int) (fd int, errno int)
+//sys   InotifyRmWatch(fd int, watchdesc uint32) (success int, errno int)
 //sys  Kill(pid int, sig int) (errno int)
 //sys  Klogctl(typ int, buf []byte) (n int, errno int) = SYS_SYSLOG
 //sys  Link(oldpath string, newpath string) (errno int)
@@ -675,9 +679,6 @@ func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0)
 // Getpmsg
 // Getpriority
 // Getxattr
-// InotifyAddWatch
-// InotifyInit
-// InotifyRmWatch
 // IoCancel
 // IoDestroy
 // IoGetevents
index 123da34c5a945507010fe356b24f4ed697f21bec..d0cd4a1849199ce027677f25df04a8f40939c9c7 100644 (file)
@@ -18,6 +18,7 @@ Input to godefs.  See also mkerrors.sh and mkall.sh
 #include <signal.h>
 #include <stdio.h>
 #include <sys/epoll.h>
+#include <sys/inotify.h>
 #include <sys/mman.h>
 #include <sys/mount.h>
 #include <sys/param.h>
@@ -119,6 +120,14 @@ enum {
 };
 
 
+// Inotify
+typedef struct inotify_event $InotifyEvent;
+
+enum {
+        $SizeofInotifyEvent = sizeof(struct inotify_event)
+};
+
+
 // Ptrace
 
 // Register structures
index ff3c12effb8e091dc65b7934f591d56067530ee8..b4bb19ba700713047c356967a291c3e4b58e60d3 100644 (file)
@@ -232,6 +232,43 @@ const (
        F_ULOCK                          = 0
        F_UNLCK                          = 0x2
        F_WRLCK                          = 0x1
+       IN_ACCESS                        = 0x1
+       IN_ALL_EVENTS                    = 0xfff
+       IN_ATTRIB                        = 0x4
+       IN_CLASSA_HOST                   = 0xffffff
+       IN_CLASSA_MAX                    = 0x80
+       IN_CLASSA_NET                    = 0xff000000
+       IN_CLASSA_NSHIFT                 = 0x18
+       IN_CLASSB_HOST                   = 0xffff
+       IN_CLASSB_MAX                    = 0x10000
+       IN_CLASSB_NET                    = 0xffff0000
+       IN_CLASSB_NSHIFT                 = 0x10
+       IN_CLASSC_HOST                   = 0xff
+       IN_CLASSC_NET                    = 0xffffff00
+       IN_CLASSC_NSHIFT                 = 0x8
+       IN_CLOEXEC                       = 0x80000
+       IN_CLOSE                         = 0x18
+       IN_CLOSE_NOWRITE                 = 0x10
+       IN_CLOSE_WRITE                   = 0x8
+       IN_CREATE                        = 0x100
+       IN_DELETE                        = 0x200
+       IN_DELETE_SELF                   = 0x400
+       IN_DONT_FOLLOW                   = 0x2000000
+       IN_IGNORED                       = 0x8000
+       IN_ISDIR                         = 0x40000000
+       IN_LOOPBACKNET                   = 0x7f
+       IN_MASK_ADD                      = 0x20000000
+       IN_MODIFY                        = 0x2
+       IN_MOVE                          = 0xc0
+       IN_MOVED_FROM                    = 0x40
+       IN_MOVED_TO                      = 0x80
+       IN_MOVE_SELF                     = 0x800
+       IN_NONBLOCK                      = 0x800
+       IN_ONESHOT                       = 0x80000000
+       IN_ONLYDIR                       = 0x1000000
+       IN_OPEN                          = 0x20
+       IN_Q_OVERFLOW                    = 0x4000
+       IN_UNMOUNT                       = 0x2000
        IPPROTO_AH                       = 0x33
        IPPROTO_COMP                     = 0x6c
        IPPROTO_DCCP                     = 0x21
index f256090140dbaff5faed5a13fbafd90f281bc70b..1893c51bffebd61e3da2b18774f268b64f70925f 100644 (file)
@@ -232,6 +232,43 @@ const (
        F_ULOCK                          = 0
        F_UNLCK                          = 0x2
        F_WRLCK                          = 0x1
+       IN_ACCESS                        = 0x1
+       IN_ALL_EVENTS                    = 0xfff
+       IN_ATTRIB                        = 0x4
+       IN_CLASSA_HOST                   = 0xffffff
+       IN_CLASSA_MAX                    = 0x80
+       IN_CLASSA_NET                    = 0xff000000
+       IN_CLASSA_NSHIFT                 = 0x18
+       IN_CLASSB_HOST                   = 0xffff
+       IN_CLASSB_MAX                    = 0x10000
+       IN_CLASSB_NET                    = 0xffff0000
+       IN_CLASSB_NSHIFT                 = 0x10
+       IN_CLASSC_HOST                   = 0xff
+       IN_CLASSC_NET                    = 0xffffff00
+       IN_CLASSC_NSHIFT                 = 0x8
+       IN_CLOEXEC                       = 0x80000
+       IN_CLOSE                         = 0x18
+       IN_CLOSE_NOWRITE                 = 0x10
+       IN_CLOSE_WRITE                   = 0x8
+       IN_CREATE                        = 0x100
+       IN_DELETE                        = 0x200
+       IN_DELETE_SELF                   = 0x400
+       IN_DONT_FOLLOW                   = 0x2000000
+       IN_IGNORED                       = 0x8000
+       IN_ISDIR                         = 0x40000000
+       IN_LOOPBACKNET                   = 0x7f
+       IN_MASK_ADD                      = 0x20000000
+       IN_MODIFY                        = 0x2
+       IN_MOVE                          = 0xc0
+       IN_MOVED_FROM                    = 0x40
+       IN_MOVED_TO                      = 0x80
+       IN_MOVE_SELF                     = 0x800
+       IN_NONBLOCK                      = 0x800
+       IN_ONESHOT                       = 0x80000000
+       IN_ONLYDIR                       = 0x1000000
+       IN_OPEN                          = 0x20
+       IN_Q_OVERFLOW                    = 0x4000
+       IN_UNMOUNT                       = 0x2000
        IPPROTO_AH                       = 0x33
        IPPROTO_COMP                     = 0x6c
        IPPROTO_DCCP                     = 0x21
index 3557000488b52be424ef973d0ef74f05643b7b9e..1f8b1830b387238e0311a49473ab2a7d43cdf1a9 100644 (file)
@@ -226,6 +226,43 @@ const (
        F_ULOCK                          = 0
        F_UNLCK                          = 0x2
        F_WRLCK                          = 0x1
+       IN_ACCESS                        = 0x1
+       IN_ALL_EVENTS                    = 0xfff
+       IN_ATTRIB                        = 0x4
+       IN_CLASSA_HOST                   = 0xffffff
+       IN_CLASSA_MAX                    = 0x80
+       IN_CLASSA_NET                    = 0xff000000
+       IN_CLASSA_NSHIFT                 = 0x18
+       IN_CLASSB_HOST                   = 0xffff
+       IN_CLASSB_MAX                    = 0x10000
+       IN_CLASSB_NET                    = 0xffff0000
+       IN_CLASSB_NSHIFT                 = 0x10
+       IN_CLASSC_HOST                   = 0xff
+       IN_CLASSC_NET                    = 0xffffff00
+       IN_CLASSC_NSHIFT                 = 0x8
+       IN_CLOEXEC                       = 0x80000
+       IN_CLOSE                         = 0x18
+       IN_CLOSE_NOWRITE                 = 0x10
+       IN_CLOSE_WRITE                   = 0x8
+       IN_CREATE                        = 0x100
+       IN_DELETE                        = 0x200
+       IN_DELETE_SELF                   = 0x400
+       IN_DONT_FOLLOW                   = 0x2000000
+       IN_IGNORED                       = 0x8000
+       IN_ISDIR                         = 0x40000000
+       IN_LOOPBACKNET                   = 0x7f
+       IN_MASK_ADD                      = 0x20000000
+       IN_MODIFY                        = 0x2
+       IN_MOVE                          = 0xc0
+       IN_MOVED_FROM                    = 0x40
+       IN_MOVED_TO                      = 0x80
+       IN_MOVE_SELF                     = 0x800
+       IN_NONBLOCK                      = 0x800
+       IN_ONESHOT                       = 0x80000000
+       IN_ONLYDIR                       = 0x1000000
+       IN_OPEN                          = 0x20
+       IN_Q_OVERFLOW                    = 0x4000
+       IN_UNMOUNT                       = 0x2000
        IPPROTO_AH                       = 0x33
        IPPROTO_COMP                     = 0x6c
        IPPROTO_DCCP                     = 0x21
index 6036dc92fa6658c3c080f8c6e57b1e1a2b3141c9..b752177ad65fcc1aea8a6c1ba7576776cb0509e4 100644 (file)
@@ -351,6 +351,42 @@ func Gettid() (tid int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(StringBytePtr(pathname))), uintptr(mask))
+       watchdesc = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func InotifyInit() (fd int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_INIT, 0, 0, 0)
+       fd = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func InotifyInit1(flags int) (fd int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
+       fd = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func InotifyRmWatch(fd int, watchdesc uint32) (success int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
+       success = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Kill(pid int, sig int) (errno int) {
        _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
        errno = int(e1)
index fa2be094550c3f2abfebae4daf0881c2889b32e6..ee0505122f3de2e655438d1e8a57cb855f70f289 100644 (file)
@@ -351,6 +351,42 @@ func Gettid() (tid int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(StringBytePtr(pathname))), uintptr(mask))
+       watchdesc = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func InotifyInit() (fd int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_INIT, 0, 0, 0)
+       fd = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func InotifyInit1(flags int) (fd int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
+       fd = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func InotifyRmWatch(fd int, watchdesc uint32) (success int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
+       success = int(r0)
+       errno = int(e1)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Kill(pid int, sig int) (errno int) {
        _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
        errno = int(e1)
index dc23c4468a9552f2d6a6e9ad335a9ef0853524f3..91bbbcc93e70b055630738474f423a3270174560 100644 (file)
@@ -269,6 +269,34 @@ func Gettid() (tid int) {
        return
 }
 
+func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(StringBytePtr(pathname))), uintptr(mask))
+       watchdesc = int(r0)
+       errno = int(e1)
+       return
+}
+
+func InotifyInit() (fd int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_INIT, 0, 0, 0)
+       fd = int(r0)
+       errno = int(e1)
+       return
+}
+
+func InotifyInit1(flags int) (fd int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
+       fd = int(r0)
+       errno = int(e1)
+       return
+}
+
+func InotifyRmWatch(fd int, watchdesc uint32) (success int, errno int) {
+       r0, _, e1 := Syscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
+       success = int(r0)
+       errno = int(e1)
+       return
+}
+
 func Kill(pid int, sig int) (errno int) {
        _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
        errno = int(e1)
index 2afabb13ff15aeb746d89e995bcd11625c240737..53751529b9e39a0c62c066ec7a86bd510818bd11 100644 (file)
@@ -19,6 +19,7 @@ const (
        SizeofLinger        = 0x8
        SizeofMsghdr        = 0x1c
        SizeofCmsghdr       = 0xc
+       SizeofInotifyEvent  = 0x10
 )
 
 // Types
@@ -217,6 +218,13 @@ type Cmsghdr struct {
        Type  int32
 }
 
+type InotifyEvent struct {
+       Wd     int32
+       Mask   uint32
+       Cookie uint32
+       Len    uint32
+}
+
 type PtraceRegs struct {
        Ebx      int32
        Ecx      int32
index 2ca047fd73effb5c9567af0a2afd21f5d044b4e3..6a19a88a8085ad2999abe8c9fc9f8b7a4446c10f 100644 (file)
@@ -19,6 +19,7 @@ const (
        SizeofLinger        = 0x8
        SizeofMsghdr        = 0x38
        SizeofCmsghdr       = 0x10
+       SizeofInotifyEvent  = 0x10
 )
 
 // Types
@@ -219,6 +220,13 @@ type Cmsghdr struct {
        Type  int32
 }
 
+type InotifyEvent struct {
+       Wd     int32
+       Mask   uint32
+       Cookie uint32
+       Len    uint32
+}
+
 type PtraceRegs struct {
        R15      uint64
        R14      uint64
index 17ed7cad5a619a9a158e5c812ebfcbce203e24ec..df752b8b1937c02d3bfaf4a612f314ac070ba531 100644 (file)
@@ -19,6 +19,7 @@ const (
        SizeofLinger        = 0x8
        SizeofMsghdr        = 0x1c
        SizeofCmsghdr       = 0xc
+       SizeofInotifyEvent  = 0x10
 )
 
 // Types
@@ -219,6 +220,13 @@ type Cmsghdr struct {
        Type  int32
 }
 
+type InotifyEvent struct {
+       Wd     int32
+       Mask   uint32
+       Cookie uint32
+       Len    uint32
+}
+
 type PtraceRegs struct{}
 
 type FdSet struct {