Whamcloud - gitweb
Branch b1_4_newconfig2
[fs/lustre-release.git] / lustre / include / liblustre.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * User-space Lustre headers.
22  *
23  */
24 #ifndef LIBLUSTRE_H__
25 #define LIBLUSTRE_H__
26
27 #ifdef __KERNEL__
28 #error Kernel files should not #include <liblustre.h>
29 #else
30 /*
31  * The userspace implementations of linux/spinlock.h vary; we just
32  * include our own for all of them
33  */
34 #define __LINUX_SPINLOCK_H
35 #endif
36
37 #include <sys/mman.h>
38 #ifdef HAVE_STDINT_H
39 # include <stdint.h>
40 #endif
41 #ifdef HAVE_ASM_PAGE_H
42 # include <asm/page.h>
43 #endif
44 #ifdef HAVE_SYS_USER_H
45 # include <sys/user.h>
46 #endif
47 #ifdef HAVE_SYS_IOCTL_H
48 # include <sys/ioctl.h>
49 #endif
50 #ifndef _IOWR
51 # include "ioctl.h"
52 #endif
53
54 #include <stdio.h>
55 #include <sys/ioctl.h>
56 #include <stdlib.h>
57 #include <string.h>
58 #include <errno.h>
59 #include <sys/stat.h>
60 #include <sys/vfs.h>
61 #include <unistd.h>
62 #include <fcntl.h>
63
64 #include <libcfs/list.h>
65 #include <portals/p30.h>
66 #include <libcfs/kp30.h>
67
68 /* definitions for liblustre */
69
70 #ifdef __CYGWIN__
71
72 #define PAGE_SHIFT 12
73 #define PAGE_SIZE (1UL << PAGE_SHIFT)
74 #define PAGE_MASK (~(PAGE_SIZE-1))
75 #define loff_t long long
76 #define ERESTART 2001
77 typedef unsigned short umode_t;
78
79 #endif
80
81 #ifndef CURRENT_SECONDS
82 # define CURRENT_SECONDS time(0)
83 #endif
84
85 /* This is because lprocfs_status.h gets included here indirectly.  It would
86  * be much better to just avoid lprocfs being included into liblustre entirely
87  * but that requires more header surgery than I can handle right now.
88  */
89 #ifndef smp_processor_id
90 #define smp_processor_id() 0
91 #endif
92
93 /* always adopt 2.5 definitions */
94 #define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
95 #define LINUX_VERSION_CODE KERNEL_VERSION(2,5,0)
96
97 static inline void inter_module_put(void *a)
98 {
99         return;
100 }
101
102 void *inter_module_get(char *arg);
103
104 /* cheats for now */
105
106 struct work_struct {
107         void (*ws_task)(void *arg);
108         void *ws_arg;
109 };
110
111 static inline void prepare_work(struct work_struct *q, void (*t)(void *),
112                                 void *arg)
113 {
114         q->ws_task = t;
115         q->ws_arg = arg;
116         return;
117 }
118
119 static inline void schedule_work(struct work_struct *q)
120 {
121         q->ws_task(q->ws_arg);
122 }
123
124
125 #define strnlen(a,b) strlen(a)
126 static inline void *kmalloc(int size, int prot)
127 {
128         return malloc(size);
129 }
130 #define vmalloc malloc
131 #define vfree free
132 #define kfree(a) free(a)
133 #define GFP_KERNEL 1
134 #define GFP_HIGHUSER 1
135 #define GFP_ATOMIC 1
136 #define GFP_NOFS 1
137 #define IS_ERR(a) (((a) && abs((long)(a)) < 500) ? 1 : 0)
138 #define PTR_ERR(a) ((long)(a))
139 #define ERR_PTR(a) ((void*)((long)(a)))
140
141 typedef struct {
142         void *cwd;
143 }mm_segment_t;
144
145 typedef int (read_proc_t)(char *page, char **start, off_t off,
146                           int count, int *eof, void *data);
147
148 struct file; /* forward ref */
149 typedef int (write_proc_t)(struct file *file, const char *buffer,
150                            unsigned long count, void *data);
151
152 #define NIPQUAD(addr) \
153         ((unsigned char *)&addr)[0], \
154         ((unsigned char *)&addr)[1], \
155         ((unsigned char *)&addr)[2], \
156         ((unsigned char *)&addr)[3]
157
158 #if defined(__LITTLE_ENDIAN)
159 #define HIPQUAD(addr) \
160         ((unsigned char *)&addr)[3], \
161         ((unsigned char *)&addr)[2], \
162         ((unsigned char *)&addr)[1], \
163         ((unsigned char *)&addr)[0]
164 #elif defined(__BIG_ENDIAN)
165 #define HIPQUAD NIPQUAD
166 #else
167 #error "Undefined byteorder??"
168 #endif /* __LITTLE_ENDIAN */
169
170 /* bits ops */
171
172 /* a long can be more than 32 bits, so use BITS_PER_LONG
173  * to allow the compiler to adjust the bit shifting accordingly
174  */
175
176 /* test if bit nr is set in bitmap addr; returns previous value of bit nr */
177 static __inline__ int set_bit(int nr, long * addr)
178 {
179         long    mask;
180
181         addr += nr / BITS_PER_LONG;
182         mask = 1UL << (nr & (BITS_PER_LONG - 1));
183         nr = (mask & *addr) != 0;
184         *addr |= mask;
185         return nr;
186 }
187
188 /* clear bit nr in bitmap addr; returns previous value of bit nr*/
189 static __inline__ int clear_bit(int nr, long * addr)
190 {
191         long    mask;
192
193         addr += nr / BITS_PER_LONG;
194         mask = 1UL << (nr & (BITS_PER_LONG - 1));
195         nr = (mask & *addr) != 0;
196         *addr &= ~mask;
197         return nr;
198 }
199
200 static __inline__ int test_bit(int nr, long * addr)
201 {
202         return ((1UL << (nr & (BITS_PER_LONG - 1))) & ((addr)[nr / BITS_PER_LONG])) != 0;
203 }
204
205 static __inline__ int ext2_set_bit(int nr, void *addr)
206 {
207         return set_bit(nr, (long*)addr);
208 }
209
210 static __inline__ int ext2_clear_bit(int nr, void *addr)
211 {
212         return clear_bit(nr, (long*)addr);
213 }
214
215 static __inline__ int ext2_test_bit(int nr, void *addr)
216 {
217         return test_bit(nr, (long*)addr);
218 }
219
220 /* modules */
221
222 struct module {
223         int count;
224 };
225
226 static inline void MODULE_AUTHOR(char *name)
227 {
228         printf("%s\n", name);
229 }
230 #define MODULE_DESCRIPTION(name) MODULE_AUTHOR(name)
231 #define MODULE_LICENSE(name) MODULE_AUTHOR(name)
232
233 #define THIS_MODULE NULL
234 #define __init
235 #define __exit
236
237 /* devices */
238
239 static inline int misc_register(void *foo)
240 {
241         return 0;
242 }
243
244 static inline int misc_deregister(void *foo)
245 {
246         return 0;
247 }
248
249 static inline int request_module(char *name)
250 {
251         return (-EINVAL);
252 }
253
254 #define __MOD_INC_USE_COUNT(m)  do {} while (0)
255 #define __MOD_DEC_USE_COUNT(m)  do {} while (0)
256 #define MOD_INC_USE_COUNT       do {} while (0)
257 #define MOD_DEC_USE_COUNT       do {} while (0)
258 static inline void __module_get(struct module *module)
259 {
260 }
261
262 static inline int try_module_get(struct module *module)
263 {
264         return 1;
265 }
266
267 static inline void module_put(struct module *module)
268 {
269 }
270
271 /* module initialization */
272 extern int init_obdclass(void);
273 extern int ptlrpc_init(void);
274 extern int ldlm_init(void);
275 extern int osc_init(void);
276 extern int lov_init(void);
277 extern int mdc_init(void);
278 extern int echo_client_init(void);
279
280
281
282 /* general stuff */
283
284 #define EXPORT_SYMBOL(S)
285
286 typedef struct { } spinlock_t;
287 typedef __u64 kdev_t;
288
289 #define SPIN_LOCK_UNLOCKED (spinlock_t) { }
290 #define LASSERT_SPIN_LOCKED(lock) do {} while(0)
291
292 static inline void spin_lock(spinlock_t *l) {return;}
293 static inline void spin_unlock(spinlock_t *l) {return;}
294 static inline void spin_lock_init(spinlock_t *l) {return;}
295 static inline void local_irq_save(unsigned long flag) {return;}
296 static inline void local_irq_restore(unsigned long flag) {return;}
297 static inline int spin_is_locked(spinlock_t *l) {return 1;}
298
299 static inline void spin_lock_bh(spinlock_t *l) {}
300 static inline void spin_unlock_bh(spinlock_t *l) {}
301 static inline void spin_lock_irqsave(spinlock_t *a, unsigned long b) {}
302 static inline void spin_unlock_irqrestore(spinlock_t *a, unsigned long b) {}
303
304 #define min(x,y) ((x)<(y) ? (x) : (y))
305 #define max(x,y) ((x)>(y) ? (x) : (y))
306
307 #ifndef min_t
308 #define min_t(type,x,y) \
309         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
310 #endif
311 #ifndef max_t
312 #define max_t(type,x,y) \
313         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
314 #endif
315
316 /* registering symbols */
317 #ifndef ERESTARTSYS
318 #define ERESTARTSYS ERESTART
319 #endif
320 #define HZ 1
321
322 /* random */
323
324 void get_random_bytes(void *ptr, int size);
325
326 /* memory */
327
328 /* FIXME */
329 #define num_physpages (16 * 1024)
330
331 static inline int copy_from_user(void *a,void *b, int c)
332 {
333         memcpy(a,b,c);
334         return 0;
335 }
336
337 static inline int copy_to_user(void *a,void *b, int c)
338 {
339         memcpy(a,b,c);
340         return 0;
341 }
342
343
344 /* slabs */
345 typedef struct {
346          int size;
347 } kmem_cache_t;
348 #define SLAB_HWCACHE_ALIGN 0
349 static inline kmem_cache_t *
350 kmem_cache_create(const char *name, size_t objsize, size_t cdum,
351                   unsigned long d,
352                   void (*e)(void *, kmem_cache_t *, unsigned long),
353                   void (*f)(void *, kmem_cache_t *, unsigned long))
354 {
355         kmem_cache_t *c;
356         c = malloc(sizeof(*c));
357         if (!c)
358                 return NULL;
359         c->size = objsize;
360         CDEBUG(D_MALLOC, "alloc slab cache %s at %p, objsize %d\n",
361                name, c, (int)objsize);
362         return c;
363 };
364
365 static inline int kmem_cache_destroy(kmem_cache_t *a)
366 {
367         CDEBUG(D_MALLOC, "destroy slab cache %p, objsize %u\n", a, a->size);
368         free(a);
369         return 0;
370 }
371 #define kmem_cache_alloc(cache, prio) malloc(cache->size)
372 #define kmem_cache_free(cache, obj) free(obj)
373
374 #define PAGE_CACHE_SIZE  PAGE_SIZE
375 #define PAGE_CACHE_SHIFT PAGE_SHIFT
376 #define PAGE_CACHE_MASK  PAGE_MASK
377
378 /* struct page decl moved out from here into portals/include/libcfs/user-prim.h */
379
380 /* 2.4 defines */
381 #define PAGE_LIST_ENTRY list
382 #define PAGE_LIST(page) ((page)->list)
383
384 #define kmap(page) (page)->addr
385 #define kunmap(a) do {} while (0)
386
387 static inline struct page *alloc_pages(int mask, unsigned long order)
388 {
389         struct page *pg = malloc(sizeof(*pg));
390
391         if (!pg)
392                 return NULL;
393 #if 0 //#ifdef MAP_ANONYMOUS
394         pg->addr = mmap(0, PAGE_SIZE << order, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
395 #else
396         pg->addr = malloc(PAGE_SIZE << order);
397 #endif
398
399         if (!pg->addr) {
400                 free(pg);
401                 return NULL;
402         }
403         return pg;
404 }
405
406 #define alloc_page(mask) alloc_pages((mask), 0)
407
408 static inline void __free_pages(struct page *pg, int what)
409 {
410 #if 0 //#ifdef MAP_ANONYMOUS
411         munmap(pg->addr, PAGE_SIZE);
412 #else
413         free(pg->addr);
414 #endif
415         free(pg);
416 }
417
418 #define __free_page(page) __free_pages((page), 0)
419 #define free_page(page) __free_page(page)
420
421 static inline struct page* __grab_cache_page(unsigned long index)
422 {
423         struct page *pg = alloc_pages(0, 0);
424
425         if (pg)
426                 pg->index = index;
427         return pg;
428 }
429
430 #define grab_cache_page(index) __grab_cache_page(index)
431 #define page_cache_release(page) __free_pages(page, 0)
432
433 /* arithmetic */
434 #define do_div(a,b)                     \
435         ({                              \
436                 unsigned long remainder;\
437                 remainder = (a) % (b);  \
438                 (a) = (a) / (b);        \
439                 (remainder);            \
440         })
441
442 /* VFS stuff */
443 #define ATTR_MODE       0x0001
444 #define ATTR_UID        0x0002
445 #define ATTR_GID        0x0004
446 #define ATTR_SIZE       0x0008
447 #define ATTR_ATIME      0x0010
448 #define ATTR_MTIME      0x0020
449 #define ATTR_CTIME      0x0040
450 #define ATTR_ATIME_SET  0x0080
451 #define ATTR_MTIME_SET  0x0100
452 #define ATTR_FORCE      0x0200  /* Not a change, but a change it */
453 #define ATTR_ATTR_FLAG  0x0400
454 #define ATTR_RAW        0x0800  /* file system, not vfs will massage attrs */
455 #define ATTR_FROM_OPEN  0x1000  /* called from open path, ie O_TRUNC */
456 #define ATTR_CTIME_SET  0x2000
457
458 struct iattr {
459         unsigned int    ia_valid;
460         umode_t         ia_mode;
461         uid_t           ia_uid;
462         gid_t           ia_gid;
463         loff_t          ia_size;
464         time_t          ia_atime;
465         time_t          ia_mtime;
466         time_t          ia_ctime;
467         unsigned int    ia_attr_flags;
468 };
469
470 #define IT_OPEN     0x0001
471 #define IT_CREAT    0x0002
472 #define IT_READDIR  0x0004
473 #define IT_GETATTR  0x0008
474 #define IT_LOOKUP   0x0010
475 #define IT_UNLINK   0x0020
476 #define IT_GETXATTR 0x0040
477 #define IT_EXEC     0x0080
478 #define IT_PIN      0x0100
479
480 #define IT_FL_LOCKED   0x0001
481 #define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
482
483 #define INTENT_MAGIC 0x19620323
484
485 struct lustre_intent_data {
486         int       it_disposition;
487         int       it_status;
488         __u64     it_lock_handle;
489         void     *it_data;
490         int       it_lock_mode;
491         int it_int_flags;
492 };
493 struct lookup_intent {
494         int     it_magic;
495         void    (*it_op_release)(struct lookup_intent *);
496         int     it_op;
497         int     it_flags;
498         int     it_create_mode;
499         union {
500                 struct lustre_intent_data lustre;
501         } d;
502 };
503
504 static inline void intent_init(struct lookup_intent *it, int op, int flags)
505 {
506         memset(it, 0, sizeof(*it));
507         it->it_magic = INTENT_MAGIC;
508         it->it_op = op;
509         it->it_flags = flags;
510 }
511
512
513 struct dentry {
514         int d_count;
515 };
516
517 struct vfsmount {
518         void *pwd;
519 };
520
521 /* semaphores */
522 struct rw_semaphore {
523         int count;
524 };
525
526 /* semaphores */
527 struct semaphore {
528         int count;
529 };
530
531 /* use the macro's argument to avoid unused warnings */
532 #define down(a) do { (void)a; } while (0)
533 #define up(a) do { (void)a; } while (0)
534 #define down_read(a) do { (void)a; } while (0)
535 #define up_read(a) do { (void)a; } while (0)
536 #define down_write(a) do { (void)a; } while (0)
537 #define up_write(a) do { (void)a; } while (0)
538 #define sema_init(a,b) do { (void)a; } while (0)
539 #define init_rwsem(a) do { (void)a; } while (0)
540 #define DECLARE_MUTEX(name)     \
541         struct semaphore name = { 1 }
542 static inline void init_MUTEX (struct semaphore *sem)
543 {
544         sema_init(sem, 1);
545 }
546
547
548 typedef struct  {
549         struct list_head sleepers;
550 } wait_queue_head_t;
551
552 typedef struct  {
553         struct list_head sleeping;
554         void *process;
555 } wait_queue_t;
556
557 struct signal {
558         int signal;
559 };
560
561 struct task_struct {
562         int state;
563         struct signal pending;
564         char comm[32];
565         int pid;
566         int fsuid;
567         int fsgid;
568         int max_groups;
569         int ngroups;
570         gid_t *groups;
571         __u32 cap_effective;
572 };
573
574 extern struct task_struct *current;
575 int in_group_p(gid_t gid);
576 static inline int capable(int cap)
577 {
578         if (current->cap_effective & (1 << cap))
579                 return 1;
580         else
581                 return 0;
582 }
583
584 #define set_current_state(foo) do { current->state = foo; } while (0)
585
586 #define init_waitqueue_entry(q,p) do { (q)->process = p; } while (0)
587 #define add_wait_queue(q,p) do {  list_add(&(q)->sleepers, &(p)->sleeping); } while (0)
588 #define del_wait_queue(p) do { list_del(&(p)->sleeping); } while (0)
589 #define remove_wait_queue(q,p) do { list_del(&(p)->sleeping); } while (0)
590
591 #define DECLARE_WAIT_QUEUE_HEAD(HEAD)                           \
592         wait_queue_head_t HEAD = {                              \
593                 .sleepers = LIST_HEAD_INIT(HEAD.sleepers)       \
594         }
595 #define init_waitqueue_head(l) INIT_LIST_HEAD(&(l)->sleepers)
596 #define wake_up(l) do { int a; a++; } while (0)
597 #define TASK_INTERRUPTIBLE 0
598 #define TASK_UNINTERRUPTIBLE 1
599 #define TASK_RUNNING 2
600
601 #define wait_event_interruptible(wq, condition)                         \
602 ({                                                                      \
603         struct l_wait_info lwi;                                         \
604         int timeout = 100000000;/* for ever */                          \
605         int ret;                                                        \
606                                                                         \
607         lwi = LWI_TIMEOUT(timeout, NULL, NULL);                         \
608         ret = l_wait_event(NULL, condition, &lwi);                      \
609                                                                         \
610         ret;                                                            \
611 })
612
613 #define in_interrupt() (0)
614
615 #define schedule() do {} while (0)
616 static inline int schedule_timeout(signed long t)
617 {
618         return 0;
619 }
620
621 #define lock_kernel() do {} while (0)
622 #define unlock_kernel() do {} while (0)
623 #define daemonize(l) do {} while (0)
624 #define sigfillset(l) do {} while (0)
625 #define recalc_sigpending(l) do {} while (0)
626 #define kernel_thread(l,m,n) LBUG()
627
628 #define USERMODEHELPER(path, argv, envp) (0)
629 #define SIGNAL_MASK_ASSERT()
630 #define KERN_INFO
631
632 #include <sys/time.h>
633 #if HZ != 1
634 #error "liblustre's jiffies currently expects HZ to be 1"
635 #endif
636 #define jiffies                                 \
637 ({                                              \
638         unsigned long _ret = 0;                 \
639         struct timeval tv;                      \
640         if (gettimeofday(&tv, NULL) == 0)       \
641                 _ret = tv.tv_sec;               \
642         _ret;                                   \
643 })
644 #define time_after(a, b) ((long)(b) - (long)(a) < 0)
645 #define time_before(a, b) time_after(b,a)
646 #define time_after_eq(a,b)      ((long)(a) - (long)(b) >= 0)
647
648 struct timer_list {
649         struct list_head tl_list;
650         void (*function)(unsigned long unused);
651         unsigned long data;
652         long expires;
653 };
654
655 static inline int timer_pending(struct timer_list *l)
656 {
657         if (time_after(l->expires, jiffies))
658                 return 1;
659         else
660                 return 0;
661 }
662
663 static inline int init_timer(struct timer_list *l)
664 {
665         INIT_LIST_HEAD(&l->tl_list);
666         return 0;
667 }
668
669 static inline void mod_timer(struct timer_list *l, int thetime)
670 {
671         l->expires = thetime;
672 }
673
674 static inline void del_timer(struct timer_list *l)
675 {
676         free(l);
677 }
678
679 typedef struct { volatile int counter; } atomic_t;
680
681 #define atomic_read(a) ((a)->counter)
682 #define atomic_set(a,b) do {(a)->counter = b; } while (0)
683 #define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
684 #define atomic_inc(a)  (((a)->counter)++)
685 #define atomic_dec(a)  do { (a)->counter--; } while (0)
686 #define atomic_add(b,a)  do {(a)->counter += b;} while (0)
687 #define atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
688
689 #ifndef likely
690 #define likely(exp) (exp)
691 #endif
692 #ifndef unlikely
693 #define unlikely(exp) (exp)
694 #endif
695
696 /* FIXME sys/capability will finally included linux/fs.h thus
697  * cause numerous trouble on x86-64. as temporary solution for
698  * build broken at cary, we copy definition we need from capability.h
699  * FIXME
700  */
701 struct _cap_struct;
702 typedef struct _cap_struct *cap_t;
703 typedef int cap_value_t;
704 typedef enum {
705     CAP_EFFECTIVE=0,
706     CAP_PERMITTED=1,
707     CAP_INHERITABLE=2
708 } cap_flag_t;
709 typedef enum {
710     CAP_CLEAR=0,
711     CAP_SET=1
712 } cap_flag_value_t;
713
714 #define CAP_DAC_OVERRIDE        1
715 #define CAP_DAC_READ_SEARCH     2
716 #define CAP_FOWNER              3
717 #define CAP_FSETID              4
718 #define CAP_SYS_ADMIN          21
719
720 cap_t   cap_get_proc(void);
721 int     cap_get_flag(cap_t, cap_value_t, cap_flag_t, cap_flag_value_t *);
722
723 /* log related */
724 static inline int llog_init_commit_master(void) { return 0; }
725 static inline int llog_cleanup_commit_master(int force) { return 0; }
726 static inline void portals_run_lbug_upcall(char *file, const char *fn,
727                                            const int l){}
728
729 /* completion */
730 struct completion {
731         unsigned int done;
732         wait_queue_head_t wait;
733 };
734
735 #define COMPLETION_INITIALIZER(work) \
736         { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
737
738 #define DECLARE_COMPLETION(work) \
739         struct completion work = COMPLETION_INITIALIZER(work)
740
741 #define INIT_COMPLETION(x)      ((x).done = 0)
742
743 static inline void init_completion(struct completion *x)
744 {
745         x->done = 0;
746         init_waitqueue_head(&x->wait);
747 }
748
749 struct liblustre_wait_callback {
750         struct list_head    llwc_list;
751         int               (*llwc_fn)(void *arg);
752         void               *llwc_arg;
753 };
754
755 void *liblustre_register_wait_callback(int (*fn)(void *arg), void *arg);
756 void liblustre_deregister_wait_callback(void *notifier);
757 int liblustre_wait_event(int timeout);
758
759 /* flock related */
760 struct nfs_lock_info {
761         __u32             state;
762         __u32             flags;
763         void            *host;
764 };
765
766 struct file_lock {
767         struct file_lock *fl_next;      /* singly linked list for this inode  */
768         struct list_head fl_link;       /* doubly linked list of all locks */
769         struct list_head fl_block;      /* circular list of blocked processes */
770         void *fl_owner;
771         unsigned int fl_pid;
772         wait_queue_head_t fl_wait;
773         struct file *fl_file;
774         unsigned char fl_flags;
775         unsigned char fl_type;
776         loff_t fl_start;
777         loff_t fl_end;
778
779         void (*fl_notify)(struct file_lock *);  /* unblock callback */
780         void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
781         void (*fl_remove)(struct file_lock *);  /* lock removal callback */
782
783         void *fl_fasync; /* for lease break notifications */
784         unsigned long fl_break_time;    /* for nonblocking lease breaks */
785
786         union {
787                 struct nfs_lock_info    nfs_fl;       
788         } fl_u;
789 };
790
791 #ifndef OFFSET_MAX
792 #define INT_LIMIT(x)    (~((x)1 << (sizeof(x)*8 - 1)))
793 #define OFFSET_MAX      INT_LIMIT(loff_t)
794 #endif
795
796 /* XXX: defined in kernel */
797 #define FL_POSIX        1
798 #define FL_SLEEP        128
799
800 /* quota */
801 #define QUOTA_OK 0
802 #define NO_QUOTA 1
803
804 /* proc */
805 #define proc_symlink(...)                       \
806 ({                                              \
807         void *result = NULL;                    \
808         result;                                 \
809 })
810
811 #ifndef ENOTSUPP
812 #define ENOTSUPP ENOTSUP
813 #endif
814
815 #include <linux/obd_support.h>
816 #include <linux/lustre_idl.h>
817 #include <linux/lustre_lib.h>
818 #include <linux/lustre_import.h>
819 #include <linux/lustre_export.h>
820 #include <linux/lustre_net.h>
821
822 #endif