]> git.pld-linux.org Git - packages/cronie.git/blame - inotify-nosys.patch
- update url
[packages/cronie.git] / inotify-nosys.patch
CommitLineData
960d0979
AM
1--- cronie-1.4.1/src/cron.c~ 2009-06-01 10:46:08.000000000 +0300
2+++ cronie-1.4.1/src/cron.c 2009-08-13 13:32:40.909067818 +0300
3@@ -41,7 +41,11 @@
4 #include <unistd.h>
f440f0d0
ER
5
6 #ifdef WITH_INOTIFY
7+#ifdef SYS_INOTIFY_H_EXISTS_AND_WORKS
960d0979 8 # include <sys/inotify.h>
f440f0d0
ER
9+#else
10+#include "inotify-nosys.h"
11+#endif
12 #endif
13
960d0979 14 #ifdef HAVE_SYS_FCNTL_H
f440f0d0
ER
15--- cronie-1.4.1/configure.ac~ 2009-08-13 13:56:08.000000000 +0300
16+++ cronie-1.4.1/configure.ac 2009-08-13 13:56:11.295316050 +0300
17@@ -27,7 +27,6 @@
18 stddef.h \
19 stdint.h \
20 sys/audit.h \
21- sys/inotify.h \
22 sys/stat.h \
23 sys/stream.h \
24 sys/stropts.h \
25@@ -106,9 +105,16 @@
26 AC_ARG_WITH(inotify,
27 [AS_HELP_STRING([--with-inotify], [ Enable inotify support])],
28 [ if test "x$withval" != "xno" ; then
29+ AC_MSG_CHECKING([whether sys/inotify.h actually works])
30+ AC_RUN_IFELSE(
31+ AC_LANG_PROGRAM([[#include <sys/inotify.h>]],
32+ [[return (-1 == inotify_init());]]
33+ ),
34+ [AC_MSG_RESULT([yup]); AC_DEFINE([SYS_INOTIFY_H_EXISTS_AND_WORKS],[1],[sys/inotify.h exists and works correctly])],
35+ [AC_MSG_RESULT([nope, using own inotify headers])]
36+ )
37+
38 AC_DEFINE(WITH_INOTIFY,1,[Define if you want inotify support.])
39- AC_CHECK_HEADER([sys/inotify.h], , AC_MSG_ERROR(Inotify support requires sys/inotify.h header))
40- AC_CHECK_FUNCS(inotify_init inotify_add_watch)
41 fi
42 ]
43 )
44--- /dev/null 2008-11-04 20:33:38.146691408 +0200
45+++ cronie-1.4.1/src/inotify-nosys.h 2007-12-30 10:50:22.000000000 +0200
46@@ -0,0 +1,167 @@
47+/*
48+ * This header is used if <sys/inotify.h> cannot be found.
49+ *
50+ * Inode based directory notification for Linux
51+ *
52+ * Copyright (C) 2005 John McCutchan
53+ */
54+
55+#ifndef _LINUX_INOTIFY_H
56+#define _LINUX_INOTIFY_H
57+
58+#include <stdint.h>
59+#include <sys/syscall.h>
60+#include <unistd.h>
61+
62+/*
63+ * struct inotify_event - structure read from the inotify device for each event
64+ *
65+ * When you are watching a directory, you will receive the filename for events
66+ * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
67+ */
68+struct inotify_event {
69+ int wd; /* watch descriptor */
70+ uint32_t mask; /* watch mask */
71+ uint32_t cookie; /* cookie to synchronize two events */
72+ uint32_t len; /* length (including nulls) of name */
73+ char name __flexarr; /* stub for possible name */
74+};
75+
76+/* the following are legal, implemented events that user-space can watch for */
77+#define IN_ACCESS 0x00000001 /* File was accessed */
78+#define IN_MODIFY 0x00000002 /* File was modified */
79+#define IN_ATTRIB 0x00000004 /* Metadata changed */
80+#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
81+#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
82+#define IN_OPEN 0x00000020 /* File was opened */
83+#define IN_MOVED_FROM 0x00000040 /* File was moved from X */
84+#define IN_MOVED_TO 0x00000080 /* File was moved to Y */
85+#define IN_CREATE 0x00000100 /* Subfile was created */
86+#define IN_DELETE 0x00000200 /* Subfile was deleted */
87+#define IN_DELETE_SELF 0x00000400 /* Self was deleted */
88+#define IN_MOVE_SELF 0x00000800 /* Self was moved */
89+
90+/* the following are legal events. they are sent as needed to any watch */
91+#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */
92+#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
93+#define IN_IGNORED 0x00008000 /* File was ignored */
94+
95+/* helper events */
96+#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
97+#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
98+
99+/* special flags */
100+#define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
101+#define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
102+#define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
103+#define IN_ISDIR 0x40000000 /* event occurred against dir */
104+#define IN_ONESHOT 0x80000000 /* only send event once */
105+
106+/*
107+ * All of the events - we build the list by hand so that we can add flags in
108+ * the future and not break backward compatibility. Apps will get only the
109+ * events that they originally wanted. Be sure to add new events here!
110+ */
111+#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
112+ IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
113+ IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
114+ IN_MOVE_SELF)
115+
116+#if defined (__alpha__)
117+# define __NR_inotify_init 444
118+# define __NR_inotify_add_watch 445
119+# define __NR_inotify_rm_watch 446
120+
121+#elif defined (__arm__)
122+# define __NR_inotify_init (__NR_SYSCALL_BASE+316)
123+# define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
124+# define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)
125+
126+#elif defined (__frv__)
127+# define __NR_inotify_init 291
128+# define __NR_inotify_add_watch 292
129+# define __NR_inotify_rm_watch 293
130+
131+#elif defined(__i386__)
132+# define __NR_inotify_init 291
133+# define __NR_inotify_add_watch 292
134+# define __NR_inotify_rm_watch 293
135+
136+#elif defined (__ia64__)
137+# define __NR_inotify_init 1277
138+# define __NR_inotify_add_watch 1278
139+# define __NR_inotify_rm_watch 1279
140+
141+#elif defined (__mips__)
142+# if _MIPS_SIM == _MIPS_SIM_ABI32
143+# define __NR_inotify_init (__NR_Linux + 284)
144+# define __NR_inotify_add_watch (__NR_Linux + 285)
145+# define __NR_inotify_rm_watch (__NR_Linux + 286)
146+# endif
147+# if _MIPS_SIM == _MIPS_SIM_ABI64
148+# define __NR_inotify_init (__NR_Linux + 243)
149+# define __NR_inotify_add_watch (__NR_Linux + 243)
150+# define __NR_inotify_rm_watch (__NR_Linux + 243)
151+# endif
152+# if _MIPS_SIM == _MIPS_SIM_NABI32
153+# define __NR_inotify_init (__NR_Linux + 247)
154+# define __NR_inotify_add_watch (__NR_Linux + 248)
155+# define __NR_inotify_rm_watch (__NR_Linux + 249)
156+# endif
157+
158+#elif defined(__parisc__)
159+# define __NR_inotify_init (__NR_Linux + 269)
160+# define __NR_inotify_add_watch (__NR_Linux + 270)
161+# define __NR_inotify_rm_watch (__NR_Linux + 271)
162+
163+#elif defined(__powerpc__) || defined(__powerpc64__)
164+# define __NR_inotify_init 275
165+# define __NR_inotify_add_watch 276
166+# define __NR_inotify_rm_watch 277
167+
168+#elif defined (__s390__)
169+# define __NR_inotify_init 284
170+# define __NR_inotify_add_watch 285
171+# define __NR_inotify_rm_watch 286
172+
173+#elif defined (__sh__)
174+# define __NR_inotify_init 290
175+# define __NR_inotify_add_watch 291
176+# define __NR_inotify_rm_watch 292
177+
178+#elif defined (__sh64__)
179+# define __NR_inotify_init 318
180+# define __NR_inotify_add_watch 319
181+# define __NR_inotify_rm_watch 320
182+
183+#elif defined (__sparc__) || defined (__sparc64__)
184+# define __NR_inotify_init 151
185+# define __NR_inotify_add_watch 152
186+# define __NR_inotify_rm_watch 156
187+
188+#elif defined(__x86_64__)
189+# define __NR_inotify_init 253
190+# define __NR_inotify_add_watch 254
191+# define __NR_inotify_rm_watch 255
192+
193+#else
194+# error "Unsupported architecture!"
195+#endif
196+
197+static inline int inotify_init (void)
198+{
199+ return syscall (__NR_inotify_init);
200+}
201+
202+static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
203+{
204+ return syscall (__NR_inotify_add_watch, fd, name, mask);
205+}
206+
207+static inline int inotify_rm_watch (int fd, uint32_t wd)
208+{
209+ return syscall (__NR_inotify_rm_watch, fd, wd);
210+}
211+
212+
213+#endif /* _LINUX_INOTIFY_H */
This page took 0.106644 seconds and 4 git commands to generate.