~vcs-imports/attr/main

« back to all changes in this revision

Viewing changes to libattr/syscalls.c

  • Committer: lachlan.longdrop.melbourne.sgi.com
  • Date: 2006-12-09 02:55:09 UTC
  • Revision ID: vcs-imports@canonical.com-20061209025509-5909434ab1982a51
Remove system call stubs from libattr, we always defer to
the libc interfaces in this day and age.  Removes a SIGILL
delivery from the ARM EABI, reported by Lennert Buytenhek.
Also updates Debian packaging.
Merge of master-melb:xfs-cmds:27677a by kenmcd.

Show diffs side-by-side

added added

removed removed

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