2 * Compatibility header file for e2fsck which should be included
3 * instead of linux/jfs.h
5 * Copyright (C) 2000 Stephen C. Tweedie
7 * This file may be redistributed under the terms of the
8 * GNU General Public License version 2 or at your discretion
15 #if EXT2_FLAT_INCLUDES
20 #include "ext2fs/ext2_fs.h"
21 #include "ext2fs/ext2fs.h"
22 #include "blkid/blkid.h"
26 * Pull in the definition of the e2fsck context structure
39 unsigned long long b_blocknr
;
53 struct ext2_inode i_ext2
;
66 #define K_DEV_JOURNAL 2
68 typedef struct kdev_s
*kdev_t
;
70 #define lock_buffer(bh) do {} while (0)
71 #define unlock_buffer(bh) do {} while (0)
72 #define buffer_req(bh) 1
73 #define do_readahead(journal, start) do {} while (0)
79 #define kmem_cache_alloc(cache, flags) malloc((cache)->object_length)
80 #define kmem_cache_free(cache, obj) free(obj)
81 #define kmem_cache_create(name, len, a, b, c) do_cache_create(len)
82 #define kmem_cache_destroy(cache) do_cache_destroy(cache)
83 #define kmalloc(len, flags) malloc(len)
84 #define kfree(p) free(p)
86 #define cond_resched() do { } while (0)
88 typedef unsigned int __be32
;
94 * Now pull in the real linux/jfs.h definitions.
96 #include <ext2fs/kernel-jbd.h>
99 * We use the standard libext2fs portability tricks for inline
102 #ifdef NO_INLINE_FUNCS
103 extern lkmem_cache_t
*do_cache_create(int len
);
104 extern void do_cache_destroy(lkmem_cache_t
*cache
);
105 extern size_t journal_tag_bytes(journal_t
*journal
);
108 #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
109 #ifdef E2FSCK_INCLUDE_INLINE_FUNCS
110 #if (__STDC_VERSION__ >= 199901L)
111 #define _INLINE_ extern inline
113 #define _INLINE_ inline
115 #else /* !E2FSCK_INCLUDE_INLINE FUNCS */
116 #if (__STDC_VERSION__ >= 199901L)
117 #define _INLINE_ inline
120 #define _INLINE_ extern __inline__
121 #else /* For Watcom C */
122 #define _INLINE_ extern inline
123 #endif /* __GNUC__ */
124 #endif /* __STDC_VERSION__ >= 199901L */
125 #endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
128 _INLINE_ lkmem_cache_t
*do_cache_create(int len
)
130 lkmem_cache_t
*new_cache
;
132 new_cache
= malloc(sizeof(*new_cache
));
134 new_cache
->object_length
= len
;
138 _INLINE_
void do_cache_destroy(lkmem_cache_t
*cache
)
147 * Kernel compatibility functions are defined in journal.c
149 int journal_bmap(journal_t
*journal
, blk64_t block
, unsigned long long *phys
);
150 struct buffer_head
*getblk(kdev_t ctx
, blk64_t blocknr
, int blocksize
);
151 int sync_blockdev(kdev_t kdev
);
152 void ll_rw_block(int rw
, int dummy
, struct buffer_head
*bh
[]);
153 void mark_buffer_dirty(struct buffer_head
*bh
);
154 void mark_buffer_uptodate(struct buffer_head
*bh
, int val
);
155 void brelse(struct buffer_head
*bh
);
156 int buffer_uptodate(struct buffer_head
*bh
);
157 void wait_on_buffer(struct buffer_head
*bh
);
160 * Define newer 2.5 interfaces
162 #define __getblk(dev, blocknr, blocksize) getblk(dev, blocknr, blocksize)
163 #define set_buffer_uptodate(bh) mark_buffer_uptodate(bh, 1)
168 #define J_ASSERT(x) assert(x)
170 #define JSB_HAS_INCOMPAT_FEATURE(jsb, mask) \
171 ((jsb)->s_header.h_blocktype == ext2fs_cpu_to_be32(JFS_SUPERBLOCK_V2) && \
172 ((jsb)->s_feature_incompat & ext2fs_cpu_to_be32((mask))))
173 static inline size_t journal_super_tag_bytes(journal_superblock_t
*jsb
)
177 if (JSB_HAS_INCOMPAT_FEATURE(jsb
, JFS_FEATURE_INCOMPAT_CSUM_V3
))
178 return sizeof(journal_block_tag3_t
);
180 sz
= sizeof(journal_block_tag_t
);
182 if (JSB_HAS_INCOMPAT_FEATURE(jsb
, JFS_FEATURE_INCOMPAT_CSUM_V2
))
185 if (JSB_HAS_INCOMPAT_FEATURE(jsb
, JFS_FEATURE_INCOMPAT_64BIT
))
188 return sz
- sizeof(__u32
);
192 extern e2fsck_t e2fsck_global_ctx
; /* Try your very best not to use this! */
194 #define J_ASSERT(assert) \
195 do { if (!(assert)) { \
196 printf ("Assertion failure in %s() at %s line %d: " \
198 __FUNCTION__, __FILE__, __LINE__, # assert); \
199 fatal_error(e2fsck_global_ctx, 0); \
204 #endif /* _JFS_USER_H */