1 module tango.sys.linux.inotify;
2 
3 version (linux)
4 {
5     // From <sys/inotify.h>: support for the Linux inotify_* system calls
6     extern (C)
7     {
8         struct inotify_event
9         {
10             int wd;         /* Watch descriptor.  */
11             uint mask;      /* Watch mask.  */
12             uint cookie;    /* Cookie to synchronize two events.  */
13             uint len;       /* Length (including NULs) of name.  */
14             /* char name[]; /* Name.  */
15         }
16 
17         enum: uint
18         {
19             /* Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH.  */
20             IN_ACCESS           = 0x00000001,   /* File was accessed.  */
21             IN_MODIFY           = 0x00000002,   /* File was modified.  */
22             IN_ATTRIB           = 0x00000004,   /* Metadata changed.  */
23             IN_CLOSE_WRITE      = 0x00000008,   /* Writtable file was closed.  */
24             IN_CLOSE_NOWRITE    = 0x00000010,   /* Unwrittable file was closed.  */
25             IN_CLOSE            = 0x00000018,   /* Close. */
26             IN_OPEN             = 0x00000020,   /* File was opened.  */
27             IN_MOVED_FROM       = 0x00000040,   /* File was moved from X.  */
28             IN_MOVED_TO         = 0x00000080,   /* File was moved to Y.  */
29             IN_MOVE             = 0x000000c0,   /* Moves.  */
30             IN_CREATE           = 0x00000100,   /* Subfile was created.  */
31             IN_DELETE           = 0x00000200,   /* Subfile was deleted.  */
32             IN_DELETE_SELF      = 0x00000400,   /* Self was deleted.  */
33             IN_MOVE_SELF        = 0x00000800,   /* Self was moved.  */
34             
35             /* Events sent by the kernel.  */
36             IN_UMOUNT           = 0x00002000,   /* Backing fs was unmounted.  */
37             IN_Q_OVERFLOW       = 0x00004000,   /* Event queued overflowed  */
38             IN_IGNORED          = 0x00008000,   /* File was ignored  */
39             
40             /* Special flags.  */
41             IN_ONLYDIR          = 0x01000000,   /* Only watch the path if it is a directory.  */
42             IN_DONT_FOLLOW      = 0x02000000,   /* Do not follow a sym link.  */
43             IN_MASK_ADD         = 0x20000000,   /* Add to the mask of an already existing watch.  */
44             IN_ISDIR            = 0x40000000,   /* Event occurred against dir.  */
45             IN_ONESHOT          = 0x80000000,   /* Only send event once.  */
46             
47             IN_ALL_EVENTS       = 0x00000fff,   /* All events which a program can wait on.  */
48         }
49         
50         /* Create and initialize inotify instance.  */
51         int inotify_init ();
52 
53         /* Add watch of object NAME to inotify instance FD.  Notify about events specified by MASK.  */
54         int inotify_add_watch (int fd, char* name, uint mask);
55 
56         /* Remove the watch specified by WD from the inotify instance FD.  */
57         int inotify_rm_watch (int fd, uint wd);
58     }
59 }