1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
/*
* Copyright (c) 2001-2002 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* The use of the syscall() function is an additional level of
* indirection. This avoids the dependency on kernel sources.
*/
#include <errno.h>
#include <unistd.h>
#if defined (__i386__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 226
# define __NR_lsetxattr 227
# define __NR_fsetxattr 228
# define __NR_getxattr 229
# define __NR_lgetxattr 230
# define __NR_fgetxattr 231
# define __NR_listxattr 232
# define __NR_llistxattr 233
# define __NR_flistxattr 234
# define __NR_removexattr 235
# define __NR_lremovexattr 236
# define __NR_fremovexattr 237
#elif defined (__sparc__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 169
# define __NR_lsetxattr 170
# define __NR_fsetxattr 171
# define __NR_getxattr 172
# define __NR_lgetxattr 173
# define __NR_fgetxattr 177
# define __NR_listxattr 178
# define __NR_llistxattr 179
# define __NR_flistxattr 180
# define __NR_removexattr 181
# define __NR_lremovexattr 182
# define __NR_fremovexattr 186
#elif defined (__ia64__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 1217
# define __NR_lsetxattr 1218
# define __NR_fsetxattr 1219
# define __NR_getxattr 1220
# define __NR_lgetxattr 1221
# define __NR_fgetxattr 1222
# define __NR_listxattr 1223
# define __NR_llistxattr 1224
# define __NR_flistxattr 1225
# define __NR_removexattr 1226
# define __NR_lremovexattr 1227
# define __NR_fremovexattr 1228
#elif defined (__powerpc__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 209
# define __NR_lsetxattr 210
# define __NR_fsetxattr 211
# define __NR_getxattr 212
# define __NR_lgetxattr 213
# define __NR_fgetxattr 214
# define __NR_listxattr 215
# define __NR_llistxattr 216
# define __NR_flistxattr 217
# define __NR_removexattr 218
# define __NR_lremovexattr 219
# define __NR_fremovexattr 220
#elif defined (__x86_64__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 188
# define __NR_lsetxattr 189
# define __NR_fsetxattr 190
# define __NR_getxattr 191
# define __NR_lgetxattr 192
# define __NR_fgetxattr 193
# define __NR_listxattr 194
# define __NR_llistxattr 195
# define __NR_flistxattr 196
# define __NR_removexattr 197
# define __NR_lremovexattr 198
# define __NR_fremovexattr 199
#elif defined (__s390__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 224
# define __NR_lsetxattr 225
# define __NR_fsetxattr 226
# define __NR_getxattr 227
# define __NR_lgetxattr 228
# define __NR_fgetxattr 229
# define __NR_listxattr 230
# define __NR_llistxattr 231
# define __NR_flistxattr 232
# define __NR_removexattr 233
# define __NR_lremovexattr 234
# define __NR_fremovexattr 235
#elif defined (__arm__)
# define HAVE_XATTR_SYSCALLS 1
# if defined(__ARM_EABI__) || defined(__thumb__)
# define __NR_SYSCALL_BASE 0
# else
# define __NR_SYSCALL_BASE 0x900000
# endif
# define __NR_setxattr (__NR_SYSCALL_BASE+226)
# define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
# define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
# define __NR_getxattr (__NR_SYSCALL_BASE+229)
# define __NR_lgetxattr (__NR_SYSCALL_BASE+230)
# define __NR_fgetxattr (__NR_SYSCALL_BASE+231)
# define __NR_listxattr (__NR_SYSCALL_BASE+232)
# define __NR_llistxattr (__NR_SYSCALL_BASE+233)
# define __NR_flistxattr (__NR_SYSCALL_BASE+234)
# define __NR_removexattr (__NR_SYSCALL_BASE+235)
# define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
# define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
#elif defined (__mips64)
# define HAVE_XATTR_SYSCALLS 1
# ifdef __LP64__ /* mips64 using n64 ABI */
# define __NR_Linux 5000
# else /* mips64 using n32 ABI */
# define __NR_Linux 6000
# endif
# define __NR_setxattr (__NR_Linux + 180)
# define __NR_lsetxattr (__NR_Linux + 181)
# define __NR_fsetxattr (__NR_Linux + 182)
# define __NR_getxattr (__NR_Linux + 183)
# define __NR_lgetxattr (__NR_Linux + 184)
# define __NR_fgetxattr (__NR_Linux + 185)
# define __NR_listxattr (__NR_Linux + 186)
# define __NR_llistxattr (__NR_Linux + 187)
# define __NR_flistxattr (__NR_Linux + 188)
# define __NR_removexattr (__NR_Linux + 189)
# define __NR_lremovexattr (__NR_Linux + 190)
# define __NR_fremovexattr (__NR_Linux + 191)
#elif defined (__mips__) /* mips32, or mips64 using o32 ABI */
# define HAVE_XATTR_SYSCALLS 1
# define __NR_Linux 4000
# define __NR_setxattr (__NR_Linux + 224)
# define __NR_lsetxattr (__NR_Linux + 225)
# define __NR_fsetxattr (__NR_Linux + 226)
# define __NR_getxattr (__NR_Linux + 227)
# define __NR_lgetxattr (__NR_Linux + 228)
# define __NR_fgetxattr (__NR_Linux + 229)
# define __NR_listxattr (__NR_Linux + 230)
# define __NR_llistxattr (__NR_Linux + 231)
# define __NR_flistxattr (__NR_Linux + 232)
# define __NR_removexattr (__NR_Linux + 233)
# define __NR_lremovexattr (__NR_Linux + 234)
# define __NR_fremovexattr (__NR_Linux + 235)
#elif defined (__alpha__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 382
# define __NR_lsetxattr 383
# define __NR_fsetxattr 384
# define __NR_getxattr 385
# define __NR_lgetxattr 386
# define __NR_fgetxattr 387
# define __NR_listxattr 388
# define __NR_llistxattr 389
# define __NR_flistxattr 390
# define __NR_removexattr 391
# define __NR_lremovexattr 392
# define __NR_fremovexattr 393
#elif defined (__mc68000__)
# define HAVE_XATTR_SYSCALLS 1
# define __NR_setxattr 223
# define __NR_lsetxattr 224
# define __NR_fsetxattr 225
# define __NR_getxattr 226
# define __NR_lgetxattr 227
# define __NR_fgetxattr 228
# define __NR_listxattr 229
# define __NR_llistxattr 230
# define __NR_flistxattr 231
# define __NR_removexattr 232
# define __NR_lremovexattr 233
# define __NR_fremovexattr 234
#else
# warning "Extended attribute syscalls undefined for this architecture"
# define HAVE_XATTR_SYSCALLS 0
#endif
#if HAVE_XATTR_SYSCALLS
# define SYSCALL(args...) syscall(args)
#else
# define SYSCALL(args...) ( errno = ENOSYS, -1 )
#endif
int setxattr (const char *path, const char *name,
void *value, size_t size, int flags)
{
return SYSCALL(__NR_setxattr, path, name, value, size, flags);
}
int lsetxattr (const char *path, const char *name,
void *value, size_t size, int flags)
{
return SYSCALL(__NR_lsetxattr, path, name, value, size, flags);
}
int fsetxattr (int filedes, const char *name,
void *value, size_t size, int flags)
{
return SYSCALL(__NR_fsetxattr, filedes, name, value, size, flags);
}
ssize_t getxattr (const char *path, const char *name,
void *value, size_t size)
{
return SYSCALL(__NR_getxattr, path, name, value, size);
}
ssize_t lgetxattr (const char *path, const char *name,
void *value, size_t size)
{
return SYSCALL(__NR_lgetxattr, path, name, value, size);
}
ssize_t fgetxattr (int filedes, const char *name,
void *value, size_t size)
{
return SYSCALL(__NR_fgetxattr, filedes, name, value, size);
}
ssize_t listxattr (const char *path, char *list, size_t size)
{
return SYSCALL(__NR_listxattr, path, list, size);
}
ssize_t llistxattr (const char *path, char *list, size_t size)
{
return SYSCALL(__NR_llistxattr, path, list, size);
}
ssize_t flistxattr (int filedes, char *list, size_t size)
{
return SYSCALL(__NR_flistxattr, filedes, list, size);
}
int removexattr (const char *path, const char *name)
{
return SYSCALL(__NR_removexattr, path, name);
}
int lremovexattr (const char *path, const char *name)
{
return SYSCALL(__NR_lremovexattr, path, name);
}
int fremovexattr (int filedes, const char *name)
{
return SYSCALL(__NR_fremovexattr, filedes, name);
}
|