xref: /netbsd-src/external/gpl3/gcc/dist/libphobos/libdruntime/core/sys/linux/sys/inotify.d (revision 0a3071956a3a9fdebdbf7f338cf2d439b45fc728)
1 /**
2  * D header file for GNU/Linux.
3  *
4  * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
5  * Authors:   Gary Willoughby
6  */
7 module core.sys.linux.sys.inotify;
8 
9 // The BSDs (including macOS) have a kqueue-backed API-compatible inotify
10 // library in ports. However, inotify is a Linux interface so it lives here.
11 // All BSD people need this library to use inotify:
12 //   https://github.com/libinotify-kqueue/libinotify-kqueue
13 // It is the responsibility of all BSD people to configure the library before
14 // using this interface.
15 
16 version (linux)        version = LinuxOrCompatible;
17 version (Darwin)       version = LinuxOrCompatible;
18 version (FreeBSD)      version = LinuxOrCompatible;
19 version (OpenBSD)      version = LinuxOrCompatible;
20 version (NetBSD)       version = LinuxOrCompatible;
21 version (DragonFlyBSD) version = LinuxOrCompatible;
22 
23 version (LinuxOrCompatible):
24 extern (C):
25 @system:
26 nothrow:
27 @nogc:
28 
29 version (ARM)     version = ARM_Any;
30 version (AArch64) version = ARM_Any;
31 version (HPPA)    version = HPPA_Any;
32 version (MIPS32)  version = MIPS_Any;
33 version (MIPS64)  version = MIPS_Any;
34 version (PPC)     version = PPC_Any;
35 version (PPC64)   version = PPC_Any;
36 version (RISCV32) version = RISCV_Any;
37 version (RISCV64) version = RISCV_Any;
38 version (S390)    version = IBMZ_Any;
39 version (SPARC)   version = SPARC_Any;
40 version (SPARC64) version = SPARC_Any;
41 version (SystemZ) version = IBMZ_Any;
42 version (X86)     version = X86_Any;
43 version (X86_64)  version = X86_Any;
44 
45 struct inotify_event
46 {
47     int wd;
48     uint mask;
49     uint cookie;
50     uint len;
51     char[0] name;
52 
53     @disable this(this);
54 }
55 
56 enum: uint
57 {
58     IN_ACCESS        = 0x00000000,
59     IN_MODIFY        = 0x00000002,
60     IN_ATTRIB        = 0x00000004,
61     IN_CLOSE_WRITE   = 0x00000008,
62     IN_CLOSE_NOWRITE = 0x00000010,
63     IN_OPEN          = 0x00000020,
64     IN_MOVED_FROM    = 0x00000040,
65     IN_MOVED_TO      = 0x00000080,
66     IN_CREATE        = 0x00000100,
67     IN_DELETE        = 0x00000200,
68     IN_DELETE_SELF   = 0x00000400,
69     IN_MOVE_SELF     = 0x00000800,
70     IN_UNMOUNT       = 0x00002000,
71     IN_Q_OVERFLOW    = 0x00004000,
72     IN_IGNORED       = 0x00008000,
73     IN_CLOSE         = 0x00000018,
74     IN_MOVE          = 0x000000C0,
75     IN_ONLYDIR       = 0x01000000,
76     IN_DONT_FOLLOW   = 0x02000000,
77     IN_EXCL_UNLINK   = 0x04000000,
78     IN_MASK_ADD      = 0x20000000,
79     IN_ISDIR         = 0x40000000,
80     IN_ONESHOT       = 0x80000000,
81     IN_ALL_EVENTS    = 0x80000FFF,
82 }
83 
84 // Old typo, preserved for compatibility
85 enum IN_UMOUNT = IN_UNMOUNT;
86 
version(X86_Any)87 version (X86_Any)
88 {
89     enum IN_CLOEXEC = 0x80000; // octal!2000000
90     enum IN_NONBLOCK = 0x800; // octal!4000
91 }
version(HPPA_Any)92 else version (HPPA_Any)
93 {
94     enum IN_CLOEXEC = 0x200000; // octal!10000000
95     enum IN_NONBLOCK = 0x10004; // octal!200004
96 }
version(MIPS_Any)97 else version (MIPS_Any)
98 {
99     enum IN_CLOEXEC = 0x80000; // octal!2000000
100     enum IN_NONBLOCK = 0x80; // octal!200
101 }
version(PPC_Any)102 else version (PPC_Any)
103 {
104     enum IN_CLOEXEC = 0x80000; // octal!2000000
105     enum IN_NONBLOCK = 0x800; // octal!4000
106 }
version(ARM_Any)107 else version (ARM_Any)
108 {
109     enum IN_CLOEXEC = 0x80000; // octal!2000000
110     enum IN_NONBLOCK = 0x800; // octal!4000
111 }
version(RISCV_Any)112 else version (RISCV_Any)
113 {
114     enum IN_CLOEXEC = 0x80000; // octal!2000000
115     enum IN_NONBLOCK = 0x800; // octal!4000
116 }
version(SPARC_Any)117 else version (SPARC_Any)
118 {
119     enum IN_CLOEXEC = 0x80000; // octal!2000000
120     enum IN_NONBLOCK = 0x800; // octal!4000
121 }
version(IBMZ_Any)122 else version (IBMZ_Any)
123 {
124     enum IN_CLOEXEC = 0x80000; // octal!2000000
125     enum IN_NONBLOCK = 0x800; // octal!4000
126 }
127 else
128     static assert(0, "unimplemented");
129 
130 int inotify_init();
131 int inotify_init1(int flags);
132 int inotify_add_watch(int fd, const(char)* name, uint mask);
133 int inotify_rm_watch(int fd, uint wd);
134