Home | History | Annotate | Download | only in e2fsck
      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 	e2fsck_t	b_ctx;
     19 	io_channel 	b_io;
     20 	int	 	b_size;
     21 	unsigned long long b_blocknr;
     22 	int	 	b_dirty;
     23 	int	 	b_uptodate;
     24 	int	 	b_err;
     25 	char		b_data[1024];
     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 lock_buffer(bh) do {} while(0)
     45 #define unlock_buffer(bh) do {} while(0)
     46 #define buffer_req(bh) 1
     47 #define do_readahead(journal, start) do {} while(0)
     48 
     49 extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
     50 
     51 typedef struct {
     52 	int	object_length;
     53 } lkmem_cache_t;
     54 
     55 #define kmem_cache_alloc(cache,flags) malloc((cache)->object_length)
     56 #define kmem_cache_free(cache,obj) free(obj)
     57 #define kmem_cache_create(name,len,a,b,c,d) do_cache_create(len)
     58 #define kmem_cache_destroy(cache) do_cache_destroy(cache)
     59 #define kmalloc(len,flags) malloc(len)
     60 #define kfree(p) free(p)
     61 
     62 #define cond_resched()	do { } while (0)
     63 
     64 #ifndef __BIONIC__
     65 typedef unsigned int __be32;
     66 typedef __u64 __be64;
     67 #endif
     68 
     69 #define __init
     70 
     71 /*
     72  * Now pull in the real linux/jfs.h definitions.
     73  */
     74 #include <ext2fs/kernel-jbd.h>
     75 
     76 /*
     77  * We use the standard libext2fs portability tricks for inline
     78  * functions.
     79  */
     80 #ifdef NO_INLINE_FUNCS
     81 extern lkmem_cache_t * do_cache_create(int len);
     82 extern void do_cache_destroy(lkmem_cache_t *cache);
     83 extern size_t journal_tag_bytes(journal_t *journal);
     84 #endif
     85 
     86 #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
     87 #ifdef E2FSCK_INCLUDE_INLINE_FUNCS
     88 #if (__STDC_VERSION__ >= 199901L)
     89 #define _INLINE_ extern inline
     90 #else
     91 #define _INLINE_ inline
     92 #endif
     93 #else /* !E2FSCK_INCLUDE_INLINE FUNCS */
     94 #if (__STDC_VERSION__ >= 199901L)
     95 #define _INLINE_ inline
     96 #else /* not C99 */
     97 #ifdef __GNUC__
     98 #define _INLINE_ extern __inline__
     99 #else				/* For Watcom C */
    100 #define _INLINE_ extern inline
    101 #endif /* __GNUC__ */
    102 #endif /* __STDC_VERSION__ >= 199901L */
    103 #endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
    104 
    105 
    106 _INLINE_ lkmem_cache_t * do_cache_create(int len)
    107 {
    108 	lkmem_cache_t *new_cache;
    109 	new_cache = malloc(sizeof(*new_cache));
    110 	if (new_cache)
    111 		new_cache->object_length = len;
    112 	return new_cache;
    113 }
    114 
    115 _INLINE_ void do_cache_destroy(lkmem_cache_t *cache)
    116 {
    117 	free(cache);
    118 }
    119 
    120 /*
    121  * helper functions to deal with 32 or 64bit block numbers.
    122  */
    123 _INLINE_ size_t journal_tag_bytes(journal_t *journal)
    124 {
    125 	if (JFS_HAS_INCOMPAT_FEATURE(journal, JFS_FEATURE_INCOMPAT_64BIT))
    126 		return JBD_TAG_SIZE64;
    127 	else
    128 		return JBD_TAG_SIZE32;
    129 }
    130 
    131 #undef _INLINE_
    132 #endif
    133 
    134 /*
    135  * Kernel compatibility functions are defined in journal.c
    136  */
    137 int journal_bmap(journal_t *journal, blk64_t block, unsigned long long *phys);
    138 struct buffer_head *getblk(kdev_t ctx, blk64_t blocknr, int blocksize);
    139 void sync_blockdev(kdev_t kdev);
    140 void ll_rw_block(int rw, int dummy, struct buffer_head *bh[]);
    141 void mark_buffer_dirty(struct buffer_head *bh);
    142 void mark_buffer_uptodate(struct buffer_head *bh, int val);
    143 void brelse(struct buffer_head *bh);
    144 int buffer_uptodate(struct buffer_head *bh);
    145 void wait_on_buffer(struct buffer_head *bh);
    146 
    147 /*
    148  * Define newer 2.5 interfaces
    149  */
    150 #define __getblk(dev, blocknr, blocksize) getblk(dev, blocknr, blocksize)
    151 #define set_buffer_uptodate(bh) mark_buffer_uptodate(bh, 1)
    152