Whamcloud - gitweb
157ece18e1f72c5db583d075fea38d95191874e0
[tools/e2fsprogs.git] / e2fsck / jfs_user.h
1 /*
2  * Compatibility header file for e2fsck which should be included
3  * instead of linux/jfs.h
4  *
5  * Copyright (C) 2000 Stephen C. Tweedie
6  *
7  * This file may be redistributed under the terms of the
8  * GNU General Public License version 2 or at your discretion
9  * any later version.
10  */
11
12 /*
13  * Pull in the definition of the e2fsck context structure
14  */
15 #include "e2fsck.h"
16
17 struct buffer_head {
18         char            b_data[8192];
19         e2fsck_t        b_ctx;
20         io_channel      b_io;
21         int             b_size;
22         blk_t           b_blocknr;
23         int             b_dirty;
24         int             b_uptodate;
25         int             b_err;
26 };
27
28 struct inode {
29         e2fsck_t        i_ctx;
30         ext2_ino_t      i_ino;
31         struct ext2_inode i_ext2;
32 };
33
34 struct kdev_s {
35         e2fsck_t        k_ctx;
36         int             k_dev;
37 };
38
39 #define K_DEV_FS        1
40 #define K_DEV_JOURNAL   2
41
42 typedef struct kdev_s *kdev_t;
43
44 #define fsync_no_super(dev) do {} while(0)
45 #define sync_blockdev(dev) do {} while(0)
46 #define lock_buffer(bh) do {} while(0)
47 #define unlock_buffer(bh) do {} while(0)
48 #define buffer_req(bh) 1
49 #define do_readahead(journal, start) do {} while(0)
50         
51 extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
52
53 typedef struct {
54         int     object_length;
55 } kmem_cache_t;
56
57 #define kmem_cache_alloc(cache,flags) malloc((cache)->object_length)
58 #define kmem_cache_free(cache,obj) free(obj)
59 #define kmem_cache_create(name,len,a,b,c,d) do_cache_create(len)
60 #define kmem_cache_destroy(cache) do_cache_destroy(cache)
61 #define kmalloc(len,flags) malloc(len)
62 #define kfree(p) free(p)
63
64 /*
65  * We use the standard libext2fs portability tricks for inline
66  * functions.  
67  */
68 extern kmem_cache_t * do_cache_create(int len);
69 extern void do_cache_destroy(kmem_cache_t *cache);
70         
71 #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
72 #ifdef E2FSCK_INCLUDE_INLINE_FUNCS
73 #define _INLINE_ extern
74 #else
75 #ifdef __GNUC__
76 #define _INLINE_ extern __inline__
77 #else                           /* For Watcom C */
78 #define _INLINE_ extern inline
79 #endif
80 #endif
81
82 _INLINE_ kmem_cache_t * do_cache_create(int len)
83 {
84         kmem_cache_t *new_cache;
85         new_cache = malloc(sizeof(*new_cache));
86         if (new_cache)
87                 new_cache->object_length = len;
88         return new_cache;
89 }
90
91 _INLINE_ void do_cache_destroy(kmem_cache_t *cache)
92 {
93         free(cache);
94 }
95 #undef _INLINE_
96 #endif
97
98 #define __init
99
100 /*
101  * Now pull in the real linux/jfs.h definitions.
102  */
103 #include <ext2fs/kernel-jbd.h>
104
105 /*
106  * Kernel compatibility functions are defined in journal.c
107  */
108 int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys);
109 struct buffer_head *getblk(kdev_t ctx, blk_t blocknr, int blocksize);
110 void ll_rw_block(int rw, int dummy, struct buffer_head *bh[]);
111 void mark_buffer_dirty(struct buffer_head *bh);
112 void mark_buffer_uptodate(struct buffer_head *bh, int val);
113 void brelse(struct buffer_head *bh);
114 int buffer_uptodate(struct buffer_head *bh);
115 void wait_on_buffer(struct buffer_head *bh);
116
117 /*
118  * Define newer 2.5 interfaces
119  */
120 #define __getblk(dev, blocknr, blocksize) getblk(dev, blocknr, blocksize)
121 #define set_buffer_uptodate(bh) mark_buffer_uptodate(bh, 1)