From 32f00fdfc6eb708c98b7dd4bad262e29633c49d1 Mon Sep 17 00:00:00 2001 From: pschwan Date: Mon, 17 Feb 2003 18:42:56 +0000 Subject: [PATCH] merge b_devel into b_setattr. highlights: - kernel 2.5 and liblustre build changes - fixes to Makefile.am for 7.3-era versions of automake, which is quite possibly the worst piece of software with which I come in contact on a daily basis - small unlink fix --- lustre/include/liblustre.h | 338 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 338 insertions(+) create mode 100644 lustre/include/liblustre.h diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h new file mode 100644 index 0000000..7804610 --- /dev/null +++ b/lustre/include/liblustre.h @@ -0,0 +1,338 @@ +#ifndef LIBLUSTRE_H__ +#define LIBLUSTRE_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* definitions for liblustre */ + +/* always adopt 2.5 definitions */ +#define LINUX_VERSION_CODE 1 +#define KERNEL_VERSION(a,b,c) 0 + +/* cheats for now */ + +struct work_struct { + void (*ws_task)(void *arg); + void *ws_arg; +}; + +static inline void prepare_work(struct work_struct *q, void (*t)(void *), + void *arg) +{ + q->ws_task = t; + q->ws_arg = arg; + return; +} + +static inline void schedule_work(struct work_struct *q) +{ + q->ws_task(q->ws_arg); +} + + +#define strnlen(a,b) strlen(a) +#define kmalloc(a,b) malloc(a) +#define vmalloc malloc +#define vfree free +#define kfree(a) free(a) +#define GFP_KERNEL 1 +#define GFP_HIGHUSER 1 +#define IS_ERR(a) (abs((int)(a)) < 500 ? 1 : 0) +#define PTR_ERR(a) ((int)(a)) + +#define capable(foo) 1 +#define CAP_SYS_ADMIN 1 + +typedef struct { + void *cwd; + +}mm_segment_t; + +typedef void *read_proc_t; +typedef void *write_proc_t; + + +/* modules */ + +struct module { + int count; +}; + +static inline void MODULE_AUTHOR(char *name) +{ + printf("%s\n", name); +} +#define MODULE_DESCRIPTION(name) MODULE_AUTHOR(name) +#define MODULE_LICENSE(name) MODULE_AUTHOR(name) + +#define THIS_MODULE NULL +#define __init +#define __exit + +/* devices */ + +static inline int misc_register(void *foo) +{ + return 0; +} +#define misc_deregister misc_register + +#define __MOD_INC_USE_COUNT(m) (m->count++) +#define __MOD_DEC_USE_COUNT(m) (m->count--) +#define MOD_INC_USE_COUNT do {int a = 1; a++; } while (0) +#define MOD_DEC_USE_COUNT do {int a = 1; a++; } while (0) + +/* general stuff */ + +#define EXPORT_SYMBOL(S) + +typedef int spinlock_t; +typedef __u64 kdev_t; + +#define SPIN_LOCK_UNLOCKED 0 +#define spin_lock(l) do {int a = 1; a++; } while (0) +#define spin_unlock(l) do {int a= 1; a++; } while (0) +#define spin_lock_init(l) do {int a= 1; a++; } while (0) +static inline void spin_lock_irqrestore(a,b) +{ + return; +} +static inline void spin_unlock_irqrestore(a,b) +{ + return; +} +static inline void spin_lock_irqsave(a,b) +{ + return; +} + +#define barrier() do {int a= 1; a++; } while (0) + +/* registering symbols */ +extern void *inter_module_get(char *name); +extern void inter_module_put(char *name); + +#define ERESTARTSYS ERESTART +#define HZ 1 + +/* random */ + +static inline void get_random_bytes(void *ptr, int size) +{ + static int r; + int *p = (int *)ptr; + int *end = p + (size / sizeof(int)); + r = rand(); + while ( p + sizeof(int) < end ) { + *p = r; + p++; + } +} + +/* memory */ + +static inline int copy_from_user(void *a,void *b, int c) +{ + memcpy(a,b,c); + return 0; +} + +static inline int copy_to_user(void *a,void *b, int c) +{ + memcpy(a,b,c); + return 0; +} + + +/* slabs */ +typedef struct { + int size; +} kmem_cache_t; + +static inline kmem_cache_t *kmem_cache_create(name,objsize,c,d,e,f) +{ + return malloc(objsize); +}; + +static inline int kmem_cache_destroy(kmem_cache_t *a) +{ + free(a); + return 0; +} +#define kmem_cache_validate(a,b) 1 +#define kmem_cache_alloc(cache, prio) malloc(cache->size) +#define kmem_cache_free(cache, obj) OBD_FREE(obj, cache->size) +#define PORTAL_SLAB_ALLOC(lock,cache,size) do { lock = kmem_cache_alloc(cache,prio); } while (0) +#define PORTAL_SLAB_FREE(lock,cache,size) do { lock = kmem_cache_alloc(cache,prio); } while (0) + +struct page { + void *addr; + int index; +}; + +#define kmap(page) (page)->addr +#define kunmap(a) do { int foo = 1; foo++; } while (0) + +static inline struct page *alloc_pages(mask,foo) +{ + struct page *pg = malloc(sizeof(*pg)); + + if (!pg) + return NULL; +#ifdef MAP_ANONYMOUS + pg->addr = mmap(0, PAGE_SIZE, PROT_WRITE, MAP_ANONYMOUS, 0, 0); +#else + pg->addr = malloc(PAGE_SIZE); +#endif + + if (!pg->addr) { + free(pg); + return NULL; + } + return pg; +} + +static inline void __free_pages(struct page *pg, int what) +{ +#ifdef MAP_ANONYMOUS + munmap(pg->addr, PAGE_SIZE); +#else + free(pg->addr); +#endif + free(pg); +} + +/* arithmetic */ +#define do_div(a,b) (a)/(b) + +/* dentries / intents */ +struct lookup_intent { + void *it_iattr; +}; + +struct iattr { + int mode; +}; + +struct dentry { + int d_count; +}; +struct file { + struct dentry *f_dentry; + void *private_data; +} ; + +struct vfsmount { + void *pwd; +}; +#define cpu_to_le32(x) ((__u32)(x)) + +/* semaphores */ +struct semaphore { + int count; +}; + +#define down(a) do {(a)->count++;} while (0) +#define up(a) do {(a)->count--;} while (0) +#define sema_init(a,b) do { (a)->count = b; } while (0) + +typedef struct { + struct list_head sleepers; +} wait_queue_head_t; + +typedef struct { + struct list_head sleeping; + void *process; +} wait_queue_t; + +struct signal { + int signal; +}; + +struct task_struct { + int state; + struct signal pending; + char comm[32]; + int pid; +}; + +extern struct task_struct *current; + + + +#define set_current_state(foo) do { current->state = foo; } while (0) + +#define init_waitqueue_entry(q,p) do { (q)->process = p; } while (0) +#define add_wait_queue(q,p) do { list_add(&(q)->sleepers, &(p)->sleeping); } while (0) +#define del_wait_queue(p) do { list_del(&(p)->sleeping); } while (0) +#define remove_wait_queue(q,p) do { list_del(&(p)->sleeping); } while (0) + +#define init_waitqueue_head(l) INIT_LIST_HEAD(&(l)->sleepers) +#define wake_up(l) do { int a; a++; } while (0) +#define wait_event(l,m) do { int a; a++; } while (0) +#define TASK_INTERRUPTIBLE 0 +#define TASK_UNINTERRUPTIBLE 1 +#define TASK_RUNNING 2 + + +#define schedule() do { int a; a++; } while (0) +static inline int schedule_timeout(t) +{ + return 0; +} + +#define lock_kernel() do { int a; a++; } while (0) +#define daemonize(l) do { int a; a++; } while (0) +#define sigfillset(l) do { int a; a++; } while (0) +#define recalc_sigpending(l) do { int a; a++; } while (0) +#define kernel_thread(l,m,n) + +static inline int call_usermodehelper(char *prog, char **argv, char **evnp) +{ + return 0; +} + + + +#define KERN_INFO + + + +struct timer_list { + struct list_head tl_list; +}; + +typedef struct { volatile int counter; } atomic_t; + +#define atomic_read(a) ((a)->counter) +#define atomic_set(a,b) do {(a)->counter = b; } while (0) +#define atomic_dec_and_test(a) ((--((a)->counter)) == 0) +#define atomic_inc(a) (((a)->counter)++) +#define atomic_dec(a) do { (a)->counter--; } while (0) +#define atomic_add(b,a) do {(a)->counter += b;} while (0) +#define atomic_sub(b,a) do {(a)->counter -= b;} while (0) + +#define LBUG() do { sleep(1000000); } while (0) + +#include +#include +#include +#include +#include +#include + + +#endif + -- 1.8.3.1