Ticket #243: patch-inotify-avahi

File patch-inotify-avahi, 7.2 KB (added by Adrian Bunk, 4 years ago)
Line 
1
2diff --git a/avahi-daemon/Makefile.am b/avahi-daemon/Makefile.am
3index 622b4de..0aac0fc 100644
4--- a/avahi-daemon/Makefile.am
5+++ b/avahi-daemon/Makefile.am
6@@ -53,8 +53,7 @@ avahi_daemon_SOURCES = \
7    static-hosts.c static-hosts.h \
8    ini-file-parser.c ini-file-parser.h \
9    setproctitle.c setproctitle.h \
10-   ../avahi-client/check-nss.c \
11-   inotify-nosys.h
12+   ../avahi-client/check-nss.c
13 
14 avahi_daemon_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS) $(XML_CFLAGS)
15 avahi_daemon_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-core/libavahi-core.la $(LIBDAEMON_LIBS) $(XML_LIBS)
16diff --git a/avahi-daemon/inotify-nosys.h b/avahi-daemon/inotify-nosys.h
17deleted file mode 100644
18index 6af44dc..0000000
19--- a/avahi-daemon/inotify-nosys.h
20+++ /dev/null
21@@ -1,181 +0,0 @@
22-/*
23- * This header is used if <sys/inotify.h> cannot be found.
24- *
25- * Inode based directory notification for Linux
26- *
27- * Copyright (C) 2005 John McCutchan
28- */
29-
30-#ifndef _LINUX_INOTIFY_H
31-#define _LINUX_INOTIFY_H
32-
33-#include <stdint.h>
34-#include <sys/syscall.h>
35-#include <unistd.h>
36-#include <asm/unistd.h>
37-
38-/*
39- * struct inotify_event - structure read from the inotify device for each event
40- *
41- * When you are watching a directory, you will receive the filename for events
42- * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
43- */
44-struct inotify_event {
45-   int     wd;     /* watch descriptor */
46-   uint32_t        mask;       /* watch mask */
47-   uint32_t        cookie;     /* cookie to synchronize two events */
48-   uint32_t        len;        /* length (including nulls) of name */
49-   char        name __flexarr; /* stub for possible name */
50-};
51-
52-/* the following are legal, implemented events that user-space can watch for */
53-#define IN_ACCESS      0x00000001  /* File was accessed */
54-#define IN_MODIFY      0x00000002  /* File was modified */
55-#define IN_ATTRIB      0x00000004  /* Metadata changed */
56-#define IN_CLOSE_WRITE     0x00000008  /* Writtable file was closed */
57-#define IN_CLOSE_NOWRITE   0x00000010  /* Unwrittable file closed */
58-#define IN_OPEN            0x00000020  /* File was opened */
59-#define IN_MOVED_FROM      0x00000040  /* File was moved from X */
60-#define IN_MOVED_TO        0x00000080  /* File was moved to Y */
61-#define IN_CREATE      0x00000100  /* Subfile was created */
62-#define IN_DELETE      0x00000200  /* Subfile was deleted */
63-#define IN_DELETE_SELF     0x00000400  /* Self was deleted */
64-#define IN_MOVE_SELF       0x00000800  /* Self was moved */
65-
66-/* the following are legal events.  they are sent as needed to any watch */
67-#define IN_UNMOUNT     0x00002000  /* Backing fs was unmounted */
68-#define IN_Q_OVERFLOW      0x00004000  /* Event queued overflowed */
69-#define IN_IGNORED     0x00008000  /* File was ignored */
70-
71-/* helper events */
72-#define IN_CLOSE       (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
73-#define IN_MOVE            (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
74-
75-/* special flags */
76-#define IN_ONLYDIR     0x01000000  /* only watch the path if it is a directory */
77-#define IN_DONT_FOLLOW     0x02000000  /* don't follow a sym link */
78-#define IN_MASK_ADD        0x20000000  /* add to the mask of an already existing watch */
79-#define IN_ISDIR       0x40000000  /* event occurred against dir */
80-#define IN_ONESHOT     0x80000000  /* only send event once */
81-
82-/*
83- * All of the events - we build the list by hand so that we can add flags in
84- * the future and not break backward compatibility.  Apps will get only the
85- * events that they originally wanted.  Be sure to add new events here!
86- */
87-#define IN_ALL_EVENTS  (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
88-            IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
89-            IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
90-            IN_MOVE_SELF)
91-
92-#if 0
93-#if defined (__alpha__)
94-# define __NR_inotify_init 444
95-# define __NR_inotify_add_watch 445
96-# define __NR_inotify_rm_watch 446
97-
98-#elif defined (__arm__)
99-# define __NR_inotify_init (__NR_SYSCALL_BASE+316)
100-# define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
101-# define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)
102-
103-#elif defined (__frv__)
104-# define __NR_inotify_init 291
105-# define __NR_inotify_add_watch 292
106-# define __NR_inotify_rm_watch 293
107-
108-#elif defined(__i386__)
109-# define __NR_inotify_init 291
110-# define __NR_inotify_add_watch 292
111-# define __NR_inotify_rm_watch 293
112-
113-#elif defined (__ia64__)
114-# define __NR_inotify_init 1277
115-# define __NR_inotify_add_watch 1278
116-# define __NR_inotify_rm_watch 1279
117-
118-#elif defined (__mips__)
119-# if _MIPS_SIM == _MIPS_SIM_ABI32
120-#  define __NR_inotify_init (__NR_Linux + 284)
121-#  define __NR_inotify_add_watch (__NR_Linux + 285)
122-#  define __NR_inotify_rm_watch (__NR_Linux + 286)
123-# endif
124-# if _MIPS_SIM == _MIPS_SIM_ABI64
125-#  define __NR_inotify_init (__NR_Linux + 243)
126-#  define __NR_inotify_add_watch (__NR_Linux + 243)
127-#  define __NR_inotify_rm_watch (__NR_Linux + 243)
128-# endif
129-# if _MIPS_SIM == _MIPS_SIM_NABI32
130-#  define __NR_inotify_init (__NR_Linux + 247)
131-#  define __NR_inotify_add_watch (__NR_Linux + 248)
132-#  define __NR_inotify_rm_watch (__NR_Linux + 249)
133-# endif
134-
135-#elif defined(__parisc__)
136-# define __NR_inotify_init (__NR_Linux + 269)
137-# define __NR_inotify_add_watch (__NR_Linux + 270)
138-# define __NR_inotify_rm_watch (__NR_Linux + 271)
139-
140-#elif defined(__powerpc__) || defined(__powerpc64__)
141-# define __NR_inotify_init 275
142-# define __NR_inotify_add_watch 276
143-# define __NR_inotify_rm_watch 277
144-
145-#elif defined (__s390__)
146-# define __NR_inotify_init 284
147-# define __NR_inotify_add_watch 285
148-# define __NR_inotify_rm_watch 286
149-
150-#elif defined (__sh__)
151-# define __NR_inotify_init 290
152-# define __NR_inotify_add_watch 291
153-# define __NR_inotify_rm_watch 292
154-
155-#elif defined (__sh64__)
156-# define __NR_inotify_init 318
157-# define __NR_inotify_add_watch 319
158-# define __NR_inotify_rm_watch 320
159-
160-#elif defined (__sparc__) || defined (__sparc64__)
161-# define __NR_inotify_init 151
162-# define __NR_inotify_add_watch 152
163-# define __NR_inotify_rm_watch 156
164-
165-#elif defined(__x86_64__)
166-# define __NR_inotify_init 253
167-# define __NR_inotify_add_watch 254
168-# define __NR_inotify_rm_watch 255
169-
170-#else
171-# error "Unsupported architecture!"
172-#endif
173-#endif
174-
175-#ifndef __NR_inotify_init
176-# error "Unsupported architecture!"
177-#endif
178-#ifndef __NR_inotify_add_watch
179-# error "Unsupported architecture!"
180-#endif
181-#ifndef __NR_inotify_rm_watch
182-# error "Unsupported architecture!"
183-#endif
184-
185-
186-static inline int inotify_init (void)
187-{
188-   return syscall (__NR_inotify_init);
189-}
190-
191-static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
192-{
193-   return syscall (__NR_inotify_add_watch, fd, name, mask);
194-}
195-
196-static inline int inotify_rm_watch (int fd, uint32_t wd)
197-{
198-   return syscall (__NR_inotify_rm_watch, fd, wd);
199-}
200-
201-
202-#endif /* _LINUX_INOTIFY_H */
203diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c
204index d8f9aa6..b5024a9 100644
205--- a/avahi-daemon/main.c
206+++ b/avahi-daemon/main.c
207@@ -43,11 +43,7 @@
208 #include <sys/socket.h>
209 
210 #ifdef HAVE_INOTIFY
211-#ifdef HAVE_SYS_INOTIFY_H
212 #include <sys/inotify.h>
213-#else
214-#include "inotify-nosys.h"
215-#endif
216 #endif
217 
218 #ifdef HAVE_KQUEUE
219diff --git a/configure.ac b/configure.ac
220index ce365b4..8c41f6b 100644
221--- a/configure.ac
222+++ b/configure.ac
223@@ -387,7 +387,6 @@ fi
224 AM_CONDITIONAL(HAVE_DLOPEN, test "x$HAVE_DLOPEN" = "xyes")
225 
226 have_inotify=no
227-AC_CHECK_HEADERS([linux/inotify.h], [have_inotify=yes])
228 AC_CHECK_HEADERS([sys/inotify.h], [have_inotify=yes])
229 
230 AM_CONDITIONAL(HAVE_INOTIFY, test "x$have_inotify" = "xyes")