]> git.proxmox.com Git - systemd.git/commitdiff
rename udev_libc_wrapper -> udev_sysdeps
authorKay Sievers <kay.sievers@suse.de>
Wed, 16 Aug 2006 00:04:04 +0000 (02:04 +0200)
committerKay Sievers <kay.sievers@suse.de>
Wed, 16 Aug 2006 00:04:04 +0000 (02:04 +0200)
Makefile
udev.h
udev_libc_wrapper.c [deleted file]
udev_libc_wrapper.h [deleted file]
udev_sysdeps.c [new file with mode: 0644]
udev_sysdeps.h [new file with mode: 0644]

index 209ab10487d32b0e73eca50bab973de326bc170a..1b3815f3bb7069f663624d99b28ae3d9346a1908 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ HEADERS = \
        udevd.h                         \
        udev_rules.h                    \
        logging.h                       \
-       udev_libc_wrapper.h             \
+       udev_sysdeps.h                  \
        udev_selinux.h                  \
        list.h
 
@@ -75,7 +75,7 @@ UDEV_OBJS = \
        udev_utils_string.o             \
        udev_utils_file.o               \
        udev_utils_run.o                \
-       udev_libc_wrapper.o
+       udev_sysdeps.o
 LIBUDEV = libudev.a
 
 MAN_PAGES = \
diff --git a/udev.h b/udev.h
index be01aeaa2a482019055eedd5ef768750e8880902..a69ce0893f0a35bfc64aa05047d29f39d50708e5 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -27,7 +27,7 @@
 
 #include "list.h"
 #include "logging.h"
-#include "udev_libc_wrapper.h"
+#include "udev_sysdeps.h"
 #include "udev_version.h"
 
 #define COMMENT_CHARACTER                      '#'
diff --git a/udev_libc_wrapper.c b/udev_libc_wrapper.c
deleted file mode 100644 (file)
index 35e01e6..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * udev_libc_wrapper - wrapping of functions missing in a specific libc
- *                    or not working in a statically compiled binary
- *
- * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (C) 2005 Kay Sievers <kay@vrfy.org>
- *
- *     This program is free software; you can redistribute it and/or modify it
- *     under the terms of the GNU General Public License as published by the
- *     Free Software Foundation version 2 of the License.
- * 
- *     This program is distributed in the hope that it will be useful, but
- *     WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *     General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License along
- *     with this program; if not, write to the Free Software Foundation, Inc.,
- *     675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#include "udev.h"
-
-#ifndef __GLIBC__
-#define __OWN_USERDB_PARSER__
-#endif
-
-#ifdef __GLIBC__
-#define __OWN_STRLCPYCAT__
-#endif
-
-#ifdef USE_STATIC
-#define __OWN_USERDB_PARSER__
-#endif
-
-#ifdef __OWN_STRLCPYCAT__
-size_t strlcpy(char *dst, const char *src, size_t size)
-{
-       size_t bytes = 0;
-       char *q = dst;
-       const char *p = src;
-       char ch;
-
-       while ((ch = *p++)) {
-               if (bytes+1 < size)
-                       *q++ = ch;
-               bytes++;
-       }
-
-       /* If size == 0 there is no space for a final null... */
-       if (size)
-               *q = '\0';
-
-       return bytes;
-}
-
-size_t strlcat(char *dst, const char *src, size_t size)
-{
-       size_t bytes = 0;
-       char *q = dst;
-       const char *p = src;
-       char ch;
-
-       while (bytes < size && *q) {
-               q++;
-               bytes++;
-       }
-       if (bytes == size)
-               return (bytes + strlen(src));
-
-       while ((ch = *p++)) {
-               if (bytes+1 < size)
-               *q++ = ch;
-               bytes++;
-       }
-
-       *q = '\0';
-       return bytes;
-}
-#endif /* __OWN_STRLCPYCAT__ */
-
-#ifndef __OWN_USERDB_PARSER__
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-
-uid_t lookup_user(const char *user)
-{
-       struct passwd *pw;
-       uid_t uid = 0;
-
-       pw = getpwnam(user);
-       if (pw == NULL)
-               err("error resolving user '%s': %s", user, strerror(errno));
-       else
-               uid = pw->pw_uid;
-
-       return uid;
-}
-
-gid_t lookup_group(const char *group)
-{
-       struct group *gr;
-       gid_t gid = 0;
-
-       gr = getgrnam(group);
-       if (gr == NULL)
-               err("error resolving group '%s': %s", group, strerror(errno));
-       else
-               gid = gr->gr_gid;
-
-       return gid;
-}
-
-#else /* __OWN_USERDB_PARSER__ */
-
-#define PASSWD_FILE            "/etc/passwd"
-#define GROUP_FILE             "/etc/group"
-
-/* return the id of a passwd style line, selected by the users name */
-static unsigned long get_id_by_name(const char *uname, const char *dbfile)
-{
-       unsigned long id = 0;
-       char line[LINE_SIZE];
-       char *buf;
-       char *bufline;
-       size_t bufsize;
-       size_t cur;
-       size_t count;
-       char *pos;
-       char *name;
-       char *idstr;
-       char *tail;
-
-       if (file_map(dbfile, &buf, &bufsize) != 0) {
-               err("can't open '%s' as db file: %s", dbfile, strerror(errno));
-               return 0;
-       }
-       dbg("search '%s' in '%s'", uname, dbfile);
-
-       /* loop through the whole file */
-       cur = 0;
-       while (cur < bufsize) {
-               count = buf_get_line(buf, bufsize, cur);
-               bufline = &buf[cur];
-               cur += count+1;
-
-               if (count >= sizeof(line))
-                       continue;
-
-               memcpy(line, bufline, count-1);
-               line[count-1] = '\0';
-               pos = line;
-
-               /* get name */
-               name = strsep(&pos, ":");
-               if (name == NULL)
-                       continue;
-
-               /* skip pass */
-               if (strsep(&pos, ":") == NULL)
-                       continue;
-
-               /* get id */
-               idstr = strsep(&pos, ":");
-               if (idstr == NULL)
-                       continue;
-
-               if (strcmp(uname, name) == 0) {
-                       id = strtoul(idstr, &tail, 10);
-                       if (tail[0] != '\0') {
-                               id = 0;
-                               dbg("no id found for '%s'",  name);
-                       } else
-                               dbg("id for '%s' is '%li'", name, id);
-                       break;
-               }
-       }
-
-       file_unmap(buf, bufsize);
-       return id;
-}
-
-uid_t lookup_user(const char *user)
-{
-       unsigned long id;
-
-       id = get_id_by_name(user, PASSWD_FILE);
-       return (uid_t) id;
-}
-
-gid_t lookup_group(const char *group)
-{
-       unsigned long id;
-
-       id = get_id_by_name(group, GROUP_FILE);
-       return (gid_t) id;
-}
-#endif /* __OWN_USERDB_PARSER__ */
diff --git a/udev_libc_wrapper.h b/udev_libc_wrapper.h
deleted file mode 100644 (file)
index 21dbce6..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * udev_libc_wrapper - wrapping of functions missing in a specific libc
- *                    or not working in a statically compiled binary
- *
- * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
- *
- *     This program is free software; you can redistribute it and/or modify it
- *     under the terms of the GNU General Public License as published by the
- *     Free Software Foundation version 2 of the License.
- * 
- *     This program is distributed in the hope that it will be useful, but
- *     WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *     General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License along
- *     with this program; if not, write to the Free Software Foundation, Inc.,
- *     675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _UDEV_LIBC_WRAPPER_H_
-#define _UDEV_LIBC_WRAPPER_H_
-
-#include <string.h>
-#include <unistd.h>
-#include <stdint.h>
-
-/* needed until Inotify! syscalls reach glibc */
-#include <sys/syscall.h>
-#ifndef __NR_inotify_init
-#if defined(__i386__)
-# define __NR_inotify_init     291
-# define __NR_inotify_add_watch        292
-# define __NR_inotify_rm_watch 293
-#elif defined(__x86_64__)
-# define __NR_inotify_init     253
-# define __NR_inotify_add_watch        254
-# define __NR_inotify_rm_watch 255
-#elif defined(__powerpc__) || defined(__powerpc64__)
-# define __NR_inotify_init     275
-# define __NR_inotify_add_watch        276
-# define __NR_inotify_rm_watch 277
-#elif defined (__ia64__)
-# define __NR_inotify_init     1277
-# define __NR_inotify_add_watch        1278
-# define __NR_inotify_rm_watch 1279
-#elif defined (__s390__)
-# define __NR_inotify_init     284
-# define __NR_inotify_add_watch        285
-# define __NR_inotify_rm_watch 286
-#elif defined (__alpha__)
-# define __NR_inotify_init     444
-# define __NR_inotify_add_watch        445
-# define __NR_inotify_rm_watch 446
-#elif defined (__sparc__) || defined (__sparc64__)
-# define __NR_inotify_init     151
-# define __NR_inotify_add_watch        152
-# define __NR_inotify_rm_watch 156
-#elif defined (__arm__)
-# define __NR_inotify_init     __NR_SYSCALL_BASE+316
-# define __NR_inotify_add_watch        __NR_SYSCALL_BASE+317
-# define __NR_inotify_rm_watch __NR_SYSCALL_BASE+318
-#elif defined (__sh__)
-# define __NR_inotify_init     290
-# define __NR_inotify_add_watch        291
-# define __NR_inotify_rm_watch 292
-#elif defined (__hppa__)
-# define __NR_inotify_init      269
-# define __NR_inotify_add_watch 270
-# define __NR_inotify_rm_watch  271
-#elif defined (__mips__)
-# include <sgidefs.h>
-# if _MIPS_SIM == _MIPS_SIM_ABI32
-#  define __NR_Linux             4000
-#  define __NR_inotify_init      (__NR_Linux + 284)
-#  define __NR_inotify_add_watch (__NR_Linux + 285)
-#  define __NR_inotify_rm_watch  (__NR_Linux + 286)
-# elif _MIPS_SIM == _MIPS_SIM_ABI64
-#  define __NR_Linux             5000
-#  define __NR_inotify_init      (__NR_Linux + 243)
-#  define __NR_inotify_add_watch (__NR_Linux + 244)
-#  define __NR_inotify_rm_watch  (__NR_Linux + 245)
-# elif _MIPS_SIM == _MIPS_SIM_NABI32
-#  define __NR_Linux             6000
-#  define __NR_inotify_init      (__NR_Linux + 247)
-#  define __NR_inotify_add_watch (__NR_Linux + 248)
-#  define __NR_inotify_rm_watch  (__NR_Linux + 249)
-# endif
-#else
-#warning "inotify unsupported on this architecture!"
-#endif
-#endif /* __NR_inotify_init */
-
-/* dummy if we don't have the syscalls defined */
-#ifndef __NR_inotify_init
-static inline int inotify_init(void)
-{
-       return -1;
-}
-
-static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
-{
-       return -1;
-}
-#else
-/* needed until /usr/include/sys/inotify.h is working */
-#ifndef __GLIBC__
-#include <sys/inotify.h>
-#else
-static inline int inotify_init(void)
-{
-       return syscall(__NR_inotify_init);
-}
-
-static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
-{
-       return syscall(__NR_inotify_add_watch, fd, name, mask);
-}
-#endif /* __GLIBC__ */
-#endif /* __NR_inotify_init */
-
-#ifndef IN_CREATE
-#define IN_CREATE              0x00000100      /* Subfile was created */
-#define IN_MOVED_FROM          0x00000040      /* File was moved from X */
-#define IN_MOVED_TO            0x00000080      /* File was moved to Y */
-#define IN_DELETE              0x00000200      /* Subfile was deleted */
-#define IN_CLOSE_WRITE         0x00000008      /* Writtable file was closed */
-#define IN_MOVE                        (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
-#endif /* IN_CREATE */
-
-/* needed for our signal handlers to work */
-#undef asmlinkage
-#ifdef __i386__
-#define asmlinkage     __attribute__((regparm(0)))
-#else
-#define asmlinkage
-#endif /* __i386__ */
-
-/* headers are broken on some architectures */
-#ifndef __FD_SET
-#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
-#endif
-#ifndef __FD_CLR
-#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
-#endif
-#ifndef __FD_ISSET
-#define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0)
-#endif
-#ifndef __FD_ZERO
-#define __FD_ZERO(set) ((void) memset ((void*) (set), 0, sizeof (fd_set)))
-#endif
-
-#ifndef NETLINK_KOBJECT_UEVENT
-#define NETLINK_KOBJECT_UEVENT 15
-#endif
-
-#ifndef SO_RCVBUFFORCE
-#if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || defined(__sparc_v9__)
-#define SO_RCVBUFFORCE 0x100b
-#else
-#define SO_RCVBUFFORCE 33
-#endif
-#endif
-
-extern uid_t lookup_user(const char *user);
-extern gid_t lookup_group(const char *group);
-
-extern size_t strlcpy(char *dst, const char *src, size_t size);
-extern size_t strlcat(char *dst, const char *src, size_t size);
-
-#endif /* _UDEV_LIBC_WRAPPER_H_ */
diff --git a/udev_sysdeps.c b/udev_sysdeps.c
new file mode 100644 (file)
index 0000000..152b7f0
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * udev_sysdeps.c - wrapping of libc features and kernel defines
+ *
+ * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify it
+ *     under the terms of the GNU General Public License as published by the
+ *     Free Software Foundation version 2 of the License.
+ * 
+ *     This program is distributed in the hope that it will be useful, but
+ *     WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     General Public License for more details.
+ * 
+ *     You should have received a copy of the GNU General Public License along
+ *     with this program; if not, write to the Free Software Foundation, Inc.,
+ *     675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#include "udev.h"
+
+#ifndef __GLIBC__
+#define __OWN_USERDB_PARSER__
+#endif
+
+#ifdef __GLIBC__
+#define __OWN_STRLCPYCAT__
+#endif
+
+#ifdef USE_STATIC
+#define __OWN_USERDB_PARSER__
+#endif
+
+#ifdef __OWN_STRLCPYCAT__
+size_t strlcpy(char *dst, const char *src, size_t size)
+{
+       size_t bytes = 0;
+       char *q = dst;
+       const char *p = src;
+       char ch;
+
+       while ((ch = *p++)) {
+               if (bytes+1 < size)
+                       *q++ = ch;
+               bytes++;
+       }
+
+       /* If size == 0 there is no space for a final null... */
+       if (size)
+               *q = '\0';
+
+       return bytes;
+}
+
+size_t strlcat(char *dst, const char *src, size_t size)
+{
+       size_t bytes = 0;
+       char *q = dst;
+       const char *p = src;
+       char ch;
+
+       while (bytes < size && *q) {
+               q++;
+               bytes++;
+       }
+       if (bytes == size)
+               return (bytes + strlen(src));
+
+       while ((ch = *p++)) {
+               if (bytes+1 < size)
+               *q++ = ch;
+               bytes++;
+       }
+
+       *q = '\0';
+       return bytes;
+}
+#endif /* __OWN_STRLCPYCAT__ */
+
+#ifndef __OWN_USERDB_PARSER__
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+
+uid_t lookup_user(const char *user)
+{
+       struct passwd *pw;
+       uid_t uid = 0;
+
+       pw = getpwnam(user);
+       if (pw == NULL)
+               err("error resolving user '%s': %s", user, strerror(errno));
+       else
+               uid = pw->pw_uid;
+
+       return uid;
+}
+
+gid_t lookup_group(const char *group)
+{
+       struct group *gr;
+       gid_t gid = 0;
+
+       gr = getgrnam(group);
+       if (gr == NULL)
+               err("error resolving group '%s': %s", group, strerror(errno));
+       else
+               gid = gr->gr_gid;
+
+       return gid;
+}
+
+#else /* __OWN_USERDB_PARSER__ */
+
+#define PASSWD_FILE            "/etc/passwd"
+#define GROUP_FILE             "/etc/group"
+
+/* return the id of a passwd style line, selected by the users name */
+static unsigned long get_id_by_name(const char *uname, const char *dbfile)
+{
+       unsigned long id = 0;
+       char line[LINE_SIZE];
+       char *buf;
+       char *bufline;
+       size_t bufsize;
+       size_t cur;
+       size_t count;
+       char *pos;
+       char *name;
+       char *idstr;
+       char *tail;
+
+       if (file_map(dbfile, &buf, &bufsize) != 0) {
+               err("can't open '%s' as db file: %s", dbfile, strerror(errno));
+               return 0;
+       }
+       dbg("search '%s' in '%s'", uname, dbfile);
+
+       /* loop through the whole file */
+       cur = 0;
+       while (cur < bufsize) {
+               count = buf_get_line(buf, bufsize, cur);
+               bufline = &buf[cur];
+               cur += count+1;
+
+               if (count >= sizeof(line))
+                       continue;
+
+               memcpy(line, bufline, count-1);
+               line[count-1] = '\0';
+               pos = line;
+
+               /* get name */
+               name = strsep(&pos, ":");
+               if (name == NULL)
+                       continue;
+
+               /* skip pass */
+               if (strsep(&pos, ":") == NULL)
+                       continue;
+
+               /* get id */
+               idstr = strsep(&pos, ":");
+               if (idstr == NULL)
+                       continue;
+
+               if (strcmp(uname, name) == 0) {
+                       id = strtoul(idstr, &tail, 10);
+                       if (tail[0] != '\0') {
+                               id = 0;
+                               dbg("no id found for '%s'",  name);
+                       } else
+                               dbg("id for '%s' is '%li'", name, id);
+                       break;
+               }
+       }
+
+       file_unmap(buf, bufsize);
+       return id;
+}
+
+uid_t lookup_user(const char *user)
+{
+       unsigned long id;
+
+       id = get_id_by_name(user, PASSWD_FILE);
+       return (uid_t) id;
+}
+
+gid_t lookup_group(const char *group)
+{
+       unsigned long id;
+
+       id = get_id_by_name(group, GROUP_FILE);
+       return (gid_t) id;
+}
+#endif /* __OWN_USERDB_PARSER__ */
diff --git a/udev_sysdeps.h b/udev_sysdeps.h
new file mode 100644 (file)
index 0000000..530218f
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * udev_sysdeps.h - wrapping of libc features and kernel defines
+ *
+ * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify it
+ *     under the terms of the GNU General Public License as published by the
+ *     Free Software Foundation version 2 of the License.
+ * 
+ *     This program is distributed in the hope that it will be useful, but
+ *     WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     General Public License for more details.
+ * 
+ *     You should have received a copy of the GNU General Public License along
+ *     with this program; if not, write to the Free Software Foundation, Inc.,
+ *     675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _UDEV_SYSDEPS_H_
+#define _UDEV_SYSDEPS_H_
+
+#include <string.h>
+#include <unistd.h>
+#include <stdint.h>
+
+/* needed until Inotify! syscalls reach glibc */
+#include <sys/syscall.h>
+#ifndef __NR_inotify_init
+#if defined(__i386__)
+# define __NR_inotify_init     291
+# define __NR_inotify_add_watch        292
+# define __NR_inotify_rm_watch 293
+#elif defined(__x86_64__)
+# define __NR_inotify_init     253
+# define __NR_inotify_add_watch        254
+# define __NR_inotify_rm_watch 255
+#elif defined(__powerpc__) || defined(__powerpc64__)
+# define __NR_inotify_init     275
+# define __NR_inotify_add_watch        276
+# define __NR_inotify_rm_watch 277
+#elif defined (__ia64__)
+# define __NR_inotify_init     1277
+# define __NR_inotify_add_watch        1278
+# define __NR_inotify_rm_watch 1279
+#elif defined (__s390__)
+# define __NR_inotify_init     284
+# define __NR_inotify_add_watch        285
+# define __NR_inotify_rm_watch 286
+#elif defined (__alpha__)
+# define __NR_inotify_init     444
+# define __NR_inotify_add_watch        445
+# define __NR_inotify_rm_watch 446
+#elif defined (__sparc__) || defined (__sparc64__)
+# define __NR_inotify_init     151
+# define __NR_inotify_add_watch        152
+# define __NR_inotify_rm_watch 156
+#elif defined (__arm__)
+# define __NR_inotify_init     __NR_SYSCALL_BASE+316
+# define __NR_inotify_add_watch        __NR_SYSCALL_BASE+317
+# define __NR_inotify_rm_watch __NR_SYSCALL_BASE+318
+#elif defined (__sh__)
+# define __NR_inotify_init     290
+# define __NR_inotify_add_watch        291
+# define __NR_inotify_rm_watch 292
+#elif defined (__hppa__)
+# define __NR_inotify_init      269
+# define __NR_inotify_add_watch 270
+# define __NR_inotify_rm_watch  271
+#elif defined (__mips__)
+# include <sgidefs.h>
+# if _MIPS_SIM == _MIPS_SIM_ABI32
+#  define __NR_Linux             4000
+#  define __NR_inotify_init      (__NR_Linux + 284)
+#  define __NR_inotify_add_watch (__NR_Linux + 285)
+#  define __NR_inotify_rm_watch  (__NR_Linux + 286)
+# elif _MIPS_SIM == _MIPS_SIM_ABI64
+#  define __NR_Linux             5000
+#  define __NR_inotify_init      (__NR_Linux + 243)
+#  define __NR_inotify_add_watch (__NR_Linux + 244)
+#  define __NR_inotify_rm_watch  (__NR_Linux + 245)
+# elif _MIPS_SIM == _MIPS_SIM_NABI32
+#  define __NR_Linux             6000
+#  define __NR_inotify_init      (__NR_Linux + 247)
+#  define __NR_inotify_add_watch (__NR_Linux + 248)
+#  define __NR_inotify_rm_watch  (__NR_Linux + 249)
+# endif
+#else
+#warning "inotify unsupported on this architecture!"
+#endif
+#endif /* __NR_inotify_init */
+
+/* dummy if we don't have the syscalls defined */
+#ifndef __NR_inotify_init
+static inline int inotify_init(void)
+{
+       return -1;
+}
+
+static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
+{
+       return -1;
+}
+#else
+/* needed until /usr/include/sys/inotify.h is working */
+#ifndef __GLIBC__
+#include <sys/inotify.h>
+#else
+static inline int inotify_init(void)
+{
+       return syscall(__NR_inotify_init);
+}
+
+static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
+{
+       return syscall(__NR_inotify_add_watch, fd, name, mask);
+}
+#endif /* __GLIBC__ */
+#endif /* __NR_inotify_init */
+
+#ifndef IN_CREATE
+#define IN_CREATE              0x00000100      /* Subfile was created */
+#define IN_MOVED_FROM          0x00000040      /* File was moved from X */
+#define IN_MOVED_TO            0x00000080      /* File was moved to Y */
+#define IN_DELETE              0x00000200      /* Subfile was deleted */
+#define IN_CLOSE_WRITE         0x00000008      /* Writtable file was closed */
+#define IN_MOVE                        (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
+#endif /* IN_CREATE */
+
+/* needed for our signal handlers to work */
+#undef asmlinkage
+#ifdef __i386__
+#define asmlinkage     __attribute__((regparm(0)))
+#else
+#define asmlinkage
+#endif /* __i386__ */
+
+/* headers are broken on some architectures */
+#ifndef __FD_SET
+#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
+#endif
+#ifndef __FD_CLR
+#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
+#endif
+#ifndef __FD_ISSET
+#define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0)
+#endif
+#ifndef __FD_ZERO
+#define __FD_ZERO(set) ((void) memset ((void*) (set), 0, sizeof (fd_set)))
+#endif
+
+#ifndef NETLINK_KOBJECT_UEVENT
+#define NETLINK_KOBJECT_UEVENT 15
+#endif
+
+#ifndef SO_RCVBUFFORCE
+#if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || defined(__sparc_v9__)
+#define SO_RCVBUFFORCE 0x100b
+#else
+#define SO_RCVBUFFORCE 33
+#endif
+#endif
+
+extern uid_t lookup_user(const char *user);
+extern gid_t lookup_group(const char *group);
+
+extern size_t strlcpy(char *dst, const char *src, size_t size);
+extern size_t strlcat(char *dst, const char *src, size_t size);
+
+#endif