2 * udev_sysdeps.h - wrapping of libc features and kernel defines
4 * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _UDEV_SYSDEPS_H_
22 #define _UDEV_SYSDEPS_H_
28 /* needed until Inotify! syscalls reach glibc */
29 #include <sys/syscall.h>
30 #ifndef __NR_inotify_init
32 # define __NR_inotify_init 291
33 # define __NR_inotify_add_watch 292
34 # define __NR_inotify_rm_watch 293
35 #elif defined(__x86_64__)
36 # define __NR_inotify_init 253
37 # define __NR_inotify_add_watch 254
38 # define __NR_inotify_rm_watch 255
39 #elif defined(__powerpc__) || defined(__powerpc64__)
40 # define __NR_inotify_init 275
41 # define __NR_inotify_add_watch 276
42 # define __NR_inotify_rm_watch 277
43 #elif defined (__ia64__)
44 # define __NR_inotify_init 1277
45 # define __NR_inotify_add_watch 1278
46 # define __NR_inotify_rm_watch 1279
47 #elif defined (__s390__)
48 # define __NR_inotify_init 284
49 # define __NR_inotify_add_watch 285
50 # define __NR_inotify_rm_watch 286
51 #elif defined (__alpha__)
52 # define __NR_inotify_init 444
53 # define __NR_inotify_add_watch 445
54 # define __NR_inotify_rm_watch 446
55 #elif defined (__sparc__) || defined (__sparc64__)
56 # define __NR_inotify_init 151
57 # define __NR_inotify_add_watch 152
58 # define __NR_inotify_rm_watch 156
59 #elif defined (__arm__)
60 # define __NR_inotify_init __NR_SYSCALL_BASE+316
61 # define __NR_inotify_add_watch __NR_SYSCALL_BASE+317
62 # define __NR_inotify_rm_watch __NR_SYSCALL_BASE+318
63 #elif defined (__sh__)
64 # define __NR_inotify_init 290
65 # define __NR_inotify_add_watch 291
66 # define __NR_inotify_rm_watch 292
67 #elif defined (__hppa__)
68 # define __NR_inotify_init 269
69 # define __NR_inotify_add_watch 270
70 # define __NR_inotify_rm_watch 271
71 #elif defined (__mips__)
73 # if _MIPS_SIM == _MIPS_SIM_ABI32
74 # define __NR_Linux 4000
75 # define __NR_inotify_init (__NR_Linux + 284)
76 # define __NR_inotify_add_watch (__NR_Linux + 285)
77 # define __NR_inotify_rm_watch (__NR_Linux + 286)
78 # elif _MIPS_SIM == _MIPS_SIM_ABI64
79 # define __NR_Linux 5000
80 # define __NR_inotify_init (__NR_Linux + 243)
81 # define __NR_inotify_add_watch (__NR_Linux + 244)
82 # define __NR_inotify_rm_watch (__NR_Linux + 245)
83 # elif _MIPS_SIM == _MIPS_SIM_NABI32
84 # define __NR_Linux 6000
85 # define __NR_inotify_init (__NR_Linux + 247)
86 # define __NR_inotify_add_watch (__NR_Linux + 248)
87 # define __NR_inotify_rm_watch (__NR_Linux + 249)
90 #warning "inotify unsupported on this architecture!"
92 #endif /* __NR_inotify_init */
94 /* dummy if we don't have the syscalls defined */
95 #ifndef __NR_inotify_init
96 static inline int inotify_init(void)
101 static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
106 /* needed until /usr/include/sys/inotify.h is working */
108 #include <sys/inotify.h>
110 static inline int inotify_init(void)
112 return syscall(__NR_inotify_init);
115 static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
117 return syscall(__NR_inotify_add_watch, fd, name, mask);
119 #endif /* __GLIBC__ */
120 #endif /* __NR_inotify_init */
123 #define IN_CREATE 0x00000100 /* Subfile was created */
124 #define IN_MOVED_FROM 0x00000040 /* File was moved from X */
125 #define IN_MOVED_TO 0x00000080 /* File was moved to Y */
126 #define IN_DELETE 0x00000200 /* Subfile was deleted */
127 #define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
128 #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
129 #endif /* IN_CREATE */
131 /* needed for our signal handlers to work */
134 #define asmlinkage __attribute__((regparm(0)))
137 #endif /* __i386__ */
139 /* headers are broken on some architectures */
141 #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
144 #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
147 #define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0)
150 #define __FD_ZERO(set) ((void) memset ((void*) (set), 0, sizeof (fd_set)))
153 #ifndef NETLINK_KOBJECT_UEVENT
154 #define NETLINK_KOBJECT_UEVENT 15
157 #ifndef SO_RCVBUFFORCE
158 #if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || defined(__sparc_v9__)
159 #define SO_RCVBUFFORCE 0x100b
161 #define SO_RCVBUFFORCE 33
165 extern uid_t lookup_user(const char *user);
166 extern gid_t lookup_group(const char *group);
168 extern size_t strlcpy(char *dst, const char *src, size_t size);
169 extern size_t strlcat(char *dst, const char *src, size_t size);