1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
21 * User-space Lustre headers.
30 #include <sys/ioctl.h>
38 #include <portals/list.h>
39 #include <portals/p30.h>
41 /* definitions for liblustre */
43 /* always adopt 2.5 definitions */
44 #define LINUX_VERSION_CODE 1
45 #define KERNEL_VERSION(a,b,c) 0
47 static inline void inter_module_put(void *a)
52 extern ptl_handle_ni_t tcpnal_ni;
54 static inline void *inter_module_get(char *arg)
57 if (strcmp(arg, "tcpnal_ni") == 0 )
68 void (*ws_task)(void *arg);
72 static inline void prepare_work(struct work_struct *q, void (*t)(void *),
80 static inline void schedule_work(struct work_struct *q)
82 q->ws_task(q->ws_arg);
86 #define strnlen(a,b) strlen(a)
87 static inline void *kmalloc(int size, int prot)
91 #define vmalloc malloc
93 #define kfree(a) free(a)
95 #define GFP_HIGHUSER 1
96 #define IS_ERR(a) (((a) && abs((int)(a)) < 500) ? 1 : 0)
97 #define PTR_ERR(a) ((int)(a))
99 #define capable(foo) 1
100 #define CAP_SYS_ADMIN 1
107 typedef void *read_proc_t;
108 typedef void *write_proc_t;
117 static inline void MODULE_AUTHOR(char *name)
119 printf("%s\n", name);
121 #define MODULE_DESCRIPTION(name) MODULE_AUTHOR(name)
122 #define MODULE_LICENSE(name) MODULE_AUTHOR(name)
124 #define THIS_MODULE NULL
130 static inline int misc_register(void *foo)
134 #define misc_deregister misc_register
136 #define __MOD_INC_USE_COUNT(m) do {int a = 1; a++; } while (0)
137 #define __MOD_DEC_USE_COUNT(m) do {int a = 1; a++; } while (0)
138 #define MOD_INC_USE_COUNT do {int a = 1; a++; } while (0)
139 #define MOD_DEC_USE_COUNT do {int a = 1; a++; } while (0)
141 /* module initialization */
142 extern int init_obdclass(void);
143 extern int ptlrpc_init(void);
144 extern int ldlm_init(void);
145 extern int osc_init(void);
146 extern int lov_init(void);
147 extern int echo_client_init(void);
154 #define EXPORT_SYMBOL(S)
156 typedef int spinlock_t;
157 typedef __u64 kdev_t;
159 #define SPIN_LOCK_UNLOCKED 0
160 #define spin_lock(l) do {int a = 1; a++; } while (0)
161 #define spin_unlock(l) do {int a= 1; a++; } while (0)
162 #define spin_lock_init(l) do {int a= 1; a++; } while (0)
163 static inline void spin_lock_bh(spinlock_t *l)
167 static inline void spin_unlock_bh(spinlock_t *l)
171 static inline void spin_lock_irqrestore(a,b)
175 static inline void spin_unlock_irqrestore(a,b)
179 static inline void spin_lock_irqsave(a,b)
184 #define barrier() do {int a= 1; a++; } while (0)
186 /* registering symbols */
188 #define ERESTARTSYS ERESTART
193 static inline void get_random_bytes(void *ptr, int size)
197 int *end = p + (size / sizeof(int));
199 while ( p + sizeof(int) < end ) {
207 static inline int copy_from_user(void *a,void *b, int c)
213 static inline int copy_to_user(void *a,void *b, int c)
224 #define SLAB_HWCACHE_ALIGN 0
225 static inline kmem_cache_t *kmem_cache_create(name,objsize,cdum,d,e,f)
228 c = malloc(sizeof(*c));
235 static inline int kmem_cache_destroy(kmem_cache_t *a)
240 #define kmem_cache_validate(a,b) 1
241 #define kmem_cache_alloc(cache, prio) malloc(cache->size)
242 #define kmem_cache_free(cache, obj) OBD_FREE(obj, cache->size)
243 #define PORTAL_SLAB_ALLOC(lock,cache,size) do { lock = kmem_cache_alloc(cache,prio); } while (0)
244 #define PORTAL_SLAB_FREE(lock,cache,size) do { lock = kmem_cache_alloc(cache,prio); } while (0)
251 #define kmap(page) (page)->addr
252 #define kunmap(a) do { int foo = 1; foo++; } while (0)
254 static inline struct page *alloc_pages(mask,foo)
256 struct page *pg = malloc(sizeof(*pg));
261 pg->addr = mmap(0, PAGE_SIZE, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
263 pg->addr = malloc(PAGE_SIZE);
273 static inline void __free_pages(struct page *pg, int what)
276 munmap(pg->addr, PAGE_SIZE);
284 #define do_div(a,b) (a)/(b)
286 /* dentries / intents */
287 struct lookup_intent {
299 struct dentry *f_dentry;
306 #define cpu_to_le32(x) ((__u32)(x))
313 #define down(a) do {(a)->count++;} while (0)
314 #define up(a) do {(a)->count--;} while (0)
315 #define sema_init(a,b) do { (a)->count = b; } while (0)
318 struct list_head sleepers;
322 struct list_head sleeping;
332 struct signal pending;
337 extern struct task_struct *current;
341 #define set_current_state(foo) do { current->state = foo; } while (0)
343 #define init_waitqueue_entry(q,p) do { (q)->process = p; } while (0)
344 #define add_wait_queue(q,p) do { list_add(&(q)->sleepers, &(p)->sleeping); } while (0)
345 #define del_wait_queue(p) do { list_del(&(p)->sleeping); } while (0)
346 #define remove_wait_queue(q,p) do { list_del(&(p)->sleeping); } while (0)
348 #define init_waitqueue_head(l) INIT_LIST_HEAD(&(l)->sleepers)
349 #define wake_up(l) do { int a; a++; } while (0)
350 #define TASK_INTERRUPTIBLE 0
351 #define TASK_UNINTERRUPTIBLE 1
352 #define TASK_RUNNING 2
355 #define schedule() do { int a; a++; } while (0)
356 static inline int schedule_timeout(t)
361 #define lock_kernel() do { int a; a++; } while (0)
362 #define daemonize(l) do { int a; a++; } while (0)
363 #define sigfillset(l) do { int a; a++; } while (0)
364 #define recalc_sigpending(l) do { int a; a++; } while (0)
365 #define kernel_thread(l,m,n)
367 static inline int call_usermodehelper(char *prog, char **argv, char **evnp)
379 struct list_head tl_list;
380 void (*function)(unsigned long unused);
385 static inline int timer_pending(struct timer_list *l)
387 if (l->expires > jiffies)
393 static inline int init_timer(struct timer_list *l)
395 INIT_LIST_HEAD(&l->tl_list);
399 static inline void mod_timer(struct timer_list *l, int thetime)
401 l->expires = thetime;
404 static inline void del_timer(struct timer_list *l)
409 typedef struct { volatile int counter; } atomic_t;
411 #define atomic_read(a) ((a)->counter)
412 #define atomic_set(a,b) do {(a)->counter = b; } while (0)
413 #define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
414 #define atomic_inc(a) (((a)->counter)++)
415 #define atomic_dec(a) do { (a)->counter--; } while (0)
416 #define atomic_add(b,a) do {(a)->counter += b;} while (0)
417 #define atomic_sub(b,a) do {(a)->counter -= b;} while (0)
419 #define LBUG() do { sleep(1000000); } while (0)
421 #include <linux/obd_support.h>
422 #include <linux/lustre_idl.h>
423 #include <linux/lustre_lib.h>
424 #include <linux/lustre_import.h>
425 #include <linux/lustre_export.h>
426 #include <linux/lustre_net.h>