blob: bb2c6302ec777b1321445c0c1fe350cd2899fff3 [file] [log] [blame]
Theodore Ts'occ7067b2001-01-03 13:24:06 +00001/*
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 */
Theodore Ts'o0e8a9562000-12-09 06:41:25 +000015#include "e2fsck.h"
Theodore Ts'occ7067b2001-01-03 13:24:06 +000016
17struct buffer_head {
Theodore Ts'o8cf93332001-12-16 02:23:36 -050018 e2fsck_t b_ctx;
19 io_channel b_io;
20 int b_size;
JP Abgralle0ed7402014-03-19 19:08:39 -070021 unsigned long long b_blocknr;
Theodore Ts'o8cf93332001-12-16 02:23:36 -050022 int b_dirty;
23 int b_uptodate;
24 int b_err;
Theodore Ts'oe35d5482009-01-02 18:14:42 -050025 char b_data[1024];
Theodore Ts'occ7067b2001-01-03 13:24:06 +000026};
27
28struct inode {
Theodore Ts'o86c627e2001-01-11 15:12:14 +000029 e2fsck_t i_ctx;
30 ext2_ino_t i_ino;
Theodore Ts'occ7067b2001-01-03 13:24:06 +000031 struct ext2_inode i_ext2;
32};
33
Theodore Ts'o8cf93332001-12-16 02:23:36 -050034struct kdev_s {
35 e2fsck_t k_ctx;
36 int k_dev;
37};
Theodore Ts'occ7067b2001-01-03 13:24:06 +000038
Theodore Ts'o8cf93332001-12-16 02:23:36 -050039#define K_DEV_FS 1
40#define K_DEV_JOURNAL 2
41
42typedef struct kdev_s *kdev_t;
43
Theodore Ts'o3de085d2003-12-07 01:00:02 -050044#define lock_buffer(bh) do {} while(0)
45#define unlock_buffer(bh) do {} while(0)
Theodore Ts'occ7067b2001-01-03 13:24:06 +000046#define buffer_req(bh) 1
47#define do_readahead(journal, start) do {} while(0)
Theodore Ts'oefc6f622008-08-27 23:07:54 -040048
Theodore Ts'occ7067b2001-01-03 13:24:06 +000049extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
50
51typedef struct {
52 int object_length;
Theodore Ts'o1911bf12008-07-13 08:04:36 -040053} lkmem_cache_t;
Theodore Ts'occ7067b2001-01-03 13:24:06 +000054
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)
Theodore Ts'o8cf93332001-12-16 02:23:36 -050058#define kmem_cache_destroy(cache) do_cache_destroy(cache)
Theodore Ts'occ7067b2001-01-03 13:24:06 +000059#define kmalloc(len,flags) malloc(len)
60#define kfree(p) free(p)
61
Theodore Ts'oe5ea6b12008-05-20 14:51:14 -040062#define cond_resched() do { } while (0)
63
Bernhard Rosenkränzer18a14442013-12-31 14:43:20 +010064#ifndef __BIONIC__
Theodore Ts'oe5ea6b12008-05-20 14:51:14 -040065typedef unsigned int __be32;
JP Abgralle0ed7402014-03-19 19:08:39 -070066typedef __u64 __be64;
Bernhard Rosenkränzer18a14442013-12-31 14:43:20 +010067#endif
Theodore Ts'oe5ea6b12008-05-20 14:51:14 -040068
Theodore Ts'o185c4ae2008-05-23 01:00:19 -040069#define __init
70
71/*
72 * Now pull in the real linux/jfs.h definitions.
73 */
74#include <ext2fs/kernel-jbd.h>
75
Theodore Ts'o2acad6b2008-06-07 11:04:10 -040076/*
77 * We use the standard libext2fs portability tricks for inline
Theodore Ts'oefc6f622008-08-27 23:07:54 -040078 * functions.
Theodore Ts'o2acad6b2008-06-07 11:04:10 -040079 */
JP Abgralle0ed7402014-03-19 19:08:39 -070080#ifdef NO_INLINE_FUNCS
Theodore Ts'o1911bf12008-07-13 08:04:36 -040081extern lkmem_cache_t * do_cache_create(int len);
82extern void do_cache_destroy(lkmem_cache_t *cache);
Theodore Ts'o2acad6b2008-06-07 11:04:10 -040083extern size_t journal_tag_bytes(journal_t *journal);
JP Abgralle0ed7402014-03-19 19:08:39 -070084#endif
Theodore Ts'oefc6f622008-08-27 23:07:54 -040085
Theodore Ts'o53ef44c2001-01-06 05:55:58 +000086#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
87#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
JP Abgralle0ed7402014-03-19 19:08:39 -070088#if (__STDC_VERSION__ >= 199901L)
89#define _INLINE_ extern inline
Theodore Ts'o53ef44c2001-01-06 05:55:58 +000090#else
JP Abgralle0ed7402014-03-19 19:08:39 -070091#define _INLINE_ inline
92#endif
93#else /* !E2FSCK_INCLUDE_INLINE FUNCS */
94#if (__STDC_VERSION__ >= 199901L)
95#define _INLINE_ inline
96#else /* not C99 */
Theodore Ts'o53ef44c2001-01-06 05:55:58 +000097#ifdef __GNUC__
98#define _INLINE_ extern __inline__
99#else /* For Watcom C */
100#define _INLINE_ extern inline
JP Abgralle0ed7402014-03-19 19:08:39 -0700101#endif /* __GNUC__ */
102#endif /* __STDC_VERSION__ >= 199901L */
103#endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
104
Theodore Ts'o53ef44c2001-01-06 05:55:58 +0000105
Theodore Ts'o1911bf12008-07-13 08:04:36 -0400106_INLINE_ lkmem_cache_t * do_cache_create(int len)
Theodore Ts'occ7067b2001-01-03 13:24:06 +0000107{
Theodore Ts'o1911bf12008-07-13 08:04:36 -0400108 lkmem_cache_t *new_cache;
Theodore Ts'occ7067b2001-01-03 13:24:06 +0000109 new_cache = malloc(sizeof(*new_cache));
110 if (new_cache)
111 new_cache->object_length = len;
112 return new_cache;
113}
114
Theodore Ts'o1911bf12008-07-13 08:04:36 -0400115_INLINE_ void do_cache_destroy(lkmem_cache_t *cache)
Theodore Ts'o8cf93332001-12-16 02:23:36 -0500116{
117 free(cache);
118}
Theodore Ts'o8cf93332001-12-16 02:23:36 -0500119
Theodore Ts'occ7067b2001-01-03 13:24:06 +0000120/*
Theodore Ts'o185c4ae2008-05-23 01:00:19 -0400121 * helper functions to deal with 32 or 64bit block numbers.
Theodore Ts'occ7067b2001-01-03 13:24:06 +0000122 */
Theodore Ts'o185c4ae2008-05-23 01:00:19 -0400123_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
Theodore Ts'o8cf93332001-12-16 02:23:36 -0500133
134/*
135 * Kernel compatibility functions are defined in journal.c
136 */
JP Abgralle0ed7402014-03-19 19:08:39 -0700137int journal_bmap(journal_t *journal, blk64_t block, unsigned long long *phys);
138struct buffer_head *getblk(kdev_t ctx, blk64_t blocknr, int blocksize);
Theodore Ts'o93effaa2004-05-26 20:58:45 -0400139void sync_blockdev(kdev_t kdev);
Theodore Ts'o8cf93332001-12-16 02:23:36 -0500140void ll_rw_block(int rw, int dummy, struct buffer_head *bh[]);
141void mark_buffer_dirty(struct buffer_head *bh);
142void mark_buffer_uptodate(struct buffer_head *bh, int val);
143void brelse(struct buffer_head *bh);
144int buffer_uptodate(struct buffer_head *bh);
145void wait_on_buffer(struct buffer_head *bh);
Theodore Ts'o3de085d2003-12-07 01:00:02 -0500146
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)