root/morphix/trunk/mini_fo/fist.h

Revision 2, 7.0 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 /*
2  * Copyright (c) 1997-2004 Erez Zadok <ezk@cs.stonybrook.edu>
3  * Copyright (c) 2001-2004 Stony Brook University
4  *
5  * For specific licensing information, see the COPYING file distributed with
6  * this package, or get one from ftp://ftp.filesystems.org/pub/fistgen/COPYING.
7  *
8  * This Copyright notice must be kept intact and distributed with all
9  * fistgen sources INCLUDING sources generated by fistgen.
10  */
11 /*
12  *  $Id: fist.h 1364 2004-12-04 10:18:10Z alextreme $
13  */
14
15 #ifndef __FIST_H_
16 #define __FIST_H_
17
18 /*
19  * KERNEL ONLY CODE:
20  */
21 #ifdef __KERNEL__
22 #include <linux/config.h>
23 #include <linux/version.h>
24 #ifdef CONFIG_MODVERSIONS
25 # define MODVERSIONS
26 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
27 # include <linux/modversions.h>
28 #else
29 # include <config/modversions.h>
30 #endif
31 #endif /* CONFIG_MODVERSIONS */
32 #include <linux/sched.h>
33 #include <linux/kernel.h>
34 #include <linux/mm.h>
35 #include <linux/string.h>
36 #include <linux/stat.h>
37 #include <linux/errno.h>
38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
39 #include <linux/buffer_head.h>
40 #else
41 #include <linux/locks.h>
42 #endif
43 #include <linux/smp.h>
44 #include <linux/smp_lock.h>
45 #include <linux/file.h>
46 #include <linux/slab.h>
47 #include <linux/vmalloc.h>
48 #include <linux/poll.h>
49 #include <linux/list.h>
50 #include <linux/init.h>
51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
52 #include <linux/pagemap.h>
53 #include <linux/namei.h>
54 #include <linux/module.h>
55 #include <linux/mount.h>
56 #include <linux/seq_file.h>
57 #include <linux/page-flags.h>
58 #include <linux/writeback.h>
59 #include <linux/page-flags.h>
60 #endif
61 #include <linux/swap.h>
62
63 #include <asm/system.h>
64 #include <asm/segment.h>
65 #include <asm/mman.h>
66
67 /*
68  * MACROS:
69  */
70
71 /* those mapped to ATTR_* were copied from linux/fs.h */
72 #define FA_MODE         ATTR_MODE
73 #define FA_UID          ATTR_UID
74 #define FA_GID          ATTR_GID
75 #define FA_SIZE         ATTR_SIZE
76 #define FA_ATIME        ATTR_ATIME
77 #define FA_MTIME        ATTR_MTIME
78 #define FA_CTIME        ATTR_CTIME
79 #define FA_ATIME_SET    ATTR_ATIME_SET
80 #define FA_MTIME_SET    ATTR_MTIME_SET
81 #define FA_FORCE        ATTR_FORCE
82 #define FA_ATTR_FLAGS   ATTR_ATTR_FLAG
83
84 /* must be greater than all other ATTR_* flags! */
85 #define FA_NLINK        2048
86 #define FA_BLKSIZE      4096
87 #define FA_BLOCKS       8192
88 #define FA_TIMES        (FA_ATIME|FA_MTIME|FA_CTIME)
89 #define FA_ALL          0
90
91 /* macros to manage changes between kernels */
92 #define INODE_DATA(i)   (&(i)->i_data)
93
94 #define MIN(x,y) ((x < y) ? (x) : (y))
95 #define MAX(x,y) ((x > y) ? (x) : (y))
96 #define MAXPATHLEN PATH_MAX
97
98 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5)
99 # define lookup_one_len(a,b,c) lookup_one(a,b)
100 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) */
101
102 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8)
103 # define generic_file_llseek default_llseek
104 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8) */
105
106 #ifndef SEEK_SET
107 # define SEEK_SET 0
108 #endif /* not SEEK_SET */
109
110 #ifndef SEEK_CUR
111 # define SEEK_CUR 1
112 #endif /* not SEEK_CUR */
113
114 #ifndef SEEK_END
115 # define SEEK_END 2
116 #endif /* not SEEK_END */
117
118 #ifndef DEFAULT_POLLMASK
119 # define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
120 #endif /* not DEFAULT_POLLMASK */
121
122 /* XXX: fix this so fistgen generates kfree() code directly */
123 #define kfree_s(a,b) kfree(a)
124
125 #ifdef FIST_MALLOC_DEBUG
126 extern void *mini_fo_kmalloc(size_t len, int flag, int line, const char *file);
127 extern void mini_fo_kfree(void *ptr, int line, const char *file);
128 extern atomic_t mini_fo_malloc_counter;
129 # define KMALLOC(size,flag) mini_fo_kmalloc((size),(flag),__LINE__,__FILE__)
130 # define KFREE(ptr) mini_fo_kfree((ptr),__LINE__,__FILE__)
131 #else /* not FIST_MALLOC_DEBUG */
132 # define KMALLOC(a,b)   kmalloc((a),(b))
133 # define KFREE(a)       kfree((a))
134 #endif /* not FIST_MALLOC_DEBUG */
135
136 /*
137  * TYPEDEFS:
138  */
139 typedef struct dentry dentry_t;
140 typedef struct file file_t;
141 typedef struct inode inode_t;
142 typedef inode_t vnode_t;
143 typedef struct page page_t;
144 typedef struct qstr qstr_t;
145 typedef struct super_block super_block_t;
146 typedef super_block_t vfs_t;
147 typedef struct vm_area_struct vm_area_t;
148 typedef struct file_lock file_lock_t;
149
150
151 /*
152  * EXTERNALS:
153  */
154
155 #define FPPF(str,page) printk("PPF %s 0x%x/%d: Lck:%d Err:%d Ref:%d Upd:%d Other::%d:%d:%d:%d:\n", \
156                 str, \
157                 (int) page, \
158                 (int) page->index, \
159                 (PageLocked(page) ? 1 : 0), \
160                 (PageError(page) ? 1 : 0), \
161                 (PageReferenced(page) ? 1 : 0), \
162                 (PageUptodate(page) ? 1 : 0), \
163                 (PageDecrAfter(page) ? 1 : 0), \
164                 (PageSlab(page) ? 1 : 0), \
165                 (PageSwapCache(page) ? 1 : 0), \
166                 (PageReserved(page) ? 1 : 0) \
167                 )
168 #define EZKDBG printk("EZK %s:%d:%s\n",__FILE__,__LINE__,__FUNCTION__)
169 #if 0
170 # define EZKDBG1 printk("EZK %s:%d\n",__FILE__,__LINE__)
171 #else
172 # define EZKDBG1
173 #endif
174
175
176
177 extern int fist_get_debug_value(void);
178 extern int fist_set_debug_value(int val);
179 extern void fist_dprint_internal(int level, char *str,...);
180 extern void fist_print_dentry(char *str, const dentry_t *dentry);
181 extern void fist_print_inode(char *str, const inode_t *inode);
182 extern void fist_print_file(char *str, const file_t *file);
183 extern void fist_print_buffer_flags(char *str, struct buffer_head *buffer);
184 extern void fist_print_page_flags(char *str, page_t *page);
185 extern void fist_print_page_bytes(char *str, page_t *page);
186 extern void fist_print_pte_flags(char *str, const page_t *page);
187 extern void fist_checkinode(inode_t *inode, char *msg);
188 extern void fist_print_sb(char *str, const super_block_t *sb);
189 extern char *add_indent(void);
190 extern char *del_indent(void);
191
192 #define STATIC
193 #define ASSERT(EX)      \
194 do {    \
195     if (!(EX)) {        \
196         printk(KERN_CRIT "ASSERTION FAILED: %s at %s:%d (%s)\n", #EX,   \
197                __FILE__, __LINE__, __FUNCTION__);       \
198         (*((char *)0))=0;       \
199     }   \
200 } while (0)
201 /* same ASSERT, but tell me who was the caller of the function */
202 #define ASSERT2(EX)     \
203 do {    \
204     if (!(EX)) {        \
205         printk(KERN_CRIT "ASSERTION FAILED (caller): %s at %s:%d (%s)\n", #EX,  \
206                file, line, func);       \
207         (*((char *)0))=0;       \
208     }   \
209 } while (0)
210
211 extern void fist_dprint_internal2(int level, char *str,char *indent,const  char* func,const char *file,const int line);
212
213 #define dprintk(format, args...) printk(KERN_DEBUG format, ##args)
214 #define fist_dprint(level, str, args...) fist_dprint_internal(level, KERN_DEBUG str, ## args)
215 #define print_entry_location() fist_dprint(4, "%sIN:  %s %s:%d\n", add_indent(), __FUNCTION__, __FILE__, __LINE__)
216 #define print_exit_location() fist_dprint(4, "%s OUT: %s %s:%d\n", del_indent(), __FUNCTION__, __FILE__, __LINE__)
217 #define print_exit_status(status) fist_dprint(4, "%s OUT: %s %s:%d, STATUS: %d\n", del_indent(), __FUNCTION__, __FILE__, __LINE__, status)
218 #define print_exit_pointer(status) \
219 do { \
220   if (IS_ERR(status)) \
221     fist_dprint(4, "%s OUT: %s %s:%d, RESULT: %ld\n", del_indent(), __FUNCTION__, __FILE__, __LINE__, PTR_ERR(status)); \
222   else \
223     fist_dprint(4, "%s OUT: %s %s:%d, RESULT: 0x%x\n", del_indent(), __FUNCTION__, __FILE__, __LINE__, PTR_ERR(status)); \
224 } while (0)
225
226
227 #endif /* __KERNEL__ */
228
229
230 /*
231  * DEFINITIONS FOR USER AND KERNEL CODE:
232  * (Note: ioctl numbers 1--9 are reserved for fistgen, the rest
233  *  are auto-generated automatically based on the user's .fist file.)
234  */
235 # define FIST_IOCTL_GET_DEBUG_VALUE     _IOR(0x15, 1, int)
236 # define FIST_IOCTL_SET_DEBUG_VALUE     _IOW(0x15, 2, int)
237
238
239
240 #endif /* not __FIST_H_ */
241
242 /*
243  * Local variables:
244  * c-basic-offset: 4
245  * End:
246  */
Note: See TracBrowser for help on using the browser.