Commit | Line | Data |
---|---|---|
f7ab093f MM |
1 | #include <linux/spinlock_types.h> |
2 | #include <linux/types.h> | |
3 | #include <linux/slab.h> | |
2c590d5f | 4 | #include <linux/ioctl.h> |
f7ab093f MM |
5 | |
6 | extern struct client_debug_mask *cdm_array; | |
7 | extern char *debug_help_string; | |
8 | extern int help_string_initialized; | |
9 | extern struct dentry *debug_dir; | |
10 | extern struct dentry *help_file_dentry; | |
11 | extern struct dentry *client_debug_dentry; | |
12 | extern const struct file_operations debug_help_fops; | |
13 | extern int client_all_index; | |
14 | extern int client_verbose_index; | |
15 | extern int cdm_element_count; | |
16 | #define DEBUG_HELP_STRING_SIZE 4096 | |
17 | #define HELP_STRING_UNINITIALIZED \ | |
18 | "Client Debug Keywords are unknown until the first time\n" \ | |
19 | "the client is started after boot.\n" | |
20 | #define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help" | |
21 | #define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug" | |
22 | #define ORANGEFS_CLIENT_DEBUG_FILE "client-debug" | |
23 | #define PVFS2_VERBOSE "verbose" | |
24 | #define PVFS2_ALL "all" | |
25 | ||
26 | /* pvfs2-config.h ***********************************************************/ | |
27 | #define PVFS2_VERSION_MAJOR 2 | |
28 | #define PVFS2_VERSION_MINOR 9 | |
29 | #define PVFS2_VERSION_SUB 0 | |
30 | ||
31 | /* khandle stuff ***********************************************************/ | |
32 | ||
33 | /* | |
34 | * The 2.9 core will put 64 bit handles in here like this: | |
35 | * 1234 0000 0000 5678 | |
36 | * The 3.0 and beyond cores will put 128 bit handles in here like this: | |
37 | * 1234 5678 90AB CDEF | |
38 | * The kernel module will always use the first four bytes and | |
39 | * the last four bytes as an inum. | |
40 | */ | |
41 | struct pvfs2_khandle { | |
42 | unsigned char u[16]; | |
43 | } __aligned(8); | |
44 | ||
45 | /* | |
46 | * kernel version of an object ref. | |
47 | */ | |
48 | struct pvfs2_object_kref { | |
49 | struct pvfs2_khandle khandle; | |
50 | __s32 fs_id; | |
51 | __s32 __pad1; | |
52 | }; | |
53 | ||
54 | /* | |
55 | * compare 2 khandles assumes little endian thus from large address to | |
56 | * small address | |
57 | */ | |
58 | static inline int PVFS_khandle_cmp(const struct pvfs2_khandle *kh1, | |
59 | const struct pvfs2_khandle *kh2) | |
60 | { | |
61 | int i; | |
62 | ||
63 | for (i = 15; i >= 0; i--) { | |
64 | if (kh1->u[i] > kh2->u[i]) | |
65 | return 1; | |
66 | if (kh1->u[i] < kh2->u[i]) | |
67 | return -1; | |
68 | } | |
69 | ||
70 | return 0; | |
71 | } | |
72 | ||
73 | /* copy a khandle to a field of arbitrary size */ | |
74 | static inline void PVFS_khandle_to(const struct pvfs2_khandle *kh, | |
75 | void *p, int size) | |
76 | { | |
77 | int i; | |
78 | unsigned char *c = p; | |
79 | ||
80 | memset(p, 0, size); | |
81 | ||
82 | for (i = 0; i < 16 && i < size; i++) | |
83 | c[i] = kh->u[i]; | |
84 | } | |
85 | ||
86 | /* copy a khandle from a field of arbitrary size */ | |
87 | static inline void PVFS_khandle_from(struct pvfs2_khandle *kh, | |
88 | void *p, int size) | |
89 | { | |
90 | int i; | |
91 | unsigned char *c = p; | |
92 | ||
93 | memset(kh, 0, 16); | |
94 | ||
95 | for (i = 0; i < 16 && i < size; i++) | |
96 | kh->u[i] = c[i]; | |
97 | } | |
98 | ||
99 | /* pvfs2-types.h ************************************************************/ | |
100 | typedef __u32 PVFS_uid; | |
101 | typedef __u32 PVFS_gid; | |
102 | typedef __s32 PVFS_fs_id; | |
103 | typedef __u32 PVFS_permissions; | |
104 | typedef __u64 PVFS_time; | |
105 | typedef __s64 PVFS_size; | |
106 | typedef __u64 PVFS_flags; | |
107 | typedef __u64 PVFS_ds_position; | |
108 | typedef __s32 PVFS_error; | |
109 | typedef __s64 PVFS_offset; | |
110 | ||
111 | #define PVFS2_SUPER_MAGIC 0x20030528 | |
112 | #define PVFS_ERROR_BIT (1 << 30) | |
113 | #define PVFS_NON_ERRNO_ERROR_BIT (1 << 29) | |
114 | #define IS_PVFS_ERROR(__error) ((__error)&(PVFS_ERROR_BIT)) | |
115 | #define IS_PVFS_NON_ERRNO_ERROR(__error) \ | |
116 | (((__error)&(PVFS_NON_ERRNO_ERROR_BIT)) && IS_PVFS_ERROR(__error)) | |
117 | #define PVFS_ERROR_TO_ERRNO(__error) PVFS_get_errno_mapping(__error) | |
118 | ||
119 | /* 7 bits are used for the errno mapped error codes */ | |
120 | #define PVFS_ERROR_CODE(__error) \ | |
121 | ((__error) & (__s32)(0x7f|PVFS_ERROR_BIT)) | |
122 | #define PVFS_ERROR_CLASS(__error) \ | |
123 | ((__error) & ~((__s32)(0x7f|PVFS_ERROR_BIT|PVFS_NON_ERRNO_ERROR_BIT))) | |
124 | #define PVFS_NON_ERRNO_ERROR_CODE(__error) \ | |
125 | ((__error) & (__s32)(127|PVFS_ERROR_BIT|PVFS_NON_ERRNO_ERROR_BIT)) | |
126 | ||
127 | /* PVFS2 error codes, compliments of asm/errno.h */ | |
128 | #define PVFS_EPERM E(1) /* Operation not permitted */ | |
129 | #define PVFS_ENOENT E(2) /* No such file or directory */ | |
130 | #define PVFS_EINTR E(3) /* Interrupted system call */ | |
131 | #define PVFS_EIO E(4) /* I/O error */ | |
132 | #define PVFS_ENXIO E(5) /* No such device or address */ | |
133 | #define PVFS_EBADF E(6) /* Bad file number */ | |
134 | #define PVFS_EAGAIN E(7) /* Try again */ | |
135 | #define PVFS_ENOMEM E(8) /* Out of memory */ | |
136 | #define PVFS_EFAULT E(9) /* Bad address */ | |
137 | #define PVFS_EBUSY E(10) /* Device or resource busy */ | |
138 | #define PVFS_EEXIST E(11) /* File exists */ | |
139 | #define PVFS_ENODEV E(12) /* No such device */ | |
140 | #define PVFS_ENOTDIR E(13) /* Not a directory */ | |
141 | #define PVFS_EISDIR E(14) /* Is a directory */ | |
142 | #define PVFS_EINVAL E(15) /* Invalid argument */ | |
143 | #define PVFS_EMFILE E(16) /* Too many open files */ | |
144 | #define PVFS_EFBIG E(17) /* File too large */ | |
145 | #define PVFS_ENOSPC E(18) /* No space left on device */ | |
146 | #define PVFS_EROFS E(19) /* Read-only file system */ | |
147 | #define PVFS_EMLINK E(20) /* Too many links */ | |
148 | #define PVFS_EPIPE E(21) /* Broken pipe */ | |
149 | #define PVFS_EDEADLK E(22) /* Resource deadlock would occur */ | |
150 | #define PVFS_ENAMETOOLONG E(23) /* File name too long */ | |
151 | #define PVFS_ENOLCK E(24) /* No record locks available */ | |
152 | #define PVFS_ENOSYS E(25) /* Function not implemented */ | |
153 | #define PVFS_ENOTEMPTY E(26) /* Directory not empty */ | |
154 | /* | |
155 | #define PVFS_ELOOP E(27) * Too many symbolic links encountered | |
156 | */ | |
157 | #define PVFS_EWOULDBLOCK E(28) /* Operation would block */ | |
158 | #define PVFS_ENOMSG E(29) /* No message of desired type */ | |
159 | #define PVFS_EUNATCH E(30) /* Protocol driver not attached */ | |
160 | #define PVFS_EBADR E(31) /* Invalid request descriptor */ | |
161 | #define PVFS_EDEADLOCK E(32) | |
162 | #define PVFS_ENODATA E(33) /* No data available */ | |
163 | #define PVFS_ETIME E(34) /* Timer expired */ | |
164 | #define PVFS_ENONET E(35) /* Machine is not on the network */ | |
165 | #define PVFS_EREMOTE E(36) /* Object is remote */ | |
166 | #define PVFS_ECOMM E(37) /* Communication error on send */ | |
167 | #define PVFS_EPROTO E(38) /* Protocol error */ | |
168 | #define PVFS_EBADMSG E(39) /* Not a data message */ | |
169 | /* | |
170 | #define PVFS_EOVERFLOW E(40) * Value too large for defined data | |
171 | * type | |
172 | */ | |
173 | /* | |
174 | #define PVFS_ERESTART E(41) * Interrupted system call should be | |
175 | * restarted | |
176 | */ | |
177 | #define PVFS_EMSGSIZE E(42) /* Message too long */ | |
178 | #define PVFS_EPROTOTYPE E(43) /* Protocol wrong type for socket */ | |
179 | #define PVFS_ENOPROTOOPT E(44) /* Protocol not available */ | |
180 | #define PVFS_EPROTONOSUPPORT E(45) /* Protocol not supported */ | |
181 | /* | |
182 | #define PVFS_EOPNOTSUPP E(46) * Operation not supported on transport | |
183 | * endpoint | |
184 | */ | |
185 | #define PVFS_EADDRINUSE E(47) /* Address already in use */ | |
186 | #define PVFS_EADDRNOTAVAIL E(48) /* Cannot assign requested address */ | |
187 | #define PVFS_ENETDOWN E(49) /* Network is down */ | |
188 | #define PVFS_ENETUNREACH E(50) /* Network is unreachable */ | |
189 | /* | |
190 | #define PVFS_ENETRESET E(51) * Network dropped connection because | |
191 | * of reset | |
192 | */ | |
193 | #define PVFS_ENOBUFS E(52) /* No buffer space available */ | |
194 | #define PVFS_ETIMEDOUT E(53) /* Connection timed out */ | |
195 | #define PVFS_ECONNREFUSED E(54) /* Connection refused */ | |
196 | #define PVFS_EHOSTDOWN E(55) /* Host is down */ | |
197 | #define PVFS_EHOSTUNREACH E(56) /* No route to host */ | |
198 | #define PVFS_EALREADY E(57) /* Operation already in progress */ | |
199 | #define PVFS_EACCES E(58) /* Access not allowed */ | |
200 | #define PVFS_ECONNRESET E(59) /* Connection reset by peer */ | |
201 | #define PVFS_ERANGE E(60) /* Math out of range or buf too small */ | |
202 | ||
203 | /***************** non-errno/pvfs2 specific error codes *****************/ | |
204 | #define PVFS_ECANCEL (1|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
205 | #define PVFS_EDEVINIT (2|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
206 | #define PVFS_EDETAIL (3|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
207 | #define PVFS_EHOSTNTFD (4|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
208 | #define PVFS_EADDRNTFD (5|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
209 | #define PVFS_ENORECVR (6|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
210 | #define PVFS_ETRYAGAIN (7|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
211 | #define PVFS_ENOTPVFS (8|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
212 | #define PVFS_ESECURITY (9|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
213 | ||
214 | /* | |
215 | * NOTE: PLEASE DO NOT ARBITRARILY ADD NEW ERRNO ERROR CODES! | |
216 | * | |
217 | * IF YOU CHOOSE TO ADD A NEW ERROR CODE (DESPITE OUR PLEA), YOU ALSO | |
218 | * NEED TO INCREMENT PVFS_ERRNO MAX (BELOW) AND ADD A MAPPING TO A | |
219 | * UNIX ERRNO VALUE IN THE MACROS BELOW (USED IN | |
220 | * src/common/misc/errno-mapping.c and the kernel module) | |
221 | */ | |
222 | #define PVFS_ERRNO_MAX 61 | |
223 | ||
224 | #define PVFS_ERROR_BMI (1 << 7) /* BMI-specific error */ | |
225 | #define PVFS_ERROR_TROVE (2 << 7) /* Trove-specific error */ | |
226 | #define PVFS_ERROR_FLOW (3 << 7) | |
227 | #define PVFS_ERROR_SM (4 << 7) /* state machine specific error */ | |
228 | #define PVFS_ERROR_SCHED (5 << 7) | |
229 | #define PVFS_ERROR_CLIENT (6 << 7) | |
230 | #define PVFS_ERROR_DEV (7 << 7) /* device file interaction */ | |
231 | ||
232 | #define PVFS_ERROR_CLASS_BITS \ | |
233 | (PVFS_ERROR_BMI | \ | |
234 | PVFS_ERROR_TROVE | \ | |
235 | PVFS_ERROR_FLOW | \ | |
236 | PVFS_ERROR_SM | \ | |
237 | PVFS_ERROR_SCHED | \ | |
238 | PVFS_ERROR_CLIENT | \ | |
239 | PVFS_ERROR_DEV) | |
240 | ||
241 | #define DECLARE_ERRNO_MAPPING() \ | |
242 | __s32 PINT_errno_mapping[PVFS_ERRNO_MAX + 1] = { \ | |
243 | 0, /* leave this one empty */ \ | |
244 | EPERM, /* 1 */ \ | |
245 | ENOENT, \ | |
246 | EINTR, \ | |
247 | EIO, \ | |
248 | ENXIO, \ | |
249 | EBADF, \ | |
250 | EAGAIN, \ | |
251 | ENOMEM, \ | |
252 | EFAULT, \ | |
253 | EBUSY, /* 10 */ \ | |
254 | EEXIST, \ | |
255 | ENODEV, \ | |
256 | ENOTDIR, \ | |
257 | EISDIR, \ | |
258 | EINVAL, \ | |
259 | EMFILE, \ | |
260 | EFBIG, \ | |
261 | ENOSPC, \ | |
262 | EROFS, \ | |
263 | EMLINK, /* 20 */ \ | |
264 | EPIPE, \ | |
265 | EDEADLK, \ | |
266 | ENAMETOOLONG, \ | |
267 | ENOLCK, \ | |
268 | ENOSYS, \ | |
269 | ENOTEMPTY, \ | |
270 | ELOOP, \ | |
271 | EWOULDBLOCK, \ | |
272 | ENOMSG, \ | |
273 | EUNATCH, /* 30 */ \ | |
274 | EBADR, \ | |
275 | EDEADLOCK, \ | |
276 | ENODATA, \ | |
277 | ETIME, \ | |
278 | ENONET, \ | |
279 | EREMOTE, \ | |
280 | ECOMM, \ | |
281 | EPROTO, \ | |
282 | EBADMSG, \ | |
283 | EOVERFLOW, /* 40 */ \ | |
284 | ERESTART, \ | |
285 | EMSGSIZE, \ | |
286 | EPROTOTYPE, \ | |
287 | ENOPROTOOPT, \ | |
288 | EPROTONOSUPPORT, \ | |
289 | EOPNOTSUPP, \ | |
290 | EADDRINUSE, \ | |
291 | EADDRNOTAVAIL, \ | |
292 | ENETDOWN, \ | |
293 | ENETUNREACH, /* 50 */ \ | |
294 | ENETRESET, \ | |
295 | ENOBUFS, \ | |
296 | ETIMEDOUT, \ | |
297 | ECONNREFUSED, \ | |
298 | EHOSTDOWN, \ | |
299 | EHOSTUNREACH, \ | |
300 | EALREADY, \ | |
301 | EACCES, \ | |
302 | ECONNRESET, /* 59 */ \ | |
303 | ERANGE, \ | |
304 | 0 /* PVFS_ERRNO_MAX */ \ | |
305 | }; \ | |
306 | const char *PINT_non_errno_strerror_mapping[] = { \ | |
307 | "Success", /* 0 */ \ | |
308 | "Operation cancelled (possibly due to timeout)", \ | |
309 | "Device initialization failed", \ | |
310 | "Detailed per-server errors are available", \ | |
311 | "Unknown host", \ | |
312 | "No address associated with name", \ | |
313 | "Unknown server error", \ | |
314 | "Host name lookup failure", \ | |
315 | "Path contains non-PVFS elements", \ | |
316 | "Security error", \ | |
317 | }; \ | |
318 | __s32 PINT_non_errno_mapping[] = { \ | |
319 | 0, /* leave this one empty */ \ | |
320 | PVFS_ECANCEL, /* 1 */ \ | |
321 | PVFS_EDEVINIT, /* 2 */ \ | |
322 | PVFS_EDETAIL, /* 3 */ \ | |
323 | PVFS_EHOSTNTFD, /* 4 */ \ | |
324 | PVFS_EADDRNTFD, /* 5 */ \ | |
325 | PVFS_ENORECVR, /* 6 */ \ | |
326 | PVFS_ETRYAGAIN, /* 7 */ \ | |
327 | PVFS_ENOTPVFS, /* 8 */ \ | |
328 | PVFS_ESECURITY, /* 9 */ \ | |
329 | } | |
330 | ||
331 | /* | |
332 | * NOTE: PVFS_get_errno_mapping will convert a PVFS_ERROR_CODE to an | |
333 | * errno value. If the error code is a pvfs2 specific error code | |
334 | * (i.e. a PVFS_NON_ERRNO_ERROR_CODE), PVFS_get_errno_mapping will | |
335 | * return an index into the PINT_non_errno_strerror_mapping array which | |
336 | * can be used for getting the pvfs2 specific strerror message given | |
337 | * the error code. if the value is not a recognized error code, the | |
338 | * passed in value will be returned unchanged. | |
339 | */ | |
340 | #define DECLARE_ERRNO_MAPPING_AND_FN() \ | |
341 | extern __s32 PINT_errno_mapping[]; \ | |
342 | extern __s32 PINT_non_errno_mapping[]; \ | |
343 | extern const char *PINT_non_errno_strerror_mapping[]; \ | |
344 | __s32 PVFS_get_errno_mapping(__s32 error) \ | |
345 | { \ | |
346 | __s32 ret = error, mask = 0; \ | |
347 | __s32 positive = ((error > -1) ? 1 : 0); \ | |
348 | if (IS_PVFS_NON_ERRNO_ERROR((positive ? error : -error))) { \ | |
349 | mask = (PVFS_NON_ERRNO_ERROR_BIT | \ | |
350 | PVFS_ERROR_BIT | \ | |
351 | PVFS_ERROR_CLASS_BITS); \ | |
352 | ret = PVFS_NON_ERRNO_ERROR_CODE(((positive ? \ | |
353 | error : \ | |
354 | abs(error))) & \ | |
355 | ~mask); \ | |
356 | } \ | |
357 | else if (IS_PVFS_ERROR((positive ? error : -error))) { \ | |
358 | mask = (PVFS_ERROR_BIT | \ | |
359 | PVFS_ERROR_CLASS_BITS); \ | |
360 | ret = PINT_errno_mapping[PVFS_ERROR_CODE(((positive ? \ | |
361 | error : \ | |
362 | abs(error))) & \ | |
363 | ~mask)]; \ | |
364 | } \ | |
365 | return ret; \ | |
366 | } \ | |
367 | __s32 PVFS_errno_to_error(int err) \ | |
368 | { \ | |
369 | __s32 e = 0; \ | |
370 | \ | |
371 | for (; e < PVFS_ERRNO_MAX; ++e) \ | |
372 | if (PINT_errno_mapping[e] == err) \ | |
373 | return e | PVFS_ERROR_BIT; \ | |
374 | \ | |
375 | return err; \ | |
376 | } \ | |
377 | DECLARE_ERRNO_MAPPING() | |
378 | ||
379 | /* permission bits */ | |
380 | #define PVFS_O_EXECUTE (1 << 0) | |
381 | #define PVFS_O_WRITE (1 << 1) | |
382 | #define PVFS_O_READ (1 << 2) | |
383 | #define PVFS_G_EXECUTE (1 << 3) | |
384 | #define PVFS_G_WRITE (1 << 4) | |
385 | #define PVFS_G_READ (1 << 5) | |
386 | #define PVFS_U_EXECUTE (1 << 6) | |
387 | #define PVFS_U_WRITE (1 << 7) | |
388 | #define PVFS_U_READ (1 << 8) | |
389 | /* no PVFS_U_VTX (sticky bit) */ | |
390 | #define PVFS_G_SGID (1 << 10) | |
391 | #define PVFS_U_SUID (1 << 11) | |
392 | ||
393 | /* definition taken from stdint.h */ | |
394 | #define INT32_MAX (2147483647) | |
395 | #define PVFS_ITERATE_START (INT32_MAX - 1) | |
396 | #define PVFS_ITERATE_END (INT32_MAX - 2) | |
397 | #define PVFS_READDIR_START PVFS_ITERATE_START | |
398 | #define PVFS_READDIR_END PVFS_ITERATE_END | |
399 | #define PVFS_IMMUTABLE_FL FS_IMMUTABLE_FL | |
400 | #define PVFS_APPEND_FL FS_APPEND_FL | |
401 | #define PVFS_NOATIME_FL FS_NOATIME_FL | |
402 | #define PVFS_MIRROR_FL 0x01000000ULL | |
403 | #define PVFS_O_EXECUTE (1 << 0) | |
404 | #define PVFS_FS_ID_NULL ((__s32)0) | |
405 | #define PVFS_ATTR_SYS_UID (1 << 0) | |
406 | #define PVFS_ATTR_SYS_GID (1 << 1) | |
407 | #define PVFS_ATTR_SYS_PERM (1 << 2) | |
408 | #define PVFS_ATTR_SYS_ATIME (1 << 3) | |
409 | #define PVFS_ATTR_SYS_CTIME (1 << 4) | |
410 | #define PVFS_ATTR_SYS_MTIME (1 << 5) | |
411 | #define PVFS_ATTR_SYS_TYPE (1 << 6) | |
412 | #define PVFS_ATTR_SYS_ATIME_SET (1 << 7) | |
413 | #define PVFS_ATTR_SYS_MTIME_SET (1 << 8) | |
414 | #define PVFS_ATTR_SYS_SIZE (1 << 20) | |
415 | #define PVFS_ATTR_SYS_LNK_TARGET (1 << 24) | |
416 | #define PVFS_ATTR_SYS_DFILE_COUNT (1 << 25) | |
417 | #define PVFS_ATTR_SYS_DIRENT_COUNT (1 << 26) | |
418 | #define PVFS_ATTR_SYS_BLKSIZE (1 << 28) | |
419 | #define PVFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29) | |
420 | #define PVFS_ATTR_SYS_COMMON_ALL \ | |
421 | (PVFS_ATTR_SYS_UID | \ | |
422 | PVFS_ATTR_SYS_GID | \ | |
423 | PVFS_ATTR_SYS_PERM | \ | |
424 | PVFS_ATTR_SYS_ATIME | \ | |
425 | PVFS_ATTR_SYS_CTIME | \ | |
426 | PVFS_ATTR_SYS_MTIME | \ | |
427 | PVFS_ATTR_SYS_TYPE) | |
428 | ||
429 | #define PVFS_ATTR_SYS_ALL_SETABLE \ | |
430 | (PVFS_ATTR_SYS_COMMON_ALL-PVFS_ATTR_SYS_TYPE) | |
431 | ||
432 | #define PVFS_ATTR_SYS_ALL_NOHINT \ | |
433 | (PVFS_ATTR_SYS_COMMON_ALL | \ | |
434 | PVFS_ATTR_SYS_SIZE | \ | |
435 | PVFS_ATTR_SYS_LNK_TARGET | \ | |
436 | PVFS_ATTR_SYS_DFILE_COUNT | \ | |
437 | PVFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ | |
438 | PVFS_ATTR_SYS_DIRENT_COUNT | \ | |
439 | PVFS_ATTR_SYS_BLKSIZE) | |
440 | #define PVFS_XATTR_REPLACE 0x2 | |
441 | #define PVFS_XATTR_CREATE 0x1 | |
442 | #define PVFS_MAX_SERVER_ADDR_LEN 256 | |
443 | #define PVFS_NAME_MAX 256 | |
444 | /* | |
445 | * max extended attribute name len as imposed by the VFS and exploited for the | |
446 | * upcall request types. | |
447 | * NOTE: Please retain them as multiples of 8 even if you wish to change them | |
448 | * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit | |
449 | * kernel. Due to implementation within DBPF, this really needs to be | |
450 | * PVFS_NAME_MAX, which it was the same value as, but no reason to let it | |
451 | * break if that changes in the future. | |
452 | */ | |
453 | #define PVFS_MAX_XATTR_NAMELEN PVFS_NAME_MAX /* Not the same as | |
454 | * XATTR_NAME_MAX defined | |
455 | * by <linux/xattr.h> | |
456 | */ | |
457 | #define PVFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX | |
458 | * defined by <linux/xattr.h> | |
459 | */ | |
460 | #define PVFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX | |
461 | * defined by <linux/xattr.h> | |
462 | */ | |
463 | /* | |
464 | * PVFS I/O operation types, used in both system and server interfaces. | |
465 | */ | |
466 | enum PVFS_io_type { | |
467 | PVFS_IO_READ = 1, | |
468 | PVFS_IO_WRITE = 2 | |
469 | }; | |
470 | ||
471 | /* | |
472 | * If this enum is modified the server parameters related to the precreate pool | |
473 | * batch and low threshold sizes may need to be modified to reflect this | |
474 | * change. | |
475 | */ | |
476 | enum pvfs2_ds_type { | |
477 | PVFS_TYPE_NONE = 0, | |
478 | PVFS_TYPE_METAFILE = (1 << 0), | |
479 | PVFS_TYPE_DATAFILE = (1 << 1), | |
480 | PVFS_TYPE_DIRECTORY = (1 << 2), | |
481 | PVFS_TYPE_SYMLINK = (1 << 3), | |
482 | PVFS_TYPE_DIRDATA = (1 << 4), | |
483 | PVFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ | |
484 | }; | |
485 | ||
486 | /* | |
487 | * PVFS_certificate simply stores a buffer with the buffer size. | |
488 | * The buffer can be converted to an OpenSSL X509 struct for use. | |
489 | */ | |
490 | struct PVFS_certificate { | |
491 | __u32 buf_size; | |
492 | unsigned char *buf; | |
493 | }; | |
494 | ||
495 | /* | |
496 | * A credential identifies a user and is signed by the client/user | |
497 | * private key. | |
498 | */ | |
499 | struct PVFS_credential { | |
500 | __u32 userid; /* user id */ | |
501 | __u32 num_groups; /* length of group_array */ | |
502 | __u32 *group_array; /* groups for which the user is a member */ | |
503 | char *issuer; /* alias of the issuing server */ | |
504 | __u64 timeout; /* seconds after epoch to time out */ | |
505 | __u32 sig_size; /* length of the signature in bytes */ | |
506 | unsigned char *signature; /* digital signature */ | |
507 | struct PVFS_certificate certificate; /* user certificate buffer */ | |
508 | }; | |
509 | #define extra_size_PVFS_credential (PVFS_REQ_LIMIT_GROUPS * \ | |
510 | sizeof(__u32) + \ | |
511 | PVFS_REQ_LIMIT_ISSUER + \ | |
512 | PVFS_REQ_LIMIT_SIGNATURE + \ | |
513 | extra_size_PVFS_certificate) | |
514 | ||
515 | /* This structure is used by the VFS-client interaction alone */ | |
516 | struct PVFS_keyval_pair { | |
517 | char key[PVFS_MAX_XATTR_NAMELEN]; | |
518 | __s32 key_sz; /* __s32 for portable, fixed-size structures */ | |
519 | __s32 val_sz; | |
520 | char val[PVFS_MAX_XATTR_VALUELEN]; | |
521 | }; | |
522 | ||
523 | /* pvfs2-sysint.h ***********************************************************/ | |
524 | /* Describes attributes for a file, directory, or symlink. */ | |
525 | struct PVFS_sys_attr_s { | |
526 | __u32 owner; | |
527 | __u32 group; | |
528 | __u32 perms; | |
529 | __u64 atime; | |
530 | __u64 mtime; | |
531 | __u64 ctime; | |
532 | __s64 size; | |
533 | ||
534 | /* NOTE: caller must free if valid */ | |
535 | char *link_target; | |
536 | ||
537 | /* Changed to __s32 so that size of structure does not change */ | |
538 | __s32 dfile_count; | |
539 | ||
540 | /* Changed to __s32 so that size of structure does not change */ | |
541 | __s32 distr_dir_servers_initial; | |
542 | ||
543 | /* Changed to __s32 so that size of structure does not change */ | |
544 | __s32 distr_dir_servers_max; | |
545 | ||
546 | /* Changed to __s32 so that size of structure does not change */ | |
547 | __s32 distr_dir_split_size; | |
548 | ||
549 | __u32 mirror_copies_count; | |
550 | ||
551 | /* NOTE: caller must free if valid */ | |
552 | char *dist_name; | |
553 | ||
554 | /* NOTE: caller must free if valid */ | |
555 | char *dist_params; | |
556 | ||
557 | __s64 dirent_count; | |
558 | enum pvfs2_ds_type objtype; | |
559 | __u64 flags; | |
560 | __u32 mask; | |
561 | __s64 blksize; | |
562 | }; | |
563 | ||
564 | #define PVFS2_LOOKUP_LINK_NO_FOLLOW 0 | |
565 | #define PVFS2_LOOKUP_LINK_FOLLOW 1 | |
566 | ||
567 | /* pint-dev.h ***************************************************************/ | |
568 | ||
569 | /* parameter structure used in PVFS_DEV_DEBUG ioctl command */ | |
570 | struct dev_mask_info_s { | |
571 | enum { | |
572 | KERNEL_MASK, | |
573 | CLIENT_MASK, | |
574 | } mask_type; | |
575 | __u64 mask_value; | |
576 | }; | |
577 | ||
578 | struct dev_mask2_info_s { | |
579 | __u64 mask1_value; | |
580 | __u64 mask2_value; | |
581 | }; | |
582 | ||
583 | /* pvfs2-util.h *************************************************************/ | |
584 | #define PVFS_util_min(x1, x2) (((x1) > (x2)) ? (x2) : (x1)) | |
585 | __s32 PVFS_util_translate_mode(int mode); | |
586 | ||
587 | /* pvfs2-debug.h ************************************************************/ | |
588 | #include "pvfs2-debug.h" | |
589 | ||
590 | /* pvfs2-internal.h *********************************************************/ | |
591 | #define llu(x) (unsigned long long)(x) | |
592 | #define lld(x) (long long)(x) | |
593 | ||
594 | /* pint-dev-shared.h ********************************************************/ | |
595 | #define PVFS_DEV_MAGIC 'k' | |
596 | ||
597 | #define PVFS2_READDIR_DEFAULT_DESC_COUNT 5 | |
598 | ||
599 | #define DEV_GET_MAGIC 0x1 | |
600 | #define DEV_GET_MAX_UPSIZE 0x2 | |
601 | #define DEV_GET_MAX_DOWNSIZE 0x3 | |
602 | #define DEV_MAP 0x4 | |
603 | #define DEV_REMOUNT_ALL 0x5 | |
604 | #define DEV_DEBUG 0x6 | |
605 | #define DEV_UPSTREAM 0x7 | |
606 | #define DEV_CLIENT_MASK 0x8 | |
607 | #define DEV_CLIENT_STRING 0x9 | |
608 | #define DEV_MAX_NR 0xa | |
609 | ||
610 | /* supported ioctls, codes are with respect to user-space */ | |
611 | enum { | |
612 | PVFS_DEV_GET_MAGIC = _IOW(PVFS_DEV_MAGIC, DEV_GET_MAGIC, __s32), | |
613 | PVFS_DEV_GET_MAX_UPSIZE = | |
614 | _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32), | |
615 | PVFS_DEV_GET_MAX_DOWNSIZE = | |
616 | _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32), | |
617 | PVFS_DEV_MAP = _IO(PVFS_DEV_MAGIC, DEV_MAP), | |
618 | PVFS_DEV_REMOUNT_ALL = _IO(PVFS_DEV_MAGIC, DEV_REMOUNT_ALL), | |
619 | PVFS_DEV_DEBUG = _IOR(PVFS_DEV_MAGIC, DEV_DEBUG, __s32), | |
620 | PVFS_DEV_UPSTREAM = _IOW(PVFS_DEV_MAGIC, DEV_UPSTREAM, int), | |
621 | PVFS_DEV_CLIENT_MASK = _IOW(PVFS_DEV_MAGIC, | |
622 | DEV_CLIENT_MASK, | |
623 | struct dev_mask2_info_s), | |
624 | PVFS_DEV_CLIENT_STRING = _IOW(PVFS_DEV_MAGIC, | |
625 | DEV_CLIENT_STRING, | |
626 | char *), | |
627 | PVFS_DEV_MAXNR = DEV_MAX_NR, | |
628 | }; | |
629 | ||
630 | /* | |
631 | * version number for use in communicating between kernel space and user | |
632 | * space | |
633 | */ | |
634 | /* | |
635 | #define PVFS_KERNEL_PROTO_VERSION \ | |
636 | ((PVFS2_VERSION_MAJOR * 10000) + \ | |
637 | (PVFS2_VERSION_MINOR * 100) + \ | |
638 | PVFS2_VERSION_SUB) | |
639 | */ | |
640 | #define PVFS_KERNEL_PROTO_VERSION 0 | |
641 | ||
642 | /* | |
643 | * describes memory regions to map in the PVFS_DEV_MAP ioctl. | |
644 | * NOTE: See devpvfs2-req.c for 32 bit compat structure. | |
645 | * Since this structure has a variable-sized layout that is different | |
646 | * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout | |
647 | * on such systems before servicing ioctl calls from user-space binaries | |
648 | * that may be 32 bit! | |
649 | */ | |
650 | struct PVFS_dev_map_desc { | |
651 | void *ptr; | |
652 | __s32 total_size; | |
653 | __s32 size; | |
654 | __s32 count; | |
655 | }; | |
656 | ||
657 | /* gossip.h *****************************************************************/ | |
658 | ||
659 | #ifdef GOSSIP_DISABLE_DEBUG | |
660 | #define gossip_debug(mask, format, f...) do {} while (0) | |
661 | #else | |
662 | extern __u64 gossip_debug_mask; | |
663 | extern struct client_debug_mask client_debug_mask; | |
664 | ||
665 | /* try to avoid function call overhead by checking masks in macro */ | |
666 | #define gossip_debug(mask, format, f...) \ | |
667 | do { \ | |
668 | if (gossip_debug_mask & mask) \ | |
669 | printk(format, ##f); \ | |
670 | } while (0) | |
671 | #endif /* GOSSIP_DISABLE_DEBUG */ | |
672 | ||
673 | /* do file and line number printouts w/ the GNU preprocessor */ | |
674 | #define gossip_ldebug(mask, format, f...) \ | |
675 | gossip_debug(mask, "%s: " format, __func__, ##f) | |
676 | ||
677 | #define gossip_err printk | |
678 | #define gossip_lerr(format, f...) \ | |
679 | gossip_err("%s line %d: " format, \ | |
680 | __FILE__, \ | |
681 | __LINE__, \ | |
682 | ##f) |