xref: /aosp_15_r20/external/e2fsprogs/lib/ext2fs/ext2fs.h (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker  * ext2fs.h --- ext2fs
3*6a54128fSAndroid Build Coastguard Worker  *
4*6a54128fSAndroid Build Coastguard Worker  * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
5*6a54128fSAndroid Build Coastguard Worker  *
6*6a54128fSAndroid Build Coastguard Worker  * %Begin-Header%
7*6a54128fSAndroid Build Coastguard Worker  * This file may be redistributed under the terms of the GNU Library
8*6a54128fSAndroid Build Coastguard Worker  * General Public License, version 2.
9*6a54128fSAndroid Build Coastguard Worker  * %End-Header%
10*6a54128fSAndroid Build Coastguard Worker  */
11*6a54128fSAndroid Build Coastguard Worker 
12*6a54128fSAndroid Build Coastguard Worker #ifndef _EXT2FS_EXT2FS_H
13*6a54128fSAndroid Build Coastguard Worker #define _EXT2FS_EXT2FS_H
14*6a54128fSAndroid Build Coastguard Worker 
15*6a54128fSAndroid Build Coastguard Worker #ifdef __GNUC__
16*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_ATTR(x) __attribute__(x)
17*6a54128fSAndroid Build Coastguard Worker #else
18*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_ATTR(x)
19*6a54128fSAndroid Build Coastguard Worker #endif
20*6a54128fSAndroid Build Coastguard Worker 
21*6a54128fSAndroid Build Coastguard Worker #ifndef __nonstring
22*6a54128fSAndroid Build Coastguard Worker #ifdef __has_attribute
23*6a54128fSAndroid Build Coastguard Worker #if __has_attribute(__nonstring__)
24*6a54128fSAndroid Build Coastguard Worker #define __nonstring                    __attribute__((__nonstring__))
25*6a54128fSAndroid Build Coastguard Worker #else
26*6a54128fSAndroid Build Coastguard Worker #define __nonstring
27*6a54128fSAndroid Build Coastguard Worker #endif /* __has_attribute(__nonstring__) */
28*6a54128fSAndroid Build Coastguard Worker #else
29*6a54128fSAndroid Build Coastguard Worker # define __nonstring
30*6a54128fSAndroid Build Coastguard Worker #endif /* __has_attribute */
31*6a54128fSAndroid Build Coastguard Worker #endif /* __nonstring */
32*6a54128fSAndroid Build Coastguard Worker 
33*6a54128fSAndroid Build Coastguard Worker #ifdef CONFIG_TDB
34*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_NO_TDB_UNUSED
35*6a54128fSAndroid Build Coastguard Worker #else
36*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_NO_TDB_UNUSED	EXT2FS_ATTR((unused))
37*6a54128fSAndroid Build Coastguard Worker #endif
38*6a54128fSAndroid Build Coastguard Worker 
39*6a54128fSAndroid Build Coastguard Worker #ifdef __cplusplus
40*6a54128fSAndroid Build Coastguard Worker extern "C" {
41*6a54128fSAndroid Build Coastguard Worker #endif
42*6a54128fSAndroid Build Coastguard Worker 
43*6a54128fSAndroid Build Coastguard Worker /*
44*6a54128fSAndroid Build Coastguard Worker  * Non-GNU C compilers won't necessarily understand inline
45*6a54128fSAndroid Build Coastguard Worker  */
46*6a54128fSAndroid Build Coastguard Worker #if (!defined(__GNUC__) && !defined(__WATCOMC__))
47*6a54128fSAndroid Build Coastguard Worker #define NO_INLINE_FUNCS
48*6a54128fSAndroid Build Coastguard Worker #endif
49*6a54128fSAndroid Build Coastguard Worker 
50*6a54128fSAndroid Build Coastguard Worker /*
51*6a54128fSAndroid Build Coastguard Worker  * Where the master copy of the superblock is located, and how big
52*6a54128fSAndroid Build Coastguard Worker  * superblocks are supposed to be.  We define SUPERBLOCK_SIZE because
53*6a54128fSAndroid Build Coastguard Worker  * the size of the superblock structure is not necessarily trustworthy
54*6a54128fSAndroid Build Coastguard Worker  * (some versions have the padding set up so that the superblock is
55*6a54128fSAndroid Build Coastguard Worker  * 1032 bytes long).
56*6a54128fSAndroid Build Coastguard Worker  */
57*6a54128fSAndroid Build Coastguard Worker #define SUPERBLOCK_OFFSET	1024
58*6a54128fSAndroid Build Coastguard Worker #define SUPERBLOCK_SIZE		1024
59*6a54128fSAndroid Build Coastguard Worker 
60*6a54128fSAndroid Build Coastguard Worker #define UUID_STR_SIZE 37
61*6a54128fSAndroid Build Coastguard Worker 
62*6a54128fSAndroid Build Coastguard Worker /*
63*6a54128fSAndroid Build Coastguard Worker  * The last ext2fs revision level that this version of the library is
64*6a54128fSAndroid Build Coastguard Worker  * able to support.
65*6a54128fSAndroid Build Coastguard Worker  */
66*6a54128fSAndroid Build Coastguard Worker #define EXT2_LIB_CURRENT_REV	EXT2_DYNAMIC_REV
67*6a54128fSAndroid Build Coastguard Worker 
68*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_SYS_TYPES_H
69*6a54128fSAndroid Build Coastguard Worker #include <sys/types.h>
70*6a54128fSAndroid Build Coastguard Worker #endif
71*6a54128fSAndroid Build Coastguard Worker 
72*6a54128fSAndroid Build Coastguard Worker #include <stdio.h>
73*6a54128fSAndroid Build Coastguard Worker #include <stdlib.h>
74*6a54128fSAndroid Build Coastguard Worker #include <string.h>
75*6a54128fSAndroid Build Coastguard Worker #include <time.h>
76*6a54128fSAndroid Build Coastguard Worker #include <errno.h>
77*6a54128fSAndroid Build Coastguard Worker 
78*6a54128fSAndroid Build Coastguard Worker #if EXT2_FLAT_INCLUDES
79*6a54128fSAndroid Build Coastguard Worker #include "e2_types.h"
80*6a54128fSAndroid Build Coastguard Worker #include "ext2_fs.h"
81*6a54128fSAndroid Build Coastguard Worker #include "ext3_extents.h"
82*6a54128fSAndroid Build Coastguard Worker #else
83*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/ext2_types.h>
84*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/ext2_fs.h>
85*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/ext3_extents.h>
86*6a54128fSAndroid Build Coastguard Worker #endif /* EXT2_FLAT_INCLUDES */
87*6a54128fSAndroid Build Coastguard Worker 
88*6a54128fSAndroid Build Coastguard Worker typedef __u32 __bitwise		ext2_ino_t;
89*6a54128fSAndroid Build Coastguard Worker typedef __u32 __bitwise		blk_t;
90*6a54128fSAndroid Build Coastguard Worker typedef __u64 __bitwise		blk64_t;
91*6a54128fSAndroid Build Coastguard Worker typedef __u32 __bitwise		dgrp_t;
92*6a54128fSAndroid Build Coastguard Worker typedef __s32 __bitwise		ext2_off_t;
93*6a54128fSAndroid Build Coastguard Worker typedef __s64 __bitwise		ext2_off64_t;
94*6a54128fSAndroid Build Coastguard Worker typedef __s64 __bitwise		e2_blkcnt_t;
95*6a54128fSAndroid Build Coastguard Worker typedef __u32 __bitwise		ext2_dirhash_t;
96*6a54128fSAndroid Build Coastguard Worker 
97*6a54128fSAndroid Build Coastguard Worker #if EXT2_FLAT_INCLUDES
98*6a54128fSAndroid Build Coastguard Worker #include "com_err.h"
99*6a54128fSAndroid Build Coastguard Worker #include "ext2_io.h"
100*6a54128fSAndroid Build Coastguard Worker #include "ext2_err.h"
101*6a54128fSAndroid Build Coastguard Worker #include "ext2_ext_attr.h"
102*6a54128fSAndroid Build Coastguard Worker #else
103*6a54128fSAndroid Build Coastguard Worker #include <et/com_err.h>
104*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/ext2_io.h>
105*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/ext2_err.h>
106*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/ext2_ext_attr.h>
107*6a54128fSAndroid Build Coastguard Worker #endif
108*6a54128fSAndroid Build Coastguard Worker 
109*6a54128fSAndroid Build Coastguard Worker #include "hashmap.h"
110*6a54128fSAndroid Build Coastguard Worker 
111*6a54128fSAndroid Build Coastguard Worker /*
112*6a54128fSAndroid Build Coastguard Worker  * Portability help for Microsoft Visual C++
113*6a54128fSAndroid Build Coastguard Worker  */
114*6a54128fSAndroid Build Coastguard Worker #ifdef _MSC_VER
115*6a54128fSAndroid Build Coastguard Worker #define EXT2_QSORT_TYPE int __cdecl
116*6a54128fSAndroid Build Coastguard Worker #else
117*6a54128fSAndroid Build Coastguard Worker #define EXT2_QSORT_TYPE int
118*6a54128fSAndroid Build Coastguard Worker #endif
119*6a54128fSAndroid Build Coastguard Worker 
120*6a54128fSAndroid Build Coastguard Worker typedef struct struct_ext2_filsys *ext2_filsys;
121*6a54128fSAndroid Build Coastguard Worker 
122*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_MARK_ERROR 	0
123*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_UNMARK_ERROR 	1
124*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_TEST_ERROR	2
125*6a54128fSAndroid Build Coastguard Worker 
126*6a54128fSAndroid Build Coastguard Worker struct ext2fs_struct_generic_bitmap_base {
127*6a54128fSAndroid Build Coastguard Worker 	errcode_t		magic;
128*6a54128fSAndroid Build Coastguard Worker 	ext2_filsys 		fs;
129*6a54128fSAndroid Build Coastguard Worker };
130*6a54128fSAndroid Build Coastguard Worker 
131*6a54128fSAndroid Build Coastguard Worker typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_generic_bitmap;
132*6a54128fSAndroid Build Coastguard Worker typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_inode_bitmap;
133*6a54128fSAndroid Build Coastguard Worker typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_block_bitmap;
134*6a54128fSAndroid Build Coastguard Worker 
135*6a54128fSAndroid Build Coastguard Worker #define EXT2_FIRST_INODE(s)	EXT2_FIRST_INO(s)
136*6a54128fSAndroid Build Coastguard Worker 
137*6a54128fSAndroid Build Coastguard Worker 
138*6a54128fSAndroid Build Coastguard Worker /*
139*6a54128fSAndroid Build Coastguard Worker  * Badblocks list definitions
140*6a54128fSAndroid Build Coastguard Worker  */
141*6a54128fSAndroid Build Coastguard Worker 
142*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_u32_list *ext2_badblocks_list;
143*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate;
144*6a54128fSAndroid Build Coastguard Worker 
145*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_u32_list *ext2_u32_list;
146*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_u32_iterate *ext2_u32_iterate;
147*6a54128fSAndroid Build Coastguard Worker 
148*6a54128fSAndroid Build Coastguard Worker /* old */
149*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_u32_list *badblocks_list;
150*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_u32_iterate *badblocks_iterate;
151*6a54128fSAndroid Build Coastguard Worker 
152*6a54128fSAndroid Build Coastguard Worker #define BADBLOCKS_FLAG_DIRTY	1
153*6a54128fSAndroid Build Coastguard Worker 
154*6a54128fSAndroid Build Coastguard Worker /*
155*6a54128fSAndroid Build Coastguard Worker  * ext2_dblist structure and abstractions (see dblist.c)
156*6a54128fSAndroid Build Coastguard Worker  */
157*6a54128fSAndroid Build Coastguard Worker struct ext2_db_entry2 {
158*6a54128fSAndroid Build Coastguard Worker 	ext2_ino_t	ino;
159*6a54128fSAndroid Build Coastguard Worker 	blk64_t	blk;
160*6a54128fSAndroid Build Coastguard Worker 	e2_blkcnt_t	blockcnt;
161*6a54128fSAndroid Build Coastguard Worker };
162*6a54128fSAndroid Build Coastguard Worker 
163*6a54128fSAndroid Build Coastguard Worker /* Ye Olde 32-bit version */
164*6a54128fSAndroid Build Coastguard Worker struct ext2_db_entry {
165*6a54128fSAndroid Build Coastguard Worker 	ext2_ino_t	ino;
166*6a54128fSAndroid Build Coastguard Worker 	blk_t	blk;
167*6a54128fSAndroid Build Coastguard Worker 	int	blockcnt;
168*6a54128fSAndroid Build Coastguard Worker };
169*6a54128fSAndroid Build Coastguard Worker 
170*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_dblist *ext2_dblist;
171*6a54128fSAndroid Build Coastguard Worker 
172*6a54128fSAndroid Build Coastguard Worker #define DBLIST_ABORT	1
173*6a54128fSAndroid Build Coastguard Worker 
174*6a54128fSAndroid Build Coastguard Worker /*
175*6a54128fSAndroid Build Coastguard Worker  * ext2_fileio definitions
176*6a54128fSAndroid Build Coastguard Worker  */
177*6a54128fSAndroid Build Coastguard Worker 
178*6a54128fSAndroid Build Coastguard Worker #define EXT2_FILE_WRITE		0x0001
179*6a54128fSAndroid Build Coastguard Worker #define EXT2_FILE_CREATE	0x0002
180*6a54128fSAndroid Build Coastguard Worker 
181*6a54128fSAndroid Build Coastguard Worker #define EXT2_FILE_MASK		0x00FF
182*6a54128fSAndroid Build Coastguard Worker 
183*6a54128fSAndroid Build Coastguard Worker #define EXT2_FILE_BUF_DIRTY	0x4000
184*6a54128fSAndroid Build Coastguard Worker #define EXT2_FILE_BUF_VALID	0x2000
185*6a54128fSAndroid Build Coastguard Worker 
186*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_file *ext2_file_t;
187*6a54128fSAndroid Build Coastguard Worker 
188*6a54128fSAndroid Build Coastguard Worker #define EXT2_SEEK_SET	0
189*6a54128fSAndroid Build Coastguard Worker #define EXT2_SEEK_CUR	1
190*6a54128fSAndroid Build Coastguard Worker #define EXT2_SEEK_END	2
191*6a54128fSAndroid Build Coastguard Worker 
192*6a54128fSAndroid Build Coastguard Worker /*
193*6a54128fSAndroid Build Coastguard Worker  * Flags for the ext2_filsys structure and for ext2fs_open()
194*6a54128fSAndroid Build Coastguard Worker  */
195*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_RW			0x01
196*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_CHANGED		0x02
197*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_DIRTY			0x04
198*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_VALID			0x08
199*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_IB_DIRTY		0x10
200*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_BB_DIRTY		0x20
201*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SWAP_BYTES		0x40
202*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SWAP_BYTES_READ	0x80
203*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SWAP_BYTES_WRITE	0x100
204*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_MASTER_SB_ONLY	0x200
205*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_FORCE			0x400
206*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SUPER_ONLY		0x800
207*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_JOURNAL_DEV_OK	0x1000
208*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_IMAGE_FILE		0x2000
209*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_EXCLUSIVE		0x4000
210*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SOFTSUPP_FEATURES	0x8000
211*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_NOFREE_ON_ERROR	0x10000
212*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_64BITS		0x20000
213*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_PRINT_PROGRESS	0x40000
214*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_DIRECT_IO		0x80000
215*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SKIP_MMP		0x100000
216*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_IGNORE_CSUM_ERRORS	0x200000
217*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_SHARE_DUP		0x400000
218*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_IGNORE_SB_ERRORS	0x800000
219*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_BBITMAP_TAIL_PROBLEM	0x1000000
220*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_IBITMAP_TAIL_PROBLEM	0x2000000
221*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_THREADS		0x4000000
222*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_IGNORE_SWAP_DIRENT	0x8000000
223*6a54128fSAndroid Build Coastguard Worker 
224*6a54128fSAndroid Build Coastguard Worker /*
225*6a54128fSAndroid Build Coastguard Worker  * Special flag in the ext2 inode i_flag field that means that this is
226*6a54128fSAndroid Build Coastguard Worker  * a new inode.  (So that ext2_write_inode() can clear extra fields.)
227*6a54128fSAndroid Build Coastguard Worker  */
228*6a54128fSAndroid Build Coastguard Worker #define EXT2_NEW_INODE_FL	0x80000000
229*6a54128fSAndroid Build Coastguard Worker 
230*6a54128fSAndroid Build Coastguard Worker /*
231*6a54128fSAndroid Build Coastguard Worker  * Flags for mkjournal
232*6a54128fSAndroid Build Coastguard Worker  */
233*6a54128fSAndroid Build Coastguard Worker #define EXT2_MKJOURNAL_V1_SUPER	0x0000001 /* create V1 superblock (deprecated) */
234*6a54128fSAndroid Build Coastguard Worker #define EXT2_MKJOURNAL_LAZYINIT	0x0000002 /* don't zero journal inode before use*/
235*6a54128fSAndroid Build Coastguard Worker #define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */
236*6a54128fSAndroid Build Coastguard Worker 
237*6a54128fSAndroid Build Coastguard Worker /*
238*6a54128fSAndroid Build Coastguard Worker  * Normal journal area size to fast commit area size ratio. This is used to
239*6a54128fSAndroid Build Coastguard Worker  * set default size of fast commit area.
240*6a54128fSAndroid Build Coastguard Worker  */
241*6a54128fSAndroid Build Coastguard Worker #define EXT2_JOURNAL_TO_FC_BLKS_RATIO		64
242*6a54128fSAndroid Build Coastguard Worker 
243*6a54128fSAndroid Build Coastguard Worker struct blk_alloc_ctx;
244*6a54128fSAndroid Build Coastguard Worker struct opaque_ext2_group_desc;
245*6a54128fSAndroid Build Coastguard Worker 
246*6a54128fSAndroid Build Coastguard Worker struct struct_ext2_filsys {
247*6a54128fSAndroid Build Coastguard Worker 	errcode_t			magic;
248*6a54128fSAndroid Build Coastguard Worker 	io_channel			io;
249*6a54128fSAndroid Build Coastguard Worker 	int				flags;
250*6a54128fSAndroid Build Coastguard Worker 	char *				device_name;
251*6a54128fSAndroid Build Coastguard Worker 	struct ext2_super_block	* 	super;
252*6a54128fSAndroid Build Coastguard Worker 	unsigned int			blocksize;
253*6a54128fSAndroid Build Coastguard Worker 	int				fragsize;
254*6a54128fSAndroid Build Coastguard Worker 	dgrp_t				group_desc_count;
255*6a54128fSAndroid Build Coastguard Worker 	unsigned long			desc_blocks;
256*6a54128fSAndroid Build Coastguard Worker 	struct opaque_ext2_group_desc *	group_desc;
257*6a54128fSAndroid Build Coastguard Worker 	unsigned int			inode_blocks_per_group;
258*6a54128fSAndroid Build Coastguard Worker 	ext2fs_inode_bitmap		inode_map;
259*6a54128fSAndroid Build Coastguard Worker 	ext2fs_block_bitmap		block_map;
260*6a54128fSAndroid Build Coastguard Worker 	/* XXX FIXME-64: not 64-bit safe, but not used? */
261*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
262*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino);
263*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*write_bitmaps)(ext2_filsys fs);
264*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino,
265*6a54128fSAndroid Build Coastguard Worker 				struct ext2_inode *inode);
266*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino,
267*6a54128fSAndroid Build Coastguard Worker 				struct ext2_inode *inode);
268*6a54128fSAndroid Build Coastguard Worker 	ext2_badblocks_list		badblocks;
269*6a54128fSAndroid Build Coastguard Worker 	ext2_dblist			dblist;
270*6a54128fSAndroid Build Coastguard Worker 	__u32				stride;	/* for mke2fs */
271*6a54128fSAndroid Build Coastguard Worker 	struct ext2_super_block *	orig_super;
272*6a54128fSAndroid Build Coastguard Worker 	struct ext2_image_hdr *		image_header;
273*6a54128fSAndroid Build Coastguard Worker 	__u32				umask;
274*6a54128fSAndroid Build Coastguard Worker 	time_t				now;
275*6a54128fSAndroid Build Coastguard Worker 	int				cluster_ratio_bits;
276*6a54128fSAndroid Build Coastguard Worker 	__u16				default_bitmap_type;
277*6a54128fSAndroid Build Coastguard Worker 	__u16				pad;
278*6a54128fSAndroid Build Coastguard Worker 	/*
279*6a54128fSAndroid Build Coastguard Worker 	 * Reserved for future expansion
280*6a54128fSAndroid Build Coastguard Worker 	 */
281*6a54128fSAndroid Build Coastguard Worker 	__u32				reserved[5];
282*6a54128fSAndroid Build Coastguard Worker 
283*6a54128fSAndroid Build Coastguard Worker 	/*
284*6a54128fSAndroid Build Coastguard Worker 	 * Reserved for the use of the calling application.
285*6a54128fSAndroid Build Coastguard Worker 	 */
286*6a54128fSAndroid Build Coastguard Worker 	void *				priv_data;
287*6a54128fSAndroid Build Coastguard Worker 
288*6a54128fSAndroid Build Coastguard Worker 	/*
289*6a54128fSAndroid Build Coastguard Worker 	 * Inode cache
290*6a54128fSAndroid Build Coastguard Worker 	 */
291*6a54128fSAndroid Build Coastguard Worker 	struct ext2_inode_cache		*icache;
292*6a54128fSAndroid Build Coastguard Worker 	io_channel			image_io;
293*6a54128fSAndroid Build Coastguard Worker 
294*6a54128fSAndroid Build Coastguard Worker 	/*
295*6a54128fSAndroid Build Coastguard Worker 	 * More callback functions
296*6a54128fSAndroid Build Coastguard Worker 	 */
297*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*get_alloc_block)(ext2_filsys fs, blk64_t goal,
298*6a54128fSAndroid Build Coastguard Worker 				     blk64_t *ret);
299*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*get_alloc_block2)(ext2_filsys fs, blk64_t goal,
300*6a54128fSAndroid Build Coastguard Worker 				      blk64_t *ret, struct blk_alloc_ctx *ctx);
301*6a54128fSAndroid Build Coastguard Worker 	void (*block_alloc_stats)(ext2_filsys fs, blk64_t blk, int inuse);
302*6a54128fSAndroid Build Coastguard Worker 
303*6a54128fSAndroid Build Coastguard Worker 	/*
304*6a54128fSAndroid Build Coastguard Worker 	 * Buffers for Multiple mount protection(MMP) block.
305*6a54128fSAndroid Build Coastguard Worker 	 */
306*6a54128fSAndroid Build Coastguard Worker 	void *mmp_buf;
307*6a54128fSAndroid Build Coastguard Worker 	void *mmp_cmp;
308*6a54128fSAndroid Build Coastguard Worker 	int mmp_fd;
309*6a54128fSAndroid Build Coastguard Worker 
310*6a54128fSAndroid Build Coastguard Worker 	/*
311*6a54128fSAndroid Build Coastguard Worker 	 * Time at which e2fsck last updated the MMP block.
312*6a54128fSAndroid Build Coastguard Worker 	 */
313*6a54128fSAndroid Build Coastguard Worker 	long mmp_last_written;
314*6a54128fSAndroid Build Coastguard Worker 
315*6a54128fSAndroid Build Coastguard Worker 	/* progress operation functions */
316*6a54128fSAndroid Build Coastguard Worker 	struct ext2fs_progress_ops *progress_ops;
317*6a54128fSAndroid Build Coastguard Worker 
318*6a54128fSAndroid Build Coastguard Worker 	/* Precomputed FS UUID checksum for seeding other checksums */
319*6a54128fSAndroid Build Coastguard Worker 	__u32 csum_seed;
320*6a54128fSAndroid Build Coastguard Worker 
321*6a54128fSAndroid Build Coastguard Worker 	io_channel			journal_io;
322*6a54128fSAndroid Build Coastguard Worker 	char				*journal_name;
323*6a54128fSAndroid Build Coastguard Worker 
324*6a54128fSAndroid Build Coastguard Worker 	/* New block range allocation hooks */
325*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*new_range)(ext2_filsys fs, int flags, blk64_t goal,
326*6a54128fSAndroid Build Coastguard Worker 			       blk64_t len, blk64_t *pblk, blk64_t *plen);
327*6a54128fSAndroid Build Coastguard Worker 	void (*block_alloc_stats_range)(ext2_filsys fs, blk64_t blk, blk_t num,
328*6a54128fSAndroid Build Coastguard Worker 					int inuse);
329*6a54128fSAndroid Build Coastguard Worker 
330*6a54128fSAndroid Build Coastguard Worker 	/* hashmap for SHA of data blocks */
331*6a54128fSAndroid Build Coastguard Worker 	struct ext2fs_hashmap* block_sha_map;
332*6a54128fSAndroid Build Coastguard Worker 
333*6a54128fSAndroid Build Coastguard Worker 	const struct ext2fs_nls_table *encoding;
334*6a54128fSAndroid Build Coastguard Worker };
335*6a54128fSAndroid Build Coastguard Worker 
336*6a54128fSAndroid Build Coastguard Worker #if EXT2_FLAT_INCLUDES
337*6a54128fSAndroid Build Coastguard Worker #include "e2_bitops.h"
338*6a54128fSAndroid Build Coastguard Worker #else
339*6a54128fSAndroid Build Coastguard Worker #include <ext2fs/bitops.h>
340*6a54128fSAndroid Build Coastguard Worker #endif
341*6a54128fSAndroid Build Coastguard Worker 
342*6a54128fSAndroid Build Coastguard Worker /*
343*6a54128fSAndroid Build Coastguard Worker  * 64-bit bitmap backend types
344*6a54128fSAndroid Build Coastguard Worker  */
345*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BMAP64_BITARRAY	1
346*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BMAP64_RBTREE	2
347*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BMAP64_AUTODIR	3
348*6a54128fSAndroid Build Coastguard Worker 
349*6a54128fSAndroid Build Coastguard Worker /*
350*6a54128fSAndroid Build Coastguard Worker  * Return flags for the block iterator functions
351*6a54128fSAndroid Build Coastguard Worker  */
352*6a54128fSAndroid Build Coastguard Worker #define BLOCK_CHANGED			1
353*6a54128fSAndroid Build Coastguard Worker #define BLOCK_ABORT			2
354*6a54128fSAndroid Build Coastguard Worker #define BLOCK_ERROR			4
355*6a54128fSAndroid Build Coastguard Worker #define BLOCK_INLINE_DATA_CHANGED	8
356*6a54128fSAndroid Build Coastguard Worker 
357*6a54128fSAndroid Build Coastguard Worker /*
358*6a54128fSAndroid Build Coastguard Worker  * Block iterate flags
359*6a54128fSAndroid Build Coastguard Worker  *
360*6a54128fSAndroid Build Coastguard Worker  * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the iterator
361*6a54128fSAndroid Build Coastguard Worker  * function should be called on blocks where the block number is zero.
362*6a54128fSAndroid Build Coastguard Worker  * This is used by ext2fs_expand_dir() to be able to add a new block
363*6a54128fSAndroid Build Coastguard Worker  * to an inode.  It can also be used for programs that want to be able
364*6a54128fSAndroid Build Coastguard Worker  * to deal with files that contain "holes".
365*6a54128fSAndroid Build Coastguard Worker  *
366*6a54128fSAndroid Build Coastguard Worker  * BLOCK_FLAG_DEPTH_TRAVERSE indicates that the iterator function for
367*6a54128fSAndroid Build Coastguard Worker  * the indirect, doubly indirect, etc. blocks should be called after
368*6a54128fSAndroid Build Coastguard Worker  * all of the blocks contained in the indirect blocks are processed.
369*6a54128fSAndroid Build Coastguard Worker  * This is useful if you are going to be deallocating blocks from an
370*6a54128fSAndroid Build Coastguard Worker  * inode.
371*6a54128fSAndroid Build Coastguard Worker  *
372*6a54128fSAndroid Build Coastguard Worker  * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be
373*6a54128fSAndroid Build Coastguard Worker  * called for data blocks only.
374*6a54128fSAndroid Build Coastguard Worker  *
375*6a54128fSAndroid Build Coastguard Worker  * BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not
376*6a54128fSAndroid Build Coastguard Worker  * modify returned block number.
377*6a54128fSAndroid Build Coastguard Worker  *
378*6a54128fSAndroid Build Coastguard Worker  * BLOCK_FLAG_NO_LARGE is for internal use only.  It informs
379*6a54128fSAndroid Build Coastguard Worker  * ext2fs_block_iterate2 that large files won't be accepted.
380*6a54128fSAndroid Build Coastguard Worker  */
381*6a54128fSAndroid Build Coastguard Worker #define BLOCK_FLAG_APPEND	1
382*6a54128fSAndroid Build Coastguard Worker #define BLOCK_FLAG_HOLE		1
383*6a54128fSAndroid Build Coastguard Worker #define BLOCK_FLAG_DEPTH_TRAVERSE	2
384*6a54128fSAndroid Build Coastguard Worker #define BLOCK_FLAG_DATA_ONLY	4
385*6a54128fSAndroid Build Coastguard Worker #define BLOCK_FLAG_READ_ONLY	8
386*6a54128fSAndroid Build Coastguard Worker 
387*6a54128fSAndroid Build Coastguard Worker #define BLOCK_FLAG_NO_LARGE	0x1000
388*6a54128fSAndroid Build Coastguard Worker 
389*6a54128fSAndroid Build Coastguard Worker /*
390*6a54128fSAndroid Build Coastguard Worker  * Magic "block count" return values for the block iterator function.
391*6a54128fSAndroid Build Coastguard Worker  */
392*6a54128fSAndroid Build Coastguard Worker #define BLOCK_COUNT_IND		(-1)
393*6a54128fSAndroid Build Coastguard Worker #define BLOCK_COUNT_DIND	(-2)
394*6a54128fSAndroid Build Coastguard Worker #define BLOCK_COUNT_TIND	(-3)
395*6a54128fSAndroid Build Coastguard Worker #define BLOCK_COUNT_TRANSLATOR	(-4)
396*6a54128fSAndroid Build Coastguard Worker 
397*6a54128fSAndroid Build Coastguard Worker #define BLOCK_ALLOC_UNKNOWN	0
398*6a54128fSAndroid Build Coastguard Worker #define BLOCK_ALLOC_DATA	1
399*6a54128fSAndroid Build Coastguard Worker #define BLOCK_ALLOC_METADATA	2
400*6a54128fSAndroid Build Coastguard Worker 
401*6a54128fSAndroid Build Coastguard Worker struct blk_alloc_ctx {
402*6a54128fSAndroid Build Coastguard Worker 	ext2_ino_t		ino;
403*6a54128fSAndroid Build Coastguard Worker 	struct ext2_inode	*inode;
404*6a54128fSAndroid Build Coastguard Worker 	blk64_t			lblk;
405*6a54128fSAndroid Build Coastguard Worker 	int			flags;
406*6a54128fSAndroid Build Coastguard Worker };
407*6a54128fSAndroid Build Coastguard Worker 
408*6a54128fSAndroid Build Coastguard Worker #if 0
409*6a54128fSAndroid Build Coastguard Worker /*
410*6a54128fSAndroid Build Coastguard Worker  * Flags for ext2fs_move_blocks
411*6a54128fSAndroid Build Coastguard Worker  */
412*6a54128fSAndroid Build Coastguard Worker #define EXT2_BMOVE_GET_DBLIST	0x0001
413*6a54128fSAndroid Build Coastguard Worker #define EXT2_BMOVE_DEBUG	0x0002
414*6a54128fSAndroid Build Coastguard Worker #endif
415*6a54128fSAndroid Build Coastguard Worker 
416*6a54128fSAndroid Build Coastguard Worker /*
417*6a54128fSAndroid Build Coastguard Worker  * Generic (non-filesystem layout specific) extents structure
418*6a54128fSAndroid Build Coastguard Worker  */
419*6a54128fSAndroid Build Coastguard Worker 
420*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_FLAGS_LEAF		0x0001
421*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_FLAGS_UNINIT	0x0002
422*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_FLAGS_SECOND_VISIT	0x0004
423*6a54128fSAndroid Build Coastguard Worker 
424*6a54128fSAndroid Build Coastguard Worker struct ext2fs_extent {
425*6a54128fSAndroid Build Coastguard Worker 	blk64_t	e_pblk;		/* first physical block */
426*6a54128fSAndroid Build Coastguard Worker 	blk64_t	e_lblk;		/* first logical block extent covers */
427*6a54128fSAndroid Build Coastguard Worker 	__u32	e_len;		/* number of blocks covered by extent */
428*6a54128fSAndroid Build Coastguard Worker 	__u32	e_flags;	/* extent flags */
429*6a54128fSAndroid Build Coastguard Worker };
430*6a54128fSAndroid Build Coastguard Worker 
431*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_extent_handle *ext2_extent_handle_t;
432*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_extent_path *ext2_extent_path_t;
433*6a54128fSAndroid Build Coastguard Worker 
434*6a54128fSAndroid Build Coastguard Worker /*
435*6a54128fSAndroid Build Coastguard Worker  * Flags used by ext2fs_extent_get()
436*6a54128fSAndroid Build Coastguard Worker  */
437*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_CURRENT	0x0000
438*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_MOVE_MASK	0x000F
439*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_ROOT	0x0001
440*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_LAST_LEAF	0x0002
441*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_FIRST_SIB	0x0003
442*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_LAST_SIB	0x0004
443*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_NEXT_SIB	0x0005
444*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_PREV_SIB	0x0006
445*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_NEXT_LEAF	0x0007
446*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_PREV_LEAF	0x0008
447*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_NEXT	0x0009
448*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_PREV	0x000A
449*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_UP		0x000B
450*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_DOWN	0x000C
451*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_DOWN_AND_LAST 0x000D
452*6a54128fSAndroid Build Coastguard Worker 
453*6a54128fSAndroid Build Coastguard Worker /*
454*6a54128fSAndroid Build Coastguard Worker  * Flags used by ext2fs_extent_insert()
455*6a54128fSAndroid Build Coastguard Worker  */
456*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_INSERT_AFTER	0x0001 /* insert after handle loc'n */
457*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_INSERT_NOSPLIT	0x0002 /* insert may not cause split */
458*6a54128fSAndroid Build Coastguard Worker 
459*6a54128fSAndroid Build Coastguard Worker /*
460*6a54128fSAndroid Build Coastguard Worker  * Flags used by ext2fs_extent_delete()
461*6a54128fSAndroid Build Coastguard Worker  */
462*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_DELETE_KEEP_EMPTY	0x001 /* keep node if last extent gone */
463*6a54128fSAndroid Build Coastguard Worker 
464*6a54128fSAndroid Build Coastguard Worker /*
465*6a54128fSAndroid Build Coastguard Worker  * Flags used by ext2fs_extent_set_bmap()
466*6a54128fSAndroid Build Coastguard Worker  */
467*6a54128fSAndroid Build Coastguard Worker #define EXT2_EXTENT_SET_BMAP_UNINIT	0x0001
468*6a54128fSAndroid Build Coastguard Worker 
469*6a54128fSAndroid Build Coastguard Worker /*
470*6a54128fSAndroid Build Coastguard Worker  * Data structure returned by ext2fs_extent_get_info()
471*6a54128fSAndroid Build Coastguard Worker  */
472*6a54128fSAndroid Build Coastguard Worker struct ext2_extent_info {
473*6a54128fSAndroid Build Coastguard Worker 	int		curr_entry;
474*6a54128fSAndroid Build Coastguard Worker 	int		curr_level;
475*6a54128fSAndroid Build Coastguard Worker 	int		num_entries;
476*6a54128fSAndroid Build Coastguard Worker 	int		max_entries;
477*6a54128fSAndroid Build Coastguard Worker 	int		max_depth;
478*6a54128fSAndroid Build Coastguard Worker 	int		bytes_avail;
479*6a54128fSAndroid Build Coastguard Worker 	blk64_t		max_lblk;
480*6a54128fSAndroid Build Coastguard Worker 	blk64_t		max_pblk;
481*6a54128fSAndroid Build Coastguard Worker 	__u32		max_len;
482*6a54128fSAndroid Build Coastguard Worker 	__u32		max_uninit_len;
483*6a54128fSAndroid Build Coastguard Worker };
484*6a54128fSAndroid Build Coastguard Worker 
485*6a54128fSAndroid Build Coastguard Worker /*
486*6a54128fSAndroid Build Coastguard Worker  * Flags for directory block reading and writing functions
487*6a54128fSAndroid Build Coastguard Worker  */
488*6a54128fSAndroid Build Coastguard Worker #define EXT2_DIRBLOCK_V2_STRUCT	0x0001
489*6a54128fSAndroid Build Coastguard Worker 
490*6a54128fSAndroid Build Coastguard Worker /*
491*6a54128fSAndroid Build Coastguard Worker  * Return flags for the directory iterator functions
492*6a54128fSAndroid Build Coastguard Worker  */
493*6a54128fSAndroid Build Coastguard Worker #define DIRENT_CHANGED	1
494*6a54128fSAndroid Build Coastguard Worker #define DIRENT_ABORT	2
495*6a54128fSAndroid Build Coastguard Worker #define DIRENT_ERROR	3
496*6a54128fSAndroid Build Coastguard Worker 
497*6a54128fSAndroid Build Coastguard Worker /*
498*6a54128fSAndroid Build Coastguard Worker  * Directory iterator flags
499*6a54128fSAndroid Build Coastguard Worker  */
500*6a54128fSAndroid Build Coastguard Worker 
501*6a54128fSAndroid Build Coastguard Worker #define DIRENT_FLAG_INCLUDE_EMPTY	1
502*6a54128fSAndroid Build Coastguard Worker #define DIRENT_FLAG_INCLUDE_REMOVED	2
503*6a54128fSAndroid Build Coastguard Worker #define DIRENT_FLAG_INCLUDE_CSUM	4
504*6a54128fSAndroid Build Coastguard Worker #define DIRENT_FLAG_INCLUDE_INLINE_DATA 8
505*6a54128fSAndroid Build Coastguard Worker 
506*6a54128fSAndroid Build Coastguard Worker #define DIRENT_DOT_FILE		1
507*6a54128fSAndroid Build Coastguard Worker #define DIRENT_DOT_DOT_FILE	2
508*6a54128fSAndroid Build Coastguard Worker #define DIRENT_OTHER_FILE	3
509*6a54128fSAndroid Build Coastguard Worker #define DIRENT_DELETED_FILE	4
510*6a54128fSAndroid Build Coastguard Worker #define DIRENT_CHECKSUM		5
511*6a54128fSAndroid Build Coastguard Worker 
512*6a54128fSAndroid Build Coastguard Worker /*
513*6a54128fSAndroid Build Coastguard Worker  * Inode scan definitions
514*6a54128fSAndroid Build Coastguard Worker  */
515*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_struct_inode_scan *ext2_inode_scan;
516*6a54128fSAndroid Build Coastguard Worker 
517*6a54128fSAndroid Build Coastguard Worker /*
518*6a54128fSAndroid Build Coastguard Worker  * ext2fs_scan flags
519*6a54128fSAndroid Build Coastguard Worker  */
520*6a54128fSAndroid Build Coastguard Worker #define EXT2_SF_CHK_BADBLOCKS	0x0001
521*6a54128fSAndroid Build Coastguard Worker #define EXT2_SF_BAD_INODE_BLK	0x0002
522*6a54128fSAndroid Build Coastguard Worker #define EXT2_SF_BAD_EXTRA_BYTES	0x0004
523*6a54128fSAndroid Build Coastguard Worker #define EXT2_SF_SKIP_MISSING_ITABLE	0x0008
524*6a54128fSAndroid Build Coastguard Worker #define EXT2_SF_DO_LAZY		0x0010
525*6a54128fSAndroid Build Coastguard Worker #define EXT2_SF_WARN_GARBAGE_INODES	0x0020
526*6a54128fSAndroid Build Coastguard Worker 
527*6a54128fSAndroid Build Coastguard Worker /*
528*6a54128fSAndroid Build Coastguard Worker  * ext2fs_check_if_mounted flags
529*6a54128fSAndroid Build Coastguard Worker  */
530*6a54128fSAndroid Build Coastguard Worker #define EXT2_MF_MOUNTED		1
531*6a54128fSAndroid Build Coastguard Worker #define EXT2_MF_ISROOT		2
532*6a54128fSAndroid Build Coastguard Worker #define EXT2_MF_READONLY	4
533*6a54128fSAndroid Build Coastguard Worker #define EXT2_MF_SWAP		8
534*6a54128fSAndroid Build Coastguard Worker #define EXT2_MF_BUSY		16
535*6a54128fSAndroid Build Coastguard Worker 
536*6a54128fSAndroid Build Coastguard Worker /*
537*6a54128fSAndroid Build Coastguard Worker  * Ext2/linux mode flags.  We define them here so that we don't need
538*6a54128fSAndroid Build Coastguard Worker  * to depend on the OS's sys/stat.h, since we may be compiling on a
539*6a54128fSAndroid Build Coastguard Worker  * non-Linux system.
540*6a54128fSAndroid Build Coastguard Worker  */
541*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFMT  00170000
542*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFSOCK 0140000
543*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFLNK	 0120000
544*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFREG  0100000
545*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFBLK  0060000
546*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFDIR  0040000
547*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFCHR  0020000
548*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IFIFO  0010000
549*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISUID  0004000
550*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISGID  0002000
551*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISVTX  0001000
552*6a54128fSAndroid Build Coastguard Worker 
553*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IRWXU 00700
554*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IRUSR 00400
555*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IWUSR 00200
556*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IXUSR 00100
557*6a54128fSAndroid Build Coastguard Worker 
558*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IRWXG 00070
559*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IRGRP 00040
560*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IWGRP 00020
561*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IXGRP 00010
562*6a54128fSAndroid Build Coastguard Worker 
563*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IRWXO 00007
564*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IROTH 00004
565*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IWOTH 00002
566*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_IXOTH 00001
567*6a54128fSAndroid Build Coastguard Worker 
568*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISLNK(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
569*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISREG(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
570*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISDIR(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
571*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISCHR(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
572*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISBLK(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
573*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISFIFO(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
574*6a54128fSAndroid Build Coastguard Worker #define LINUX_S_ISSOCK(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
575*6a54128fSAndroid Build Coastguard Worker 
576*6a54128fSAndroid Build Coastguard Worker /*
577*6a54128fSAndroid Build Coastguard Worker  * ext2 size of an inode
578*6a54128fSAndroid Build Coastguard Worker  */
579*6a54128fSAndroid Build Coastguard Worker #define EXT2_I_SIZE(i)	((i)->i_size | ((__u64) (i)->i_size_high << 32))
580*6a54128fSAndroid Build Coastguard Worker 
581*6a54128fSAndroid Build Coastguard Worker /*
582*6a54128fSAndroid Build Coastguard Worker  * ext2_icount_t abstraction
583*6a54128fSAndroid Build Coastguard Worker  */
584*6a54128fSAndroid Build Coastguard Worker #define EXT2_ICOUNT_OPT_INCREMENT	0x01
585*6a54128fSAndroid Build Coastguard Worker #define EXT2_ICOUNT_OPT_FULLMAP		0x02
586*6a54128fSAndroid Build Coastguard Worker 
587*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_icount *ext2_icount_t;
588*6a54128fSAndroid Build Coastguard Worker 
589*6a54128fSAndroid Build Coastguard Worker /*
590*6a54128fSAndroid Build Coastguard Worker  * Flags for ext2fs_bmap
591*6a54128fSAndroid Build Coastguard Worker  */
592*6a54128fSAndroid Build Coastguard Worker #define BMAP_ALLOC	0x0001
593*6a54128fSAndroid Build Coastguard Worker #define BMAP_SET	0x0002
594*6a54128fSAndroid Build Coastguard Worker #define BMAP_UNINIT	0x0004
595*6a54128fSAndroid Build Coastguard Worker #define BMAP_ZERO	0x0008
596*6a54128fSAndroid Build Coastguard Worker 
597*6a54128fSAndroid Build Coastguard Worker /*
598*6a54128fSAndroid Build Coastguard Worker  * Returned flags from ext2fs_bmap
599*6a54128fSAndroid Build Coastguard Worker  */
600*6a54128fSAndroid Build Coastguard Worker #define BMAP_RET_UNINIT	0x0001
601*6a54128fSAndroid Build Coastguard Worker 
602*6a54128fSAndroid Build Coastguard Worker /*
603*6a54128fSAndroid Build Coastguard Worker  * Flags for ext2fs_read_inode2
604*6a54128fSAndroid Build Coastguard Worker  */
605*6a54128fSAndroid Build Coastguard Worker #define READ_INODE_NOCSUM	0x0001
606*6a54128fSAndroid Build Coastguard Worker 
607*6a54128fSAndroid Build Coastguard Worker /*
608*6a54128fSAndroid Build Coastguard Worker  * Flags for ext2fs_write_inode2
609*6a54128fSAndroid Build Coastguard Worker  */
610*6a54128fSAndroid Build Coastguard Worker #define WRITE_INODE_NOCSUM	0x0001
611*6a54128fSAndroid Build Coastguard Worker 
612*6a54128fSAndroid Build Coastguard Worker /*
613*6a54128fSAndroid Build Coastguard Worker  * Flags for imager.c functions
614*6a54128fSAndroid Build Coastguard Worker  */
615*6a54128fSAndroid Build Coastguard Worker #define IMAGER_FLAG_INODEMAP	1
616*6a54128fSAndroid Build Coastguard Worker #define IMAGER_FLAG_SPARSEWRITE	2
617*6a54128fSAndroid Build Coastguard Worker 
618*6a54128fSAndroid Build Coastguard Worker /*
619*6a54128fSAndroid Build Coastguard Worker  * For checking structure magic numbers...
620*6a54128fSAndroid Build Coastguard Worker  */
621*6a54128fSAndroid Build Coastguard Worker 
622*6a54128fSAndroid Build Coastguard Worker #define EXT2_CHECK_MAGIC(struct, code) \
623*6a54128fSAndroid Build Coastguard Worker 	  if ((struct)->magic != (code)) return (code)
624*6a54128fSAndroid Build Coastguard Worker 
625*6a54128fSAndroid Build Coastguard Worker /*
626*6a54128fSAndroid Build Coastguard Worker  * Features supported by this version of the library
627*6a54128fSAndroid Build Coastguard Worker  */
628*6a54128fSAndroid Build Coastguard Worker #define EXT2_LIB_FEATURE_COMPAT_SUPP	(EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
629*6a54128fSAndroid Build Coastguard Worker 					 EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
630*6a54128fSAndroid Build Coastguard Worker 					 EXT3_FEATURE_COMPAT_HAS_JOURNAL|\
631*6a54128fSAndroid Build Coastguard Worker 					 EXT2_FEATURE_COMPAT_RESIZE_INODE|\
632*6a54128fSAndroid Build Coastguard Worker 					 EXT2_FEATURE_COMPAT_DIR_INDEX|\
633*6a54128fSAndroid Build Coastguard Worker 					 EXT2_FEATURE_COMPAT_EXT_ATTR|\
634*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_COMPAT_SPARSE_SUPER2|\
635*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_COMPAT_FAST_COMMIT|\
636*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_COMPAT_STABLE_INODES)
637*6a54128fSAndroid Build Coastguard Worker 
638*6a54128fSAndroid Build Coastguard Worker #ifdef CONFIG_MMP
639*6a54128fSAndroid Build Coastguard Worker #define EXT4_LIB_INCOMPAT_MMP		EXT4_FEATURE_INCOMPAT_MMP
640*6a54128fSAndroid Build Coastguard Worker #else
641*6a54128fSAndroid Build Coastguard Worker #define EXT4_LIB_INCOMPAT_MMP		(0)
642*6a54128fSAndroid Build Coastguard Worker #endif
643*6a54128fSAndroid Build Coastguard Worker 
644*6a54128fSAndroid Build Coastguard Worker #define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
645*6a54128fSAndroid Build Coastguard Worker 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
646*6a54128fSAndroid Build Coastguard Worker 					 EXT2_FEATURE_INCOMPAT_META_BG|\
647*6a54128fSAndroid Build Coastguard Worker 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
648*6a54128fSAndroid Build Coastguard Worker 					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
649*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_FLEX_BG|\
650*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_EA_INODE|\
651*6a54128fSAndroid Build Coastguard Worker 					 EXT4_LIB_INCOMPAT_MMP|\
652*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_64BIT|\
653*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_INLINE_DATA|\
654*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_ENCRYPT|\
655*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_CASEFOLD|\
656*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_CSUM_SEED|\
657*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_INCOMPAT_LARGEDIR)
658*6a54128fSAndroid Build Coastguard Worker 
659*6a54128fSAndroid Build Coastguard Worker #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
660*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
661*6a54128fSAndroid Build Coastguard Worker 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
662*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
663*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
664*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
665*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_BIGALLOC|\
666*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_QUOTA|\
667*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
668*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_READONLY |\
669*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_PROJECT |\
670*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS |\
671*6a54128fSAndroid Build Coastguard Worker 					 EXT4_FEATURE_RO_COMPAT_VERITY)
672*6a54128fSAndroid Build Coastguard Worker 
673*6a54128fSAndroid Build Coastguard Worker /*
674*6a54128fSAndroid Build Coastguard Worker  * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
675*6a54128fSAndroid Build Coastguard Worker  * to ext2fs_openfs()
676*6a54128fSAndroid Build Coastguard Worker  */
677*6a54128fSAndroid Build Coastguard Worker #define EXT2_LIB_SOFTSUPP_INCOMPAT	(0)
678*6a54128fSAndroid Build Coastguard Worker #define EXT2_LIB_SOFTSUPP_RO_COMPAT	(EXT4_FEATURE_RO_COMPAT_REPLICA)
679*6a54128fSAndroid Build Coastguard Worker 
680*6a54128fSAndroid Build Coastguard Worker 
681*6a54128fSAndroid Build Coastguard Worker /* Translate a block number to a cluster number */
682*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_CLUSTER_RATIO(fs)	(1 << (fs)->cluster_ratio_bits)
683*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_CLUSTER_MASK(fs)		(EXT2FS_CLUSTER_RATIO(fs) - 1)
684*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_B2C(fs, blk)		((blk) >> (fs)->cluster_ratio_bits)
685*6a54128fSAndroid Build Coastguard Worker /* Translate a cluster number to a block number */
686*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_C2B(fs, cluster)		((cluster) << (fs)->cluster_ratio_bits)
687*6a54128fSAndroid Build Coastguard Worker /* Translate # of blks to # of clusters */
688*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_NUM_B2C(fs, blks)	(((blks) + EXT2FS_CLUSTER_MASK(fs)) >> \
689*6a54128fSAndroid Build Coastguard Worker 					 (fs)->cluster_ratio_bits)
690*6a54128fSAndroid Build Coastguard Worker 
691*6a54128fSAndroid Build Coastguard Worker #if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
692*6a54128fSAndroid Build Coastguard Worker typedef struct stat64 ext2fs_struct_stat;
693*6a54128fSAndroid Build Coastguard Worker #else
694*6a54128fSAndroid Build Coastguard Worker typedef struct stat ext2fs_struct_stat;
695*6a54128fSAndroid Build Coastguard Worker #endif
696*6a54128fSAndroid Build Coastguard Worker 
697*6a54128fSAndroid Build Coastguard Worker /*
698*6a54128fSAndroid Build Coastguard Worker  * For ext2fs_close2() and ext2fs_flush2(), this flag allows you to
699*6a54128fSAndroid Build Coastguard Worker  * avoid the fsync call.
700*6a54128fSAndroid Build Coastguard Worker  */
701*6a54128fSAndroid Build Coastguard Worker #define EXT2_FLAG_FLUSH_NO_SYNC          1
702*6a54128fSAndroid Build Coastguard Worker 
703*6a54128fSAndroid Build Coastguard Worker /*
704*6a54128fSAndroid Build Coastguard Worker  * Modify and iterate extended attributes
705*6a54128fSAndroid Build Coastguard Worker  */
706*6a54128fSAndroid Build Coastguard Worker struct ext2_xattr_handle;
707*6a54128fSAndroid Build Coastguard Worker #define XATTR_ABORT	1
708*6a54128fSAndroid Build Coastguard Worker #define XATTR_CHANGED	2
709*6a54128fSAndroid Build Coastguard Worker 
710*6a54128fSAndroid Build Coastguard Worker /*
711*6a54128fSAndroid Build Coastguard Worker  * flags for ext2fs_rw_bitmaps()
712*6a54128fSAndroid Build Coastguard Worker  */
713*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BITMAPS_WRITE		0x0001
714*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BITMAPS_BLOCK		0x0002
715*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BITMAPS_INODE		0x0004
716*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_BITMAPS_VALID_FLAGS	0x0007
717*6a54128fSAndroid Build Coastguard Worker 
718*6a54128fSAndroid Build Coastguard Worker /*
719*6a54128fSAndroid Build Coastguard Worker  * function prototypes
720*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_has_group_desc_csum(ext2_filsys fs)721*6a54128fSAndroid Build Coastguard Worker static inline int ext2fs_has_group_desc_csum(ext2_filsys fs)
722*6a54128fSAndroid Build Coastguard Worker {
723*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_has_feature_metadata_csum(fs->super) ||
724*6a54128fSAndroid Build Coastguard Worker 	       ext2fs_has_feature_gdt_csum(fs->super);
725*6a54128fSAndroid Build Coastguard Worker }
726*6a54128fSAndroid Build Coastguard Worker 
727*6a54128fSAndroid Build Coastguard Worker /* The LARGE_FILE feature should be set if we have stored files 2GB+ in size */
ext2fs_needs_large_file_feature(unsigned long long file_size)728*6a54128fSAndroid Build Coastguard Worker static inline int ext2fs_needs_large_file_feature(unsigned long long file_size)
729*6a54128fSAndroid Build Coastguard Worker {
730*6a54128fSAndroid Build Coastguard Worker 	return file_size >= 0x80000000ULL;
731*6a54128fSAndroid Build Coastguard Worker }
732*6a54128fSAndroid Build Coastguard Worker 
733*6a54128fSAndroid Build Coastguard Worker /* alloc.c */
734*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group);
735*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode,
736*6a54128fSAndroid Build Coastguard Worker 				  ext2fs_inode_bitmap map, ext2_ino_t *ret);
737*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
738*6a54128fSAndroid Build Coastguard Worker 				  ext2fs_block_bitmap map, blk_t *ret);
739*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
740*6a54128fSAndroid Build Coastguard Worker 				   ext2fs_block_bitmap map, blk64_t *ret);
741*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_new_block3(ext2_filsys fs, blk64_t goal,
742*6a54128fSAndroid Build Coastguard Worker 				   ext2fs_block_bitmap map, blk64_t *ret,
743*6a54128fSAndroid Build Coastguard Worker 				   struct blk_alloc_ctx *ctx);
744*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start,
745*6a54128fSAndroid Build Coastguard Worker 					blk_t finish, int num,
746*6a54128fSAndroid Build Coastguard Worker 					ext2fs_block_bitmap map,
747*6a54128fSAndroid Build Coastguard Worker 					blk_t *ret);
748*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start,
749*6a54128fSAndroid Build Coastguard Worker 					 blk64_t finish, int num,
750*6a54128fSAndroid Build Coastguard Worker 					 ext2fs_block_bitmap map,
751*6a54128fSAndroid Build Coastguard Worker 					 blk64_t *ret);
752*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
753*6a54128fSAndroid Build Coastguard Worker 				    char *block_buf, blk_t *ret);
754*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
755*6a54128fSAndroid Build Coastguard Worker 				     char *block_buf, blk64_t *ret);
756*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_alloc_block3(ext2_filsys fs, blk64_t goal,
757*6a54128fSAndroid Build Coastguard Worker 				     char *block_buf, blk64_t *ret,
758*6a54128fSAndroid Build Coastguard Worker 				     struct blk_alloc_ctx *ctx);
759*6a54128fSAndroid Build Coastguard Worker 
760*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_alloc_block_callback(ext2_filsys fs,
761*6a54128fSAndroid Build Coastguard Worker 					    errcode_t (*func)(ext2_filsys fs,
762*6a54128fSAndroid Build Coastguard Worker 							      blk64_t goal,
763*6a54128fSAndroid Build Coastguard Worker 							      blk64_t *ret),
764*6a54128fSAndroid Build Coastguard Worker 					    errcode_t (**old)(ext2_filsys fs,
765*6a54128fSAndroid Build Coastguard Worker 							      blk64_t goal,
766*6a54128fSAndroid Build Coastguard Worker 							      blk64_t *ret));
767*6a54128fSAndroid Build Coastguard Worker blk64_t ext2fs_find_inode_goal(ext2_filsys fs, ext2_ino_t ino,
768*6a54128fSAndroid Build Coastguard Worker 			       struct ext2_inode *inode, blk64_t lblk);
769*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_new_range_callback(ext2_filsys fs,
770*6a54128fSAndroid Build Coastguard Worker 	errcode_t (*func)(ext2_filsys fs, int flags, blk64_t goal,
771*6a54128fSAndroid Build Coastguard Worker 			       blk64_t len, blk64_t *pblk, blk64_t *plen),
772*6a54128fSAndroid Build Coastguard Worker 	errcode_t (**old)(ext2_filsys fs, int flags, blk64_t goal,
773*6a54128fSAndroid Build Coastguard Worker 			       blk64_t len, blk64_t *pblk, blk64_t *plen));
774*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_block_alloc_stats_range_callback(ext2_filsys fs,
775*6a54128fSAndroid Build Coastguard Worker 	void (*func)(ext2_filsys fs, blk64_t blk,
776*6a54128fSAndroid Build Coastguard Worker 				    blk_t num, int inuse),
777*6a54128fSAndroid Build Coastguard Worker 	void (**old)(ext2_filsys fs, blk64_t blk,
778*6a54128fSAndroid Build Coastguard Worker 				    blk_t num, int inuse));
779*6a54128fSAndroid Build Coastguard Worker #define EXT2_NEWRANGE_FIXED_GOAL	(0x1)
780*6a54128fSAndroid Build Coastguard Worker #define EXT2_NEWRANGE_MIN_LENGTH	(0x2)
781*6a54128fSAndroid Build Coastguard Worker #define EXT2_NEWRANGE_ALL_FLAGS		(0x3)
782*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_new_range(ext2_filsys fs, int flags, blk64_t goal,
783*6a54128fSAndroid Build Coastguard Worker 			   blk64_t len, ext2fs_block_bitmap map, blk64_t *pblk,
784*6a54128fSAndroid Build Coastguard Worker 			   blk64_t *plen);
785*6a54128fSAndroid Build Coastguard Worker #define EXT2_ALLOCRANGE_FIXED_GOAL	(0x1)
786*6a54128fSAndroid Build Coastguard Worker #define EXT2_ALLOCRANGE_ZERO_BLOCKS	(0x2)
787*6a54128fSAndroid Build Coastguard Worker #define EXT2_ALLOCRANGE_ALL_FLAGS	(0x3)
788*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_alloc_range(ext2_filsys fs, int flags, blk64_t goal,
789*6a54128fSAndroid Build Coastguard Worker 			     blk_t len, blk64_t *ret);
790*6a54128fSAndroid Build Coastguard Worker 
791*6a54128fSAndroid Build Coastguard Worker /* alloc_sb.c */
792*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
793*6a54128fSAndroid Build Coastguard Worker 					dgrp_t group,
794*6a54128fSAndroid Build Coastguard Worker 					ext2fs_block_bitmap bmap);
795*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs,
796*6a54128fSAndroid Build Coastguard Worker 						  void (*func)(ext2_filsys fs,
797*6a54128fSAndroid Build Coastguard Worker 							       blk64_t blk,
798*6a54128fSAndroid Build Coastguard Worker 							       int inuse),
799*6a54128fSAndroid Build Coastguard Worker 						  void (**old)(ext2_filsys fs,
800*6a54128fSAndroid Build Coastguard Worker 							       blk64_t blk,
801*6a54128fSAndroid Build Coastguard Worker 							       int inuse));
802*6a54128fSAndroid Build Coastguard Worker 
803*6a54128fSAndroid Build Coastguard Worker /* alloc_stats.c */
804*6a54128fSAndroid Build Coastguard Worker void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse);
805*6a54128fSAndroid Build Coastguard Worker void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
806*6a54128fSAndroid Build Coastguard Worker 			       int inuse, int isdir);
807*6a54128fSAndroid Build Coastguard Worker void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse);
808*6a54128fSAndroid Build Coastguard Worker void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse);
809*6a54128fSAndroid Build Coastguard Worker void ext2fs_block_alloc_stats_range(ext2_filsys fs, blk64_t blk,
810*6a54128fSAndroid Build Coastguard Worker 				    blk_t num, int inuse);
811*6a54128fSAndroid Build Coastguard Worker 
812*6a54128fSAndroid Build Coastguard Worker /* alloc_tables.c */
813*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_allocate_tables(ext2_filsys fs);
814*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
815*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_block_bitmap bmap);
816*6a54128fSAndroid Build Coastguard Worker 
817*6a54128fSAndroid Build Coastguard Worker /* badblocks.c */
818*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_u32_list_create(ext2_u32_list *ret, int size);
819*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk);
820*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk);
821*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_u32_list_test(ext2_u32_list bb, blk_t blk);
822*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb,
823*6a54128fSAndroid Build Coastguard Worker 					       ext2_u32_iterate *ret);
824*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_u32_list_iterate(ext2_u32_iterate iter, blk_t *blk);
825*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_u32_list_iterate_end(ext2_u32_iterate iter);
826*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest);
827*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_u32_list_equal(ext2_u32_list bb1, ext2_u32_list bb2);
828*6a54128fSAndroid Build Coastguard Worker 
829*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret,
830*6a54128fSAndroid Build Coastguard Worker 					    int size);
831*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb,
832*6a54128fSAndroid Build Coastguard Worker 					   blk_t blk);
833*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb,
834*6a54128fSAndroid Build Coastguard Worker 				    blk_t blk);
835*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk);
836*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_badblocks_list_del(ext2_u32_list bb, __u32 blk);
837*6a54128fSAndroid Build Coastguard Worker extern errcode_t
838*6a54128fSAndroid Build Coastguard Worker 	ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb,
839*6a54128fSAndroid Build Coastguard Worker 					    ext2_badblocks_iterate *ret);
840*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter,
841*6a54128fSAndroid Build Coastguard Worker 					 blk_t *blk);
842*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter);
843*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src,
844*6a54128fSAndroid Build Coastguard Worker 				       ext2_badblocks_list *dest);
845*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_badblocks_equal(ext2_badblocks_list bb1,
846*6a54128fSAndroid Build Coastguard Worker 				  ext2_badblocks_list bb2);
847*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_u32_list_count(ext2_u32_list bb);
848*6a54128fSAndroid Build Coastguard Worker 
849*6a54128fSAndroid Build Coastguard Worker /* bb_compat */
850*6a54128fSAndroid Build Coastguard Worker extern errcode_t badblocks_list_create(badblocks_list *ret, int size);
851*6a54128fSAndroid Build Coastguard Worker extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk);
852*6a54128fSAndroid Build Coastguard Worker extern int badblocks_list_test(badblocks_list bb, blk_t blk);
853*6a54128fSAndroid Build Coastguard Worker extern errcode_t badblocks_list_iterate_begin(badblocks_list bb,
854*6a54128fSAndroid Build Coastguard Worker 					      badblocks_iterate *ret);
855*6a54128fSAndroid Build Coastguard Worker extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk);
856*6a54128fSAndroid Build Coastguard Worker extern void badblocks_list_iterate_end(badblocks_iterate iter);
857*6a54128fSAndroid Build Coastguard Worker extern void badblocks_list_free(badblocks_list bb);
858*6a54128fSAndroid Build Coastguard Worker 
859*6a54128fSAndroid Build Coastguard Worker /* bb_inode.c */
860*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs,
861*6a54128fSAndroid Build Coastguard Worker 					ext2_badblocks_list bb_list);
862*6a54128fSAndroid Build Coastguard Worker 
863*6a54128fSAndroid Build Coastguard Worker /* bitmaps.c */
864*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap);
865*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap);
866*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
867*6a54128fSAndroid Build Coastguard Worker 				    ext2fs_generic_bitmap *dest);
868*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
869*6a54128fSAndroid Build Coastguard Worker 					      const char *descr,
870*6a54128fSAndroid Build Coastguard Worker 					      ext2fs_block_bitmap *ret);
871*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
872*6a54128fSAndroid Build Coastguard Worker 						   const char *descr,
873*6a54128fSAndroid Build Coastguard Worker 						   ext2fs_block_bitmap *ret);
874*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap);
875*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
876*6a54128fSAndroid Build Coastguard Worker 					      const char *descr,
877*6a54128fSAndroid Build Coastguard Worker 					      ext2fs_inode_bitmap *ret);
878*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
879*6a54128fSAndroid Build Coastguard Worker 					       ext2_ino_t end, ext2_ino_t *oend);
880*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
881*6a54128fSAndroid Build Coastguard Worker 					       blk_t end, blk_t *oend);
882*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_fudge_block_bitmap_end2(ext2fs_block_bitmap bitmap,
883*6a54128fSAndroid Build Coastguard Worker 					 blk64_t end, blk64_t *oend);
884*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap);
885*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap);
886*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
887*6a54128fSAndroid Build Coastguard Worker 					    ext2fs_inode_bitmap bmap);
888*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_inode_bitmap2(__u64 new_end,
889*6a54128fSAndroid Build Coastguard Worker 					     __u64 new_real_end,
890*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_inode_bitmap bmap);
891*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
892*6a54128fSAndroid Build Coastguard Worker 					    ext2fs_block_bitmap bmap);
893*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_block_bitmap2(__u64 new_end,
894*6a54128fSAndroid Build Coastguard Worker 					     __u64 new_real_end,
895*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_block_bitmap bmap);
896*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
897*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_block_bitmap bm2);
898*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
899*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_inode_bitmap bm2);
900*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
901*6a54128fSAndroid Build Coastguard Worker 					ext2_ino_t start, unsigned int num,
902*6a54128fSAndroid Build Coastguard Worker 					void *in);
903*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
904*6a54128fSAndroid Build Coastguard Worker 					 __u64 start, size_t num,
905*6a54128fSAndroid Build Coastguard Worker 					 void *in);
906*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
907*6a54128fSAndroid Build Coastguard Worker 					ext2_ino_t start, unsigned int num,
908*6a54128fSAndroid Build Coastguard Worker 					void *out);
909*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
910*6a54128fSAndroid Build Coastguard Worker 					 __u64 start, size_t num,
911*6a54128fSAndroid Build Coastguard Worker 					 void *out);
912*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
913*6a54128fSAndroid Build Coastguard Worker 					blk_t start, unsigned int num,
914*6a54128fSAndroid Build Coastguard Worker 					void *in);
915*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_block_bitmap_range2(ext2fs_block_bitmap bmap,
916*6a54128fSAndroid Build Coastguard Worker 					 blk64_t start, size_t num,
917*6a54128fSAndroid Build Coastguard Worker 					 void *in);
918*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
919*6a54128fSAndroid Build Coastguard Worker 					blk_t start, unsigned int num,
920*6a54128fSAndroid Build Coastguard Worker 					void *out);
921*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_block_bitmap_range2(ext2fs_block_bitmap bmap,
922*6a54128fSAndroid Build Coastguard Worker 					 blk64_t start, size_t num,
923*6a54128fSAndroid Build Coastguard Worker 					 void *out);
924*6a54128fSAndroid Build Coastguard Worker 
925*6a54128fSAndroid Build Coastguard Worker /* blknum.c */
926*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_inode_bitmap_checksum(ext2_filsys fs, dgrp_t group);
927*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_block_bitmap_checksum(ext2_filsys fs, dgrp_t group);
928*6a54128fSAndroid Build Coastguard Worker extern dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t);
929*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group);
930*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group);
931*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group);
932*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
933*6a54128fSAndroid Build Coastguard Worker 					 struct ext2_inode *inode);
934*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_inode_i_blocks(ext2_filsys fs,
935*6a54128fSAndroid Build Coastguard Worker 				     struct ext2_inode *inode);
936*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_get_stat_i_blocks(ext2_filsys fs,
937*6a54128fSAndroid Build Coastguard Worker 					struct ext2_inode *inode);
938*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_blocks_count(struct ext2_super_block *super);
939*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_blocks_count_set(struct ext2_super_block *super,
940*6a54128fSAndroid Build Coastguard Worker 				    blk64_t blk);
941*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_blocks_count_add(struct ext2_super_block *super,
942*6a54128fSAndroid Build Coastguard Worker 				    blk64_t blk);
943*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_r_blocks_count(struct ext2_super_block *super);
944*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_r_blocks_count_set(struct ext2_super_block *super,
945*6a54128fSAndroid Build Coastguard Worker 				      blk64_t blk);
946*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_r_blocks_count_add(struct ext2_super_block *super,
947*6a54128fSAndroid Build Coastguard Worker 				      blk64_t blk);
948*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_free_blocks_count(struct ext2_super_block *super);
949*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_blocks_count_set(struct ext2_super_block *super,
950*6a54128fSAndroid Build Coastguard Worker 					 blk64_t blk);
951*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_blocks_count_add(struct ext2_super_block *super,
952*6a54128fSAndroid Build Coastguard Worker 					 blk64_t blk);
953*6a54128fSAndroid Build Coastguard Worker /* Block group descriptor accessor functions */
954*6a54128fSAndroid Build Coastguard Worker extern struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
955*6a54128fSAndroid Build Coastguard Worker 					  struct opaque_ext2_group_desc *gdp,
956*6a54128fSAndroid Build Coastguard Worker 					  dgrp_t group);
957*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_block_bitmap_csum(ext2_filsys fs, dgrp_t group);
958*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_block_bitmap_loc(ext2_filsys fs, dgrp_t group);
959*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
960*6a54128fSAndroid Build Coastguard Worker 					blk64_t blk);
961*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_inode_bitmap_csum(ext2_filsys fs, dgrp_t group);
962*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group);
963*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_inode_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
964*6a54128fSAndroid Build Coastguard Worker 					blk64_t blk);
965*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_inode_table_loc(ext2_filsys fs, dgrp_t group);
966*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_inode_table_loc_set(ext2_filsys fs, dgrp_t group,
967*6a54128fSAndroid Build Coastguard Worker 				       blk64_t blk);
968*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_bg_free_blocks_count(ext2_filsys fs, dgrp_t group);
969*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_free_blocks_count_set(ext2_filsys fs, dgrp_t group,
970*6a54128fSAndroid Build Coastguard Worker 					 __u32 n);
971*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_bg_free_inodes_count(ext2_filsys fs, dgrp_t group);
972*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_free_inodes_count_set(ext2_filsys fs, dgrp_t group,
973*6a54128fSAndroid Build Coastguard Worker 					 __u32 n);
974*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_bg_used_dirs_count(ext2_filsys fs, dgrp_t group);
975*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_used_dirs_count_set(ext2_filsys fs, dgrp_t group,
976*6a54128fSAndroid Build Coastguard Worker 				       __u32 n);
977*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_bg_itable_unused(ext2_filsys fs, dgrp_t group);
978*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_itable_unused_set(ext2_filsys fs, dgrp_t group,
979*6a54128fSAndroid Build Coastguard Worker 				     __u32 n);
980*6a54128fSAndroid Build Coastguard Worker extern __u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group);
981*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group);
982*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_bg_flags_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
983*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
984*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
985*6a54128fSAndroid Build Coastguard Worker extern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group);
986*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum);
987*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_file_acl_block(ext2_filsys fs,
988*6a54128fSAndroid Build Coastguard Worker 				     const struct ext2_inode *inode);
989*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_file_acl_block_set(ext2_filsys fs,
990*6a54128fSAndroid Build Coastguard Worker 				      struct ext2_inode *inode, blk64_t blk);
991*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inode_size_set(ext2_filsys fs, struct ext2_inode *inode,
992*6a54128fSAndroid Build Coastguard Worker 				       ext2_off64_t size);
993*6a54128fSAndroid Build Coastguard Worker 
994*6a54128fSAndroid Build Coastguard Worker /* block.c */
995*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
996*6a54128fSAndroid Build Coastguard Worker 				      ext2_ino_t	ino,
997*6a54128fSAndroid Build Coastguard Worker 				      int	flags,
998*6a54128fSAndroid Build Coastguard Worker 				      char *block_buf,
999*6a54128fSAndroid Build Coastguard Worker 				      int (*func)(ext2_filsys fs,
1000*6a54128fSAndroid Build Coastguard Worker 						  blk_t	*blocknr,
1001*6a54128fSAndroid Build Coastguard Worker 						  int	blockcnt,
1002*6a54128fSAndroid Build Coastguard Worker 						  void	*priv_data),
1003*6a54128fSAndroid Build Coastguard Worker 				      void *priv_data);
1004*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_block_iterate2(ext2_filsys fs,
1005*6a54128fSAndroid Build Coastguard Worker 				ext2_ino_t	ino,
1006*6a54128fSAndroid Build Coastguard Worker 				int	flags,
1007*6a54128fSAndroid Build Coastguard Worker 				char *block_buf,
1008*6a54128fSAndroid Build Coastguard Worker 				int (*func)(ext2_filsys fs,
1009*6a54128fSAndroid Build Coastguard Worker 					    blk_t	*blocknr,
1010*6a54128fSAndroid Build Coastguard Worker 					    e2_blkcnt_t	blockcnt,
1011*6a54128fSAndroid Build Coastguard Worker 					    blk_t	ref_blk,
1012*6a54128fSAndroid Build Coastguard Worker 					    int		ref_offset,
1013*6a54128fSAndroid Build Coastguard Worker 					    void	*priv_data),
1014*6a54128fSAndroid Build Coastguard Worker 				void *priv_data);
1015*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_block_iterate3(ext2_filsys fs,
1016*6a54128fSAndroid Build Coastguard Worker 				ext2_ino_t ino,
1017*6a54128fSAndroid Build Coastguard Worker 				int	flags,
1018*6a54128fSAndroid Build Coastguard Worker 				char *block_buf,
1019*6a54128fSAndroid Build Coastguard Worker 				int (*func)(ext2_filsys fs,
1020*6a54128fSAndroid Build Coastguard Worker 					    blk64_t	*blocknr,
1021*6a54128fSAndroid Build Coastguard Worker 					    e2_blkcnt_t	blockcnt,
1022*6a54128fSAndroid Build Coastguard Worker 					    blk64_t	ref_blk,
1023*6a54128fSAndroid Build Coastguard Worker 					    int		ref_offset,
1024*6a54128fSAndroid Build Coastguard Worker 					    void	*priv_data),
1025*6a54128fSAndroid Build Coastguard Worker 				void *priv_data);
1026*6a54128fSAndroid Build Coastguard Worker 
1027*6a54128fSAndroid Build Coastguard Worker /* bmap.c */
1028*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
1029*6a54128fSAndroid Build Coastguard Worker 			     struct ext2_inode *inode,
1030*6a54128fSAndroid Build Coastguard Worker 			     char *block_buf, int bmap_flags,
1031*6a54128fSAndroid Build Coastguard Worker 			     blk_t block, blk_t *phys_blk);
1032*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino,
1033*6a54128fSAndroid Build Coastguard Worker 			      struct ext2_inode *inode,
1034*6a54128fSAndroid Build Coastguard Worker 			      char *block_buf, int bmap_flags, blk64_t block,
1035*6a54128fSAndroid Build Coastguard Worker 			      int *ret_flags, blk64_t *phys_blk);
1036*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino,
1037*6a54128fSAndroid Build Coastguard Worker 				   struct ext2_inode *inode, blk64_t lblk,
1038*6a54128fSAndroid Build Coastguard Worker 				   blk64_t *pblk);
1039*6a54128fSAndroid Build Coastguard Worker 
1040*6a54128fSAndroid Build Coastguard Worker #if 0
1041*6a54128fSAndroid Build Coastguard Worker /* bmove.c */
1042*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_move_blocks(ext2_filsys fs,
1043*6a54128fSAndroid Build Coastguard Worker 				    ext2fs_block_bitmap reserve,
1044*6a54128fSAndroid Build Coastguard Worker 				    ext2fs_block_bitmap alloc_map,
1045*6a54128fSAndroid Build Coastguard Worker 				    int flags);
1046*6a54128fSAndroid Build Coastguard Worker #endif
1047*6a54128fSAndroid Build Coastguard Worker 
1048*6a54128fSAndroid Build Coastguard Worker /* check_desc.c */
1049*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_check_desc(ext2_filsys fs);
1050*6a54128fSAndroid Build Coastguard Worker 
1051*6a54128fSAndroid Build Coastguard Worker /* closefs.c */
1052*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_close(ext2_filsys fs);
1053*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_close2(ext2_filsys fs, int flags);
1054*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_close_free(ext2_filsys *fs);
1055*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_flush(ext2_filsys fs);
1056*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_flush2(ext2_filsys fs, int flags);
1057*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group_block);
1058*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
1059*6a54128fSAndroid Build Coastguard Worker 				    dgrp_t group,
1060*6a54128fSAndroid Build Coastguard Worker 				    blk64_t *ret_super_blk,
1061*6a54128fSAndroid Build Coastguard Worker 				    blk64_t *ret_old_desc_blk,
1062*6a54128fSAndroid Build Coastguard Worker 				    blk64_t *ret_new_desc_blk,
1063*6a54128fSAndroid Build Coastguard Worker 				    blk_t *ret_used_blks);
1064*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
1065*6a54128fSAndroid Build Coastguard Worker 				    dgrp_t group,
1066*6a54128fSAndroid Build Coastguard Worker 				    blk_t *ret_super_blk,
1067*6a54128fSAndroid Build Coastguard Worker 				    blk_t *ret_old_desc_blk,
1068*6a54128fSAndroid Build Coastguard Worker 				    blk_t *ret_new_desc_blk,
1069*6a54128fSAndroid Build Coastguard Worker 				    int *ret_meta_bg);
1070*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
1071*6a54128fSAndroid Build Coastguard Worker 
1072*6a54128fSAndroid Build Coastguard Worker /* crc32c.c */
1073*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_crc32_be(__u32 crc, unsigned char const *p, size_t len);
1074*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len);
1075*6a54128fSAndroid Build Coastguard Worker 
1076*6a54128fSAndroid Build Coastguard Worker /* csum.c */
1077*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_init_csum_seed(ext2_filsys fs);
1078*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_mmp_csum_set(ext2_filsys fs, struct mmp_struct *mmp);
1079*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mmp_csum_verify(ext2_filsys, struct mmp_struct *mmp);
1080*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_verify_csum_type(ext2_filsys fs, struct ext2_super_block *sb);
1081*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_superblock_csum_set(ext2_filsys fs,
1082*6a54128fSAndroid Build Coastguard Worker 					    struct ext2_super_block *sb);
1083*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_superblock_csum_verify(ext2_filsys fs,
1084*6a54128fSAndroid Build Coastguard Worker 					 struct ext2_super_block *sb);
1085*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_ext_attr_block_csum_set(ext2_filsys fs,
1086*6a54128fSAndroid Build Coastguard Worker 					ext2_ino_t inum, blk64_t block,
1087*6a54128fSAndroid Build Coastguard Worker 					struct ext2_ext_attr_header *hdr);
1088*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_ext_attr_block_csum_verify(ext2_filsys fs, ext2_ino_t inum,
1089*6a54128fSAndroid Build Coastguard Worker 					     blk64_t block,
1090*6a54128fSAndroid Build Coastguard Worker 					     struct ext2_ext_attr_header *hdr);
1091*6a54128fSAndroid Build Coastguard Worker #define EXT2_DIRENT_TAIL(block, blocksize) \
1092*6a54128fSAndroid Build Coastguard Worker 	((struct ext2_dir_entry_tail *)(((char *)(block)) + \
1093*6a54128fSAndroid Build Coastguard Worker 	(blocksize) - sizeof(struct ext2_dir_entry_tail)))
1094*6a54128fSAndroid Build Coastguard Worker 
1095*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_initialize_dirent_tail(ext2_filsys fs,
1096*6a54128fSAndroid Build Coastguard Worker 					  struct ext2_dir_entry_tail *t);
1097*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_dirent_has_tail(ext2_filsys fs,
1098*6a54128fSAndroid Build Coastguard Worker 				  struct ext2_dir_entry *dirent);
1099*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_dirent_csum_verify(ext2_filsys fs, ext2_ino_t inum,
1100*6a54128fSAndroid Build Coastguard Worker 				     struct ext2_dir_entry *dirent);
1101*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_dir_block_csum_verify(ext2_filsys fs, ext2_ino_t inum,
1102*6a54128fSAndroid Build Coastguard Worker 					struct ext2_dir_entry *dirent);
1103*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dir_block_csum_set(ext2_filsys fs, ext2_ino_t inum,
1104*6a54128fSAndroid Build Coastguard Worker 					   struct ext2_dir_entry *dirent);
1105*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_dx_countlimit(ext2_filsys fs,
1106*6a54128fSAndroid Build Coastguard Worker 					  struct ext2_dir_entry *dirent,
1107*6a54128fSAndroid Build Coastguard Worker 					  struct ext2_dx_countlimit **cc,
1108*6a54128fSAndroid Build Coastguard Worker 					  int *offset);
1109*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dx_csum(ext2_filsys fs, ext2_ino_t inum,
1110*6a54128fSAndroid Build Coastguard Worker 				struct ext2_dir_entry *dirent,
1111*6a54128fSAndroid Build Coastguard Worker 				__u32 *crc, struct ext2_dx_tail **ret_t);
1112*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_block_csum_set(ext2_filsys fs,
1113*6a54128fSAndroid Build Coastguard Worker 					      ext2_ino_t inum,
1114*6a54128fSAndroid Build Coastguard Worker 					      struct ext3_extent_header *eh);
1115*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_extent_block_csum_verify(ext2_filsys fs,
1116*6a54128fSAndroid Build Coastguard Worker 					   ext2_ino_t inum,
1117*6a54128fSAndroid Build Coastguard Worker 					   struct ext3_extent_header *eh);
1118*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_block_bitmap_csum_set(ext2_filsys fs, dgrp_t group,
1119*6a54128fSAndroid Build Coastguard Worker 					      char *bitmap, int size);
1120*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_block_bitmap_csum_verify(ext2_filsys fs, dgrp_t group,
1121*6a54128fSAndroid Build Coastguard Worker 					   char *bitmap, int size);
1122*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inode_bitmap_csum_set(ext2_filsys fs, dgrp_t group,
1123*6a54128fSAndroid Build Coastguard Worker 					      char *bitmap, int size);
1124*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_inode_bitmap_csum_verify(ext2_filsys fs, dgrp_t group,
1125*6a54128fSAndroid Build Coastguard Worker 					   char *bitmap, int size);
1126*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inode_csum_set(ext2_filsys fs, ext2_ino_t inum,
1127*6a54128fSAndroid Build Coastguard Worker 				       struct ext2_inode_large *inode);
1128*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_inode_csum_verify(ext2_filsys fs, ext2_ino_t inum,
1129*6a54128fSAndroid Build Coastguard Worker 				    struct ext2_inode_large *inode);
1130*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group);
1131*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group);
1132*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_gdt_csum(ext2_filsys fs);
1133*6a54128fSAndroid Build Coastguard Worker extern __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group);
1134*6a54128fSAndroid Build Coastguard Worker 
1135*6a54128fSAndroid Build Coastguard Worker /* dblist.c */
1136*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
1137*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
1138*6a54128fSAndroid Build Coastguard Worker 				      blk_t blk, int blockcnt);
1139*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
1140*6a54128fSAndroid Build Coastguard Worker 				       blk64_t blk, e2_blkcnt_t blockcnt);
1141*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_dblist_sort(ext2_dblist dblist,
1142*6a54128fSAndroid Build Coastguard Worker 			       EXT2_QSORT_TYPE (*sortfunc)(const void *,
1143*6a54128fSAndroid Build Coastguard Worker 							   const void *));
1144*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_dblist_sort2(ext2_dblist dblist,
1145*6a54128fSAndroid Build Coastguard Worker 				EXT2_QSORT_TYPE (*sortfunc)(const void *,
1146*6a54128fSAndroid Build Coastguard Worker 							    const void *));
1147*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
1148*6a54128fSAndroid Build Coastguard Worker 	int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
1149*6a54128fSAndroid Build Coastguard Worker 		    void	*priv_data),
1150*6a54128fSAndroid Build Coastguard Worker 	void *priv_data);
1151*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist,
1152*6a54128fSAndroid Build Coastguard Worker 	int (*func)(ext2_filsys fs, struct ext2_db_entry2 *db_info,
1153*6a54128fSAndroid Build Coastguard Worker 		    void	*priv_data),
1154*6a54128fSAndroid Build Coastguard Worker 	void *priv_data);
1155*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dblist_iterate3(ext2_dblist dblist,
1156*6a54128fSAndroid Build Coastguard Worker 	int (*func)(ext2_filsys fs, struct ext2_db_entry2 *db_info,
1157*6a54128fSAndroid Build Coastguard Worker 		    void	*priv_data),
1158*6a54128fSAndroid Build Coastguard Worker 	unsigned long long start,
1159*6a54128fSAndroid Build Coastguard Worker 	unsigned long long count,
1160*6a54128fSAndroid Build Coastguard Worker 	void *priv_data);
1161*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino,
1162*6a54128fSAndroid Build Coastguard Worker 				      blk_t blk, int blockcnt);
1163*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
1164*6a54128fSAndroid Build Coastguard Worker 				       blk64_t blk, e2_blkcnt_t blockcnt);
1165*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_copy_dblist(ext2_dblist src,
1166*6a54128fSAndroid Build Coastguard Worker 				    ext2_dblist *dest);
1167*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_dblist_count(ext2_dblist dblist);
1168*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_dblist_count2(ext2_dblist dblist);
1169*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
1170*6a54128fSAndroid Build Coastguard Worker 					struct ext2_db_entry **entry);
1171*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist,
1172*6a54128fSAndroid Build Coastguard Worker 					struct ext2_db_entry2 **entry);
1173*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist);
1174*6a54128fSAndroid Build Coastguard Worker 
1175*6a54128fSAndroid Build Coastguard Worker /* dblist_dir.c */
1176*6a54128fSAndroid Build Coastguard Worker extern errcode_t
1177*6a54128fSAndroid Build Coastguard Worker 	ext2fs_dblist_dir_iterate(ext2_dblist dblist,
1178*6a54128fSAndroid Build Coastguard Worker 				  int	flags,
1179*6a54128fSAndroid Build Coastguard Worker 				  char	*block_buf,
1180*6a54128fSAndroid Build Coastguard Worker 				  int (*func)(ext2_ino_t	dir,
1181*6a54128fSAndroid Build Coastguard Worker 					      int		entry,
1182*6a54128fSAndroid Build Coastguard Worker 					      struct ext2_dir_entry *dirent,
1183*6a54128fSAndroid Build Coastguard Worker 					      int	offset,
1184*6a54128fSAndroid Build Coastguard Worker 					      int	blocksize,
1185*6a54128fSAndroid Build Coastguard Worker 					      char	*buf,
1186*6a54128fSAndroid Build Coastguard Worker 					      void	*priv_data),
1187*6a54128fSAndroid Build Coastguard Worker 				  void *priv_data);
1188*6a54128fSAndroid Build Coastguard Worker 
1189*6a54128fSAndroid Build Coastguard Worker #if 0
1190*6a54128fSAndroid Build Coastguard Worker /* digest_encode.c */
1191*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_DIGEST_SIZE EXT2FS_SHA256_LENGTH
1192*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_digest_encode(const char *src, int len, char *dst);
1193*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_digest_decode(const char *src, int len, char *dst);
1194*6a54128fSAndroid Build Coastguard Worker #endif
1195*6a54128fSAndroid Build Coastguard Worker 
1196*6a54128fSAndroid Build Coastguard Worker /* dirblock.c */
1197*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
1198*6a54128fSAndroid Build Coastguard Worker 				       void *buf);
1199*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
1200*6a54128fSAndroid Build Coastguard Worker 					void *buf, int flags);
1201*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
1202*6a54128fSAndroid Build Coastguard Worker 					void *buf, int flags);
1203*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_dir_block4(ext2_filsys fs, blk64_t block,
1204*6a54128fSAndroid Build Coastguard Worker 					void *buf, int flags, ext2_ino_t ino);
1205*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
1206*6a54128fSAndroid Build Coastguard Worker 					void *buf);
1207*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
1208*6a54128fSAndroid Build Coastguard Worker 					 void *buf, int flags);
1209*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block,
1210*6a54128fSAndroid Build Coastguard Worker 					 void *buf, int flags);
1211*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_dir_block4(ext2_filsys fs, blk64_t block,
1212*6a54128fSAndroid Build Coastguard Worker 					 void *buf, int flags, ext2_ino_t ino);
1213*6a54128fSAndroid Build Coastguard Worker 
1214*6a54128fSAndroid Build Coastguard Worker /* dirhash.c */
1215*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dirhash(int version, const char *name, int len,
1216*6a54128fSAndroid Build Coastguard Worker 				const __u32 *seed,
1217*6a54128fSAndroid Build Coastguard Worker 				ext2_dirhash_t *ret_hash,
1218*6a54128fSAndroid Build Coastguard Worker 				ext2_dirhash_t *ret_minor_hash);
1219*6a54128fSAndroid Build Coastguard Worker 
1220*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dirhash2(int version, const char *name, int len,
1221*6a54128fSAndroid Build Coastguard Worker 				 const struct ext2fs_nls_table *charset,
1222*6a54128fSAndroid Build Coastguard Worker 				 int hash_flags,
1223*6a54128fSAndroid Build Coastguard Worker 				 const __u32 *seed,
1224*6a54128fSAndroid Build Coastguard Worker 				 ext2_dirhash_t *ret_hash,
1225*6a54128fSAndroid Build Coastguard Worker 				 ext2_dirhash_t *ret_minor_hash);
1226*6a54128fSAndroid Build Coastguard Worker 
1227*6a54128fSAndroid Build Coastguard Worker /* dir_iterate.c */
1228*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_rec_len(ext2_filsys fs,
1229*6a54128fSAndroid Build Coastguard Worker 				    struct ext2_dir_entry *dirent,
1230*6a54128fSAndroid Build Coastguard Worker 				    unsigned int *rec_len);
1231*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_rec_len(ext2_filsys fs,
1232*6a54128fSAndroid Build Coastguard Worker 				    unsigned int len,
1233*6a54128fSAndroid Build Coastguard Worker 				    struct ext2_dir_entry *dirent);
1234*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
1235*6a54128fSAndroid Build Coastguard Worker 			      ext2_ino_t dir,
1236*6a54128fSAndroid Build Coastguard Worker 			      int flags,
1237*6a54128fSAndroid Build Coastguard Worker 			      char *block_buf,
1238*6a54128fSAndroid Build Coastguard Worker 			      int (*func)(struct ext2_dir_entry *dirent,
1239*6a54128fSAndroid Build Coastguard Worker 					  int	offset,
1240*6a54128fSAndroid Build Coastguard Worker 					  int	blocksize,
1241*6a54128fSAndroid Build Coastguard Worker 					  char	*buf,
1242*6a54128fSAndroid Build Coastguard Worker 					  void	*priv_data),
1243*6a54128fSAndroid Build Coastguard Worker 			      void *priv_data);
1244*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs,
1245*6a54128fSAndroid Build Coastguard Worker 			      ext2_ino_t dir,
1246*6a54128fSAndroid Build Coastguard Worker 			      int flags,
1247*6a54128fSAndroid Build Coastguard Worker 			      char *block_buf,
1248*6a54128fSAndroid Build Coastguard Worker 			      int (*func)(ext2_ino_t	dir,
1249*6a54128fSAndroid Build Coastguard Worker 					  int	entry,
1250*6a54128fSAndroid Build Coastguard Worker 					  struct ext2_dir_entry *dirent,
1251*6a54128fSAndroid Build Coastguard Worker 					  int	offset,
1252*6a54128fSAndroid Build Coastguard Worker 					  int	blocksize,
1253*6a54128fSAndroid Build Coastguard Worker 					  char	*buf,
1254*6a54128fSAndroid Build Coastguard Worker 					  void	*priv_data),
1255*6a54128fSAndroid Build Coastguard Worker 			      void *priv_data);
1256*6a54128fSAndroid Build Coastguard Worker 
1257*6a54128fSAndroid Build Coastguard Worker /* dupfs.c */
1258*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest);
1259*6a54128fSAndroid Build Coastguard Worker 
1260*6a54128fSAndroid Build Coastguard Worker /* expanddir.c */
1261*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir);
1262*6a54128fSAndroid Build Coastguard Worker 
1263*6a54128fSAndroid Build Coastguard Worker /* ext_attr.c */
1264*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry,
1265*6a54128fSAndroid Build Coastguard Worker 					void *data);
1266*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_ext_attr_hash_entry_signed(struct ext2_ext_attr_entry *entry,
1267*6a54128fSAndroid Build Coastguard Worker 					       void *data);
1268*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_ext_attr_hash_entry2(ext2_filsys fs,
1269*6a54128fSAndroid Build Coastguard Worker 					     struct ext2_ext_attr_entry *entry,
1270*6a54128fSAndroid Build Coastguard Worker 					     void *data, __u32 *hash);
1271*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_ext_attr_hash_entry3(ext2_filsys fs,
1272*6a54128fSAndroid Build Coastguard Worker 					     struct ext2_ext_attr_entry *entry,
1273*6a54128fSAndroid Build Coastguard Worker 					     void *data, __u32 *hash,
1274*6a54128fSAndroid Build Coastguard Worker 					     __u32 *signed_hash);
1275*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf);
1276*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_ext_attr2(ext2_filsys fs, blk64_t block,
1277*6a54128fSAndroid Build Coastguard Worker 				       void *buf);
1278*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_ext_attr3(ext2_filsys fs, blk64_t block,
1279*6a54128fSAndroid Build Coastguard Worker 				       void *buf, ext2_ino_t inum);
1280*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block,
1281*6a54128fSAndroid Build Coastguard Worker 				       void *buf);
1282*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block,
1283*6a54128fSAndroid Build Coastguard Worker 				       void *buf);
1284*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_ext_attr3(ext2_filsys fs, blk64_t block,
1285*6a54128fSAndroid Build Coastguard Worker 				       void *buf, ext2_ino_t inum);
1286*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
1287*6a54128fSAndroid Build Coastguard Worker 					   char *block_buf,
1288*6a54128fSAndroid Build Coastguard Worker 					   int adjust, __u32 *newcount);
1289*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
1290*6a54128fSAndroid Build Coastguard Worker 					   char *block_buf,
1291*6a54128fSAndroid Build Coastguard Worker 					   int adjust, __u32 *newcount);
1292*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk,
1293*6a54128fSAndroid Build Coastguard Worker 					   char *block_buf,
1294*6a54128fSAndroid Build Coastguard Worker 					   int adjust, __u32 *newcount,
1295*6a54128fSAndroid Build Coastguard Worker 					   ext2_ino_t inum);
1296*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_write(struct ext2_xattr_handle *handle);
1297*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_read(struct ext2_xattr_handle *handle);
1298*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_iterate(struct ext2_xattr_handle *h,
1299*6a54128fSAndroid Build Coastguard Worker 				int (*func)(char *name, char *value,
1300*6a54128fSAndroid Build Coastguard Worker 					    size_t value_len, void *data),
1301*6a54128fSAndroid Build Coastguard Worker 				void *data);
1302*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattr_get(struct ext2_xattr_handle *h, const char *key,
1303*6a54128fSAndroid Build Coastguard Worker 			   void **value, size_t *value_len);
1304*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattr_set(struct ext2_xattr_handle *handle,
1305*6a54128fSAndroid Build Coastguard Worker 			   const char *key,
1306*6a54128fSAndroid Build Coastguard Worker 			   const void *value,
1307*6a54128fSAndroid Build Coastguard Worker 			   size_t value_len);
1308*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattr_remove(struct ext2_xattr_handle *handle,
1309*6a54128fSAndroid Build Coastguard Worker 			      const char *key);
1310*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_open(ext2_filsys fs, ext2_ino_t ino,
1311*6a54128fSAndroid Build Coastguard Worker 			     struct ext2_xattr_handle **handle);
1312*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_close(struct ext2_xattr_handle **handle);
1313*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_free_ext_attr(ext2_filsys fs, ext2_ino_t ino,
1314*6a54128fSAndroid Build Coastguard Worker 			       struct ext2_inode_large *inode);
1315*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_count(struct ext2_xattr_handle *handle, size_t *count);
1316*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattr_inode_max_size(ext2_filsys fs, ext2_ino_t ino,
1317*6a54128fSAndroid Build Coastguard Worker 				      size_t *size);
1318*6a54128fSAndroid Build Coastguard Worker #define XATTR_HANDLE_FLAG_RAW	0x0001
1319*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_xattrs_flags(struct ext2_xattr_handle *handle,
1320*6a54128fSAndroid Build Coastguard Worker 			      unsigned int *new_flags, unsigned int *old_flags);
1321*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_ext_attr_block_rehash(struct ext2_ext_attr_header *header,
1322*6a54128fSAndroid Build Coastguard Worker 					 struct ext2_ext_attr_entry *end);
1323*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_get_ea_inode_hash(struct ext2_inode *inode);
1324*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_ea_inode_hash(struct ext2_inode *inode, __u32 hash);
1325*6a54128fSAndroid Build Coastguard Worker extern __u64 ext2fs_get_ea_inode_ref(struct ext2_inode *inode);
1326*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_ea_inode_ref(struct ext2_inode *inode, __u64 ref_count);
1327*6a54128fSAndroid Build Coastguard Worker 
1328*6a54128fSAndroid Build Coastguard Worker /* extent.c */
1329*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_header_verify(void *ptr, int size);
1330*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
1331*6a54128fSAndroid Build Coastguard Worker 				    ext2_extent_handle_t *handle);
1332*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
1333*6a54128fSAndroid Build Coastguard Worker 					struct ext2_inode *inode,
1334*6a54128fSAndroid Build Coastguard Worker 					ext2_extent_handle_t *ret_handle);
1335*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_extent_free(ext2_extent_handle_t handle);
1336*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
1337*6a54128fSAndroid Build Coastguard Worker 				   int flags, struct ext2fs_extent *extent);
1338*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle);
1339*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,
1340*6a54128fSAndroid Build Coastguard Worker 				       struct ext2fs_extent *extent);
1341*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_insert(ext2_extent_handle_t handle, int flags,
1342*6a54128fSAndroid Build Coastguard Worker 				      struct ext2fs_extent *extent);
1343*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle,
1344*6a54128fSAndroid Build Coastguard Worker 					blk64_t logical, blk64_t physical,
1345*6a54128fSAndroid Build Coastguard Worker 					int flags);
1346*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags);
1347*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle,
1348*6a54128fSAndroid Build Coastguard Worker 					struct ext2_extent_info *info);
1349*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
1350*6a54128fSAndroid Build Coastguard Worker 				    blk64_t blk);
1351*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_goto2(ext2_extent_handle_t handle,
1352*6a54128fSAndroid Build Coastguard Worker 				     int leaf_level, blk64_t blk);
1353*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle);
1354*6a54128fSAndroid Build Coastguard Worker extern size_t ext2fs_max_extent_depth(ext2_extent_handle_t handle);
1355*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_fix_extents_checksums(ext2_filsys fs, ext2_ino_t ino,
1356*6a54128fSAndroid Build Coastguard Worker 					      struct ext2_inode *inode);
1357*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_count_blocks(ext2_filsys fs, ext2_ino_t ino,
1358*6a54128fSAndroid Build Coastguard Worker 				     struct ext2_inode *inode, blk64_t *ret_count);
1359*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_decode_extent(struct ext2fs_extent *to, void *from,
1360*6a54128fSAndroid Build Coastguard Worker 				      int len);
1361*6a54128fSAndroid Build Coastguard Worker 
1362*6a54128fSAndroid Build Coastguard Worker /* fallocate.c */
1363*6a54128fSAndroid Build Coastguard Worker #define EXT2_FALLOCATE_ZERO_BLOCKS	(0x1)
1364*6a54128fSAndroid Build Coastguard Worker #define EXT2_FALLOCATE_FORCE_INIT	(0x2)
1365*6a54128fSAndroid Build Coastguard Worker #define EXT2_FALLOCATE_FORCE_UNINIT	(0x4)
1366*6a54128fSAndroid Build Coastguard Worker #define EXT2_FALLOCATE_INIT_BEYOND_EOF	(0x8)
1367*6a54128fSAndroid Build Coastguard Worker #define EXT2_FALLOCATE_ALL_FLAGS	(0xF)
1368*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_fallocate(ext2_filsys fs, int flags, ext2_ino_t ino,
1369*6a54128fSAndroid Build Coastguard Worker 			   struct ext2_inode *inode, blk64_t goal,
1370*6a54128fSAndroid Build Coastguard Worker 			   blk64_t start, blk64_t len);
1371*6a54128fSAndroid Build Coastguard Worker 
1372*6a54128fSAndroid Build Coastguard Worker /* fileio.c */
1373*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
1374*6a54128fSAndroid Build Coastguard Worker 				   struct ext2_inode *inode,
1375*6a54128fSAndroid Build Coastguard Worker 				   int flags, ext2_file_t *ret);
1376*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
1377*6a54128fSAndroid Build Coastguard Worker 				  int flags, ext2_file_t *ret);
1378*6a54128fSAndroid Build Coastguard Worker extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file);
1379*6a54128fSAndroid Build Coastguard Worker struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file);
1380*6a54128fSAndroid Build Coastguard Worker extern ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file);
1381*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_close(ext2_file_t file);
1382*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_flush(ext2_file_t file);
1383*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
1384*6a54128fSAndroid Build Coastguard Worker 				  unsigned int wanted, unsigned int *got);
1385*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
1386*6a54128fSAndroid Build Coastguard Worker 				   unsigned int nbytes, unsigned int *written);
1387*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_llseek(ext2_file_t file, __u64 offset,
1388*6a54128fSAndroid Build Coastguard Worker 				   int whence, __u64 *ret_pos);
1389*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset,
1390*6a54128fSAndroid Build Coastguard Worker 				   int whence, ext2_off_t *ret_pos);
1391*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_file_get_lsize(ext2_file_t file, __u64 *ret_size);
1392*6a54128fSAndroid Build Coastguard Worker extern ext2_off_t ext2fs_file_get_size(ext2_file_t file);
1393*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size);
1394*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size);
1395*6a54128fSAndroid Build Coastguard Worker 
1396*6a54128fSAndroid Build Coastguard Worker /* finddev.c */
1397*6a54128fSAndroid Build Coastguard Worker extern char *ext2fs_find_block_device(dev_t device);
1398*6a54128fSAndroid Build Coastguard Worker 
1399*6a54128fSAndroid Build Coastguard Worker /* flushb.c */
1400*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_sync_device(int fd, int flushb);
1401*6a54128fSAndroid Build Coastguard Worker 
1402*6a54128fSAndroid Build Coastguard Worker /* freefs.c */
1403*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free(ext2_filsys fs);
1404*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_dblist(ext2_dblist dblist);
1405*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_badblocks_list_free(ext2_badblocks_list bb);
1406*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_u32_list_free(ext2_u32_list bb);
1407*6a54128fSAndroid Build Coastguard Worker 
1408*6a54128fSAndroid Build Coastguard Worker /* gen_bitmap.c */
1409*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap);
1410*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
1411*6a54128fSAndroid Build Coastguard Worker 					    __u32 start, __u32 end,
1412*6a54128fSAndroid Build Coastguard Worker 					    __u32 real_end,
1413*6a54128fSAndroid Build Coastguard Worker 					    const char *descr, char *init_map,
1414*6a54128fSAndroid Build Coastguard Worker 					    ext2fs_generic_bitmap *ret);
1415*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
1416*6a54128fSAndroid Build Coastguard Worker 						__u32 end,
1417*6a54128fSAndroid Build Coastguard Worker 						__u32 real_end,
1418*6a54128fSAndroid Build Coastguard Worker 						const char *descr,
1419*6a54128fSAndroid Build Coastguard Worker 						ext2fs_generic_bitmap *ret);
1420*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src,
1421*6a54128fSAndroid Build Coastguard Worker 					    ext2fs_generic_bitmap *dest);
1422*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap);
1423*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
1424*6a54128fSAndroid Build Coastguard Worker 						 errcode_t magic,
1425*6a54128fSAndroid Build Coastguard Worker 						 errcode_t neq,
1426*6a54128fSAndroid Build Coastguard Worker 						 ext2_ino_t end,
1427*6a54128fSAndroid Build Coastguard Worker 						 ext2_ino_t *oend);
1428*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map);
1429*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_generic_bitmap(errcode_t magic,
1430*6a54128fSAndroid Build Coastguard Worker 					      __u32 new_end,
1431*6a54128fSAndroid Build Coastguard Worker 					      __u32 new_real_end,
1432*6a54128fSAndroid Build Coastguard Worker 					      ext2fs_generic_bitmap bmap);
1433*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq,
1434*6a54128fSAndroid Build Coastguard Worker 					       ext2fs_generic_bitmap bm1,
1435*6a54128fSAndroid Build Coastguard Worker 					       ext2fs_generic_bitmap bm2);
1436*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap,
1437*6a54128fSAndroid Build Coastguard Worker 						 errcode_t magic,
1438*6a54128fSAndroid Build Coastguard Worker 						 __u32 start, __u32 num,
1439*6a54128fSAndroid Build Coastguard Worker 						 void *out);
1440*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
1441*6a54128fSAndroid Build Coastguard Worker 						 errcode_t magic,
1442*6a54128fSAndroid Build Coastguard Worker 						 __u32 start, __u32 num,
1443*6a54128fSAndroid Build Coastguard Worker 						 void *in);
1444*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
1445*6a54128fSAndroid Build Coastguard Worker 						       __u32 start, __u32 end,
1446*6a54128fSAndroid Build Coastguard Worker 						       __u32 *out);
1447*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap bitmap,
1448*6a54128fSAndroid Build Coastguard Worker 						       __u32 start, __u32 end,
1449*6a54128fSAndroid Build Coastguard Worker 						       __u32 *out);
1450*6a54128fSAndroid Build Coastguard Worker 
1451*6a54128fSAndroid Build Coastguard Worker /* gen_bitmap64.c */
1452*6a54128fSAndroid Build Coastguard Worker void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
1453*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
1454*6a54128fSAndroid Build Coastguard Worker 				    int type, __u64 start, __u64 end,
1455*6a54128fSAndroid Build Coastguard Worker 				    __u64 real_end,
1456*6a54128fSAndroid Build Coastguard Worker 				    const char *descr,
1457*6a54128fSAndroid Build Coastguard Worker 				    ext2fs_generic_bitmap *ret);
1458*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
1459*6a54128fSAndroid Build Coastguard Worker 				   ext2fs_generic_bitmap *dest);
1460*6a54128fSAndroid Build Coastguard Worker void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
1461*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
1462*6a54128fSAndroid Build Coastguard Worker 					errcode_t neq,
1463*6a54128fSAndroid Build Coastguard Worker 					__u64 end, __u64 *oend);
1464*6a54128fSAndroid Build Coastguard Worker void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
1465*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
1466*6a54128fSAndroid Build Coastguard Worker 				     __u64 new_end,
1467*6a54128fSAndroid Build Coastguard Worker 				     __u64 new_real_end);
1468*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
1469*6a54128fSAndroid Build Coastguard Worker 				      ext2fs_generic_bitmap bm1,
1470*6a54128fSAndroid Build Coastguard Worker 				      ext2fs_generic_bitmap bm2);
1471*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
1472*6a54128fSAndroid Build Coastguard Worker 					__u64 start, unsigned int num,
1473*6a54128fSAndroid Build Coastguard Worker 					void *out);
1474*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
1475*6a54128fSAndroid Build Coastguard Worker 					__u64 start, unsigned int num,
1476*6a54128fSAndroid Build Coastguard Worker 					void *in);
1477*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
1478*6a54128fSAndroid Build Coastguard Worker 					   ext2fs_block_bitmap *bitmap);
1479*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_count_used_clusters(ext2_filsys fs, blk64_t start,
1480*6a54128fSAndroid Build Coastguard Worker 				     blk64_t end, blk64_t *out);
1481*6a54128fSAndroid Build Coastguard Worker 
1482*6a54128fSAndroid Build Coastguard Worker /* get_num_dirs.c */
1483*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
1484*6a54128fSAndroid Build Coastguard Worker 
1485*6a54128fSAndroid Build Coastguard Worker /* getsize.c */
1486*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
1487*6a54128fSAndroid Build Coastguard Worker 					blk_t *retblocks);
1488*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
1489*6a54128fSAndroid Build Coastguard Worker 					blk64_t *retblocks);
1490*6a54128fSAndroid Build Coastguard Worker 
1491*6a54128fSAndroid Build Coastguard Worker /* getsectsize.c */
1492*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_get_dio_alignment(int fd);
1493*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize);
1494*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize);
1495*6a54128fSAndroid Build Coastguard Worker 
1496*6a54128fSAndroid Build Coastguard Worker /* i_block.c */
1497*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_iblk_add_blocks(ext2_filsys fs, struct ext2_inode *inode,
1498*6a54128fSAndroid Build Coastguard Worker 				 blk64_t num_blocks);
1499*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_iblk_sub_blocks(ext2_filsys fs, struct ext2_inode *inode,
1500*6a54128fSAndroid Build Coastguard Worker 				 blk64_t num_blocks);
1501*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_iblk_set(ext2_filsys fs, struct ext2_inode *inode, blk64_t b);
1502*6a54128fSAndroid Build Coastguard Worker 
1503*6a54128fSAndroid Build Coastguard Worker /* imager.c */
1504*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags);
1505*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags);
1506*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags);
1507*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags);
1508*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags);
1509*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags);
1510*6a54128fSAndroid Build Coastguard Worker 
1511*6a54128fSAndroid Build Coastguard Worker /* ind_block.c */
1512*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf);
1513*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf);
1514*6a54128fSAndroid Build Coastguard Worker 
1515*6a54128fSAndroid Build Coastguard Worker /* initialize.c */
1516*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_initialize(const char *name, int flags,
1517*6a54128fSAndroid Build Coastguard Worker 				   struct ext2_super_block *param,
1518*6a54128fSAndroid Build Coastguard Worker 				   io_manager manager, ext2_filsys *ret_fs);
1519*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs, int super_only);
1520*6a54128fSAndroid Build Coastguard Worker 
1521*6a54128fSAndroid Build Coastguard Worker /* icount.c */
1522*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_icount(ext2_icount_t icount);
1523*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
1524*6a54128fSAndroid Build Coastguard Worker 					  int flags, ext2_icount_t *ret);
1525*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags,
1526*6a54128fSAndroid Build Coastguard Worker 				       unsigned int size,
1527*6a54128fSAndroid Build Coastguard Worker 				       ext2_icount_t hint, ext2_icount_t *ret);
1528*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags,
1529*6a54128fSAndroid Build Coastguard Worker 				      unsigned int size,
1530*6a54128fSAndroid Build Coastguard Worker 				      ext2_icount_t *ret);
1531*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino,
1532*6a54128fSAndroid Build Coastguard Worker 				     __u16 *ret);
1533*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
1534*6a54128fSAndroid Build Coastguard Worker 					 __u16 *ret);
1535*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
1536*6a54128fSAndroid Build Coastguard Worker 					 __u16 *ret);
1537*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
1538*6a54128fSAndroid Build Coastguard Worker 				     __u16 count);
1539*6a54128fSAndroid Build Coastguard Worker extern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount);
1540*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *);
1541*6a54128fSAndroid Build Coastguard Worker 
1542*6a54128fSAndroid Build Coastguard Worker /* inline.c */
1543*6a54128fSAndroid Build Coastguard Worker 
1544*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_memalign(unsigned long size,
1545*6a54128fSAndroid Build Coastguard Worker 				     unsigned long align, void *ptr);
1546*6a54128fSAndroid Build Coastguard Worker 
1547*6a54128fSAndroid Build Coastguard Worker /* inline_data.c */
1548*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inline_data_init(ext2_filsys fs, ext2_ino_t ino);
1549*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inline_data_size(ext2_filsys fs, ext2_ino_t ino,
1550*6a54128fSAndroid Build Coastguard Worker 					 size_t *size);
1551*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inline_data_get(ext2_filsys fs, ext2_ino_t ino,
1552*6a54128fSAndroid Build Coastguard Worker 					struct ext2_inode *inode,
1553*6a54128fSAndroid Build Coastguard Worker 					void *buf, size_t *size);
1554*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inline_data_set(ext2_filsys fs, ext2_ino_t ino,
1555*6a54128fSAndroid Build Coastguard Worker 					struct ext2_inode *inode,
1556*6a54128fSAndroid Build Coastguard Worker 					void *buf, size_t size);
1557*6a54128fSAndroid Build Coastguard Worker 
1558*6a54128fSAndroid Build Coastguard Worker /* inode.c */
1559*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_inode_cache(ext2_filsys fs,
1560*6a54128fSAndroid Build Coastguard Worker 					   unsigned int cache_size);
1561*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_free_inode_cache(struct ext2_inode_cache *icache);
1562*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_flush_icache(ext2_filsys fs);
1563*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan,
1564*6a54128fSAndroid Build Coastguard Worker 					    ext2_ino_t *ino,
1565*6a54128fSAndroid Build Coastguard Worker 					    struct ext2_inode *inode,
1566*6a54128fSAndroid Build Coastguard Worker 					    int bufsize);
1567*6a54128fSAndroid Build Coastguard Worker #define EXT2_INODE_SCAN_DEFAULT_BUFFER_BLOCKS	8
1568*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
1569*6a54128fSAndroid Build Coastguard Worker 				  ext2_inode_scan *ret_scan);
1570*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_close_inode_scan(ext2_inode_scan scan);
1571*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
1572*6a54128fSAndroid Build Coastguard Worker 			       struct ext2_inode *inode);
1573*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
1574*6a54128fSAndroid Build Coastguard Worker 						   int	group);
1575*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_inode_callback
1576*6a54128fSAndroid Build Coastguard Worker 	(ext2_inode_scan scan,
1577*6a54128fSAndroid Build Coastguard Worker 	 errcode_t (*done_group)(ext2_filsys fs,
1578*6a54128fSAndroid Build Coastguard Worker 				 ext2_inode_scan scan,
1579*6a54128fSAndroid Build Coastguard Worker 				 dgrp_t group,
1580*6a54128fSAndroid Build Coastguard Worker 				 void * priv_data),
1581*6a54128fSAndroid Build Coastguard Worker 	 void *done_group_data);
1582*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags,
1583*6a54128fSAndroid Build Coastguard Worker 				   int clear_flags);
1584*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
1585*6a54128fSAndroid Build Coastguard Worker 					struct ext2_inode * inode,
1586*6a54128fSAndroid Build Coastguard Worker 					int bufsize);
1587*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_inode(ext2_filsys fs, ext2_ino_t ino,
1588*6a54128fSAndroid Build Coastguard Worker 			    struct ext2_inode * inode);
1589*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_inode2(ext2_filsys fs, ext2_ino_t ino,
1590*6a54128fSAndroid Build Coastguard Worker 				    struct ext2_inode * inode,
1591*6a54128fSAndroid Build Coastguard Worker 				    int bufsize, int flags);
1592*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
1593*6a54128fSAndroid Build Coastguard Worker 					 struct ext2_inode * inode,
1594*6a54128fSAndroid Build Coastguard Worker 					 int bufsize);
1595*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
1596*6a54128fSAndroid Build Coastguard Worker 			    struct ext2_inode * inode);
1597*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_inode2(ext2_filsys fs, ext2_ino_t ino,
1598*6a54128fSAndroid Build Coastguard Worker 				     struct ext2_inode * inode,
1599*6a54128fSAndroid Build Coastguard Worker 				     int bufsize, int flags);
1600*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
1601*6a54128fSAndroid Build Coastguard Worker 			    struct ext2_inode * inode);
1602*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
1603*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino);
1604*6a54128fSAndroid Build Coastguard Worker 
1605*6a54128fSAndroid Build Coastguard Worker /* inode_io.c */
1606*6a54128fSAndroid Build Coastguard Worker extern io_manager inode_io_manager;
1607*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino,
1608*6a54128fSAndroid Build Coastguard Worker 					char **name);
1609*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino,
1610*6a54128fSAndroid Build Coastguard Worker 					 struct ext2_inode *inode,
1611*6a54128fSAndroid Build Coastguard Worker 					 char **name);
1612*6a54128fSAndroid Build Coastguard Worker 
1613*6a54128fSAndroid Build Coastguard Worker /* ismounted.c */
1614*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags);
1615*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
1616*6a54128fSAndroid Build Coastguard Worker 					  char *mtpt, int mtlen);
1617*6a54128fSAndroid Build Coastguard Worker 
1618*6a54128fSAndroid Build Coastguard Worker /* punch.c */
1619*6a54128fSAndroid Build Coastguard Worker /*
1620*6a54128fSAndroid Build Coastguard Worker  * NOTE: This function removes from an inode the blocks "start", "end", and
1621*6a54128fSAndroid Build Coastguard Worker  * every block in between.
1622*6a54128fSAndroid Build Coastguard Worker  */
1623*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
1624*6a54128fSAndroid Build Coastguard Worker 			      struct ext2_inode *inode,
1625*6a54128fSAndroid Build Coastguard Worker 			      char *block_buf, blk64_t start,
1626*6a54128fSAndroid Build Coastguard Worker 			      blk64_t end);
1627*6a54128fSAndroid Build Coastguard Worker 
1628*6a54128fSAndroid Build Coastguard Worker /* namei.c */
1629*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
1630*6a54128fSAndroid Build Coastguard Worker 			 int namelen, char *buf, ext2_ino_t *inode);
1631*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
1632*6a54128fSAndroid Build Coastguard Worker 			const char *name, ext2_ino_t *inode);
1633*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
1634*6a54128fSAndroid Build Coastguard Worker 			      const char *name, ext2_ino_t *inode);
1635*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
1636*6a54128fSAndroid Build Coastguard Worker 			ext2_ino_t inode, ext2_ino_t *res_inode);
1637*6a54128fSAndroid Build Coastguard Worker 
1638*6a54128fSAndroid Build Coastguard Worker /* native.c */
1639*6a54128fSAndroid Build Coastguard Worker int ext2fs_native_flag(void);
1640*6a54128fSAndroid Build Coastguard Worker 
1641*6a54128fSAndroid Build Coastguard Worker /* newdir.c */
1642*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
1643*6a54128fSAndroid Build Coastguard Worker 				ext2_ino_t parent_ino, char **block);
1644*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_new_dir_inline_data(ext2_filsys fs, ext2_ino_t dir_ino,
1645*6a54128fSAndroid Build Coastguard Worker 				ext2_ino_t parent_ino, __u32 *iblock);
1646*6a54128fSAndroid Build Coastguard Worker 
1647*6a54128fSAndroid Build Coastguard Worker /* nls_utf8.c */
1648*6a54128fSAndroid Build Coastguard Worker extern const struct ext2fs_nls_table *ext2fs_load_nls_table(int encoding);
1649*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_check_encoded_name(const struct ext2fs_nls_table *table,
1650*6a54128fSAndroid Build Coastguard Worker 				     char *s, size_t len, char **pos);
1651*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_casefold_cmp(const struct ext2fs_nls_table *table,
1652*6a54128fSAndroid Build Coastguard Worker 			       const unsigned char *str1, size_t len1,
1653*6a54128fSAndroid Build Coastguard Worker 			       const unsigned char *str2, size_t len2);
1654*6a54128fSAndroid Build Coastguard Worker 
1655*6a54128fSAndroid Build Coastguard Worker /* mkdir.c */
1656*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
1657*6a54128fSAndroid Build Coastguard Worker 			      const char *name);
1658*6a54128fSAndroid Build Coastguard Worker 
1659*6a54128fSAndroid Build Coastguard Worker /* mkjournal.c */
1660*6a54128fSAndroid Build Coastguard Worker struct ext2fs_journal_params {
1661*6a54128fSAndroid Build Coastguard Worker 	blk_t num_journal_blocks;
1662*6a54128fSAndroid Build Coastguard Worker 	blk_t num_fc_blocks;
1663*6a54128fSAndroid Build Coastguard Worker };
1664*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_journal_params(
1665*6a54128fSAndroid Build Coastguard Worker 		struct ext2fs_journal_params *params, ext2_filsys fs);
1666*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num,
1667*6a54128fSAndroid Build Coastguard Worker 				    blk_t *ret_blk, int *ret_count);
1668*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
1669*6a54128fSAndroid Build Coastguard Worker 				     blk64_t *ret_blk, int *ret_count);
1670*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
1671*6a54128fSAndroid Build Coastguard Worker 						  __u32 num_blocks, int flags,
1672*6a54128fSAndroid Build Coastguard Worker 						  char  **ret_jsb);
1673*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_journal_superblock2(ext2_filsys fs,
1674*6a54128fSAndroid Build Coastguard Worker 						  struct ext2fs_journal_params *params,
1675*6a54128fSAndroid Build Coastguard Worker 						  int flags, char  **ret_jsb);
1676*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_add_journal_device(ext2_filsys fs,
1677*6a54128fSAndroid Build Coastguard Worker 					   ext2_filsys journal_dev);
1678*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks,
1679*6a54128fSAndroid Build Coastguard Worker 					  int flags);
1680*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_add_journal_inode2(ext2_filsys fs, blk_t num_blocks,
1681*6a54128fSAndroid Build Coastguard Worker 					   blk64_t goal, int flags);
1682*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_add_journal_inode3(ext2_filsys fs,
1683*6a54128fSAndroid Build Coastguard Worker 				    struct ext2fs_journal_params *params,
1684*6a54128fSAndroid Build Coastguard Worker 				    blk64_t goal, int flags);
1685*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_default_journal_size(__u64 num_blocks);
1686*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_journal_sb_start(int blocksize);
1687*6a54128fSAndroid Build Coastguard Worker 
1688*6a54128fSAndroid Build Coastguard Worker /* openfs.c */
1689*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_open(const char *name, int flags, int superblock,
1690*6a54128fSAndroid Build Coastguard Worker 			     unsigned int block_size, io_manager manager,
1691*6a54128fSAndroid Build Coastguard Worker 			     ext2_filsys *ret_fs);
1692*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_open2(const char *name, const char *io_options,
1693*6a54128fSAndroid Build Coastguard Worker 			      int flags, int superblock,
1694*6a54128fSAndroid Build Coastguard Worker 			      unsigned int block_size, io_manager manager,
1695*6a54128fSAndroid Build Coastguard Worker 			      ext2_filsys *ret_fs);
1696*6a54128fSAndroid Build Coastguard Worker /*
1697*6a54128fSAndroid Build Coastguard Worker  * The dgrp_t argument to these two functions is not actually a group number
1698*6a54128fSAndroid Build Coastguard Worker  * but a block number offset within a group table!  Convert with the formula
1699*6a54128fSAndroid Build Coastguard Worker  * (group_number / groups_per_block).
1700*6a54128fSAndroid Build Coastguard Worker  */
1701*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs,
1702*6a54128fSAndroid Build Coastguard Worker 					blk64_t group_block, dgrp_t i);
1703*6a54128fSAndroid Build Coastguard Worker extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block,
1704*6a54128fSAndroid Build Coastguard Worker 					 dgrp_t i);
1705*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io);
1706*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io);
1707*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io);
1708*6a54128fSAndroid Build Coastguard Worker 
1709*6a54128fSAndroid Build Coastguard Worker /* get_pathname.c */
1710*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino,
1711*6a54128fSAndroid Build Coastguard Worker 			       char **name);
1712*6a54128fSAndroid Build Coastguard Worker 
1713*6a54128fSAndroid Build Coastguard Worker /* link.c */
1714*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_UNLINK_FORCE		0x1	/* Forcefully unlink even if
1715*6a54128fSAndroid Build Coastguard Worker 						 * the inode number doesn't
1716*6a54128fSAndroid Build Coastguard Worker 						 * match the dirent
1717*6a54128fSAndroid Build Coastguard Worker 						 */
1718*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
1719*6a54128fSAndroid Build Coastguard Worker 		      ext2_ino_t ino, int flags);
1720*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name,
1721*6a54128fSAndroid Build Coastguard Worker 			ext2_ino_t ino, int flags);
1722*6a54128fSAndroid Build Coastguard Worker 
1723*6a54128fSAndroid Build Coastguard Worker /* symlink.c */
1724*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
1725*6a54128fSAndroid Build Coastguard Worker 			 const char *name, const char *target);
1726*6a54128fSAndroid Build Coastguard Worker int ext2fs_is_fast_symlink(struct ext2_inode *inode);
1727*6a54128fSAndroid Build Coastguard Worker 
1728*6a54128fSAndroid Build Coastguard Worker /* mmp.c */
1729*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf);
1730*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf);
1731*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_clear(ext2_filsys fs);
1732*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_init(ext2_filsys fs);
1733*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_start(ext2_filsys fs);
1734*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_update(ext2_filsys fs);
1735*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_update2(ext2_filsys fs, int immediately);
1736*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_mmp_stop(ext2_filsys fs);
1737*6a54128fSAndroid Build Coastguard Worker unsigned ext2fs_mmp_new_seq(void);
1738*6a54128fSAndroid Build Coastguard Worker 
1739*6a54128fSAndroid Build Coastguard Worker /* read_bb.c */
1740*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
1741*6a54128fSAndroid Build Coastguard Worker 				      ext2_badblocks_list *bb_list);
1742*6a54128fSAndroid Build Coastguard Worker 
1743*6a54128fSAndroid Build Coastguard Worker /* read_bb_file.c */
1744*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
1745*6a54128fSAndroid Build Coastguard Worker 				      ext2_badblocks_list *bb_list,
1746*6a54128fSAndroid Build Coastguard Worker 				      void *priv_data,
1747*6a54128fSAndroid Build Coastguard Worker 				      void (*invalid)(ext2_filsys fs,
1748*6a54128fSAndroid Build Coastguard Worker 						      blk_t blk,
1749*6a54128fSAndroid Build Coastguard Worker 						      char *badstr,
1750*6a54128fSAndroid Build Coastguard Worker 						      void *priv_data));
1751*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
1752*6a54128fSAndroid Build Coastguard Worker 				     ext2_badblocks_list *bb_list,
1753*6a54128fSAndroid Build Coastguard Worker 				     void (*invalid)(ext2_filsys fs,
1754*6a54128fSAndroid Build Coastguard Worker 						     blk_t blk));
1755*6a54128fSAndroid Build Coastguard Worker 
1756*6a54128fSAndroid Build Coastguard Worker /* res_gdt.c */
1757*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs);
1758*6a54128fSAndroid Build Coastguard Worker 
1759*6a54128fSAndroid Build Coastguard Worker /* rw_bitmaps.c */
1760*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_rw_bitmaps(ext2_filsys fs, int flags, int num_threads);
1761*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs);
1762*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs);
1763*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
1764*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs);
1765*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs);
1766*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs);
1767*6a54128fSAndroid Build Coastguard Worker 
1768*6a54128fSAndroid Build Coastguard Worker /*sha256.c */
1769*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_SHA256_LENGTH 32
1770*6a54128fSAndroid Build Coastguard Worker #if 0
1771*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_sha256(const unsigned char *in, unsigned long in_size,
1772*6a54128fSAndroid Build Coastguard Worker 		   unsigned char out[EXT2FS_SHA256_LENGTH]);
1773*6a54128fSAndroid Build Coastguard Worker #endif
1774*6a54128fSAndroid Build Coastguard Worker 
1775*6a54128fSAndroid Build Coastguard Worker /* sha512.c */
1776*6a54128fSAndroid Build Coastguard Worker #define EXT2FS_SHA512_LENGTH 64
1777*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_sha512(const unsigned char *in, unsigned long in_size,
1778*6a54128fSAndroid Build Coastguard Worker 			  unsigned char out[EXT2FS_SHA512_LENGTH]);
1779*6a54128fSAndroid Build Coastguard Worker 
1780*6a54128fSAndroid Build Coastguard Worker /* swapfs.c */
1781*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dirent_swab_in2(ext2_filsys fs, char *buf, size_t size,
1782*6a54128fSAndroid Build Coastguard Worker 					int flags);
1783*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dirent_swab_in(ext2_filsys fs, char *buf, int flags);
1784*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dirent_swab_out2(ext2_filsys fs, char *buf, size_t size,
1785*6a54128fSAndroid Build Coastguard Worker 					 int flags);
1786*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_dirent_swab_out(ext2_filsys fs, char *buf, int flags);
1787*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize,
1788*6a54128fSAndroid Build Coastguard Worker 				 int has_header);
1789*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header,
1790*6a54128fSAndroid Build Coastguard Worker 					struct ext2_ext_attr_header *from_hdr);
1791*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_ext_attr_entry(struct ext2_ext_attr_entry *to_entry,
1792*6a54128fSAndroid Build Coastguard Worker 				       struct ext2_ext_attr_entry *from_entry);
1793*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_super(struct ext2_super_block * super);
1794*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp);
1795*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_group_desc2(ext2_filsys, struct ext2_group_desc *gdp);
1796*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
1797*6a54128fSAndroid Build Coastguard Worker 				   struct ext2_inode_large *f, int hostorder,
1798*6a54128fSAndroid Build Coastguard Worker 				   int bufsize);
1799*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
1800*6a54128fSAndroid Build Coastguard Worker 			      struct ext2_inode *f, int hostorder);
1801*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_swap_mmp(struct mmp_struct *mmp);
1802*6a54128fSAndroid Build Coastguard Worker 
1803*6a54128fSAndroid Build Coastguard Worker /* unix_io.c */
1804*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_open_file(const char *pathname, int flags, mode_t mode);
1805*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_stat(const char *path, ext2fs_struct_stat *buf);
1806*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fstat(int fd, ext2fs_struct_stat *buf);
1807*6a54128fSAndroid Build Coastguard Worker 
1808*6a54128fSAndroid Build Coastguard Worker /* valid_blk.c */
1809*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
1810*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_inode_has_valid_blocks2(ext2_filsys fs,
1811*6a54128fSAndroid Build Coastguard Worker 					  struct ext2_inode *inode);
1812*6a54128fSAndroid Build Coastguard Worker 
1813*6a54128fSAndroid Build Coastguard Worker /* version.c */
1814*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_parse_version_string(const char *ver_string);
1815*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_get_library_version(const char **ver_string,
1816*6a54128fSAndroid Build Coastguard Worker 				      const char **date_string);
1817*6a54128fSAndroid Build Coastguard Worker 
1818*6a54128fSAndroid Build Coastguard Worker /* write_bb_file.c */
1819*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
1820*6a54128fSAndroid Build Coastguard Worker 				      unsigned int flags,
1821*6a54128fSAndroid Build Coastguard Worker 				      FILE *f);
1822*6a54128fSAndroid Build Coastguard Worker 
1823*6a54128fSAndroid Build Coastguard Worker 
1824*6a54128fSAndroid Build Coastguard Worker /* inline functions */
1825*6a54128fSAndroid Build Coastguard Worker #ifdef NO_INLINE_FUNCS
1826*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_mem(unsigned long size, void *ptr);
1827*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_memzero(unsigned long size, void *ptr);
1828*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_array(unsigned long count,
1829*6a54128fSAndroid Build Coastguard Worker 				  unsigned long size, void *ptr);
1830*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_get_arrayzero(unsigned long count,
1831*6a54128fSAndroid Build Coastguard Worker 				      unsigned long size, void *ptr);
1832*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_free_mem(void *ptr);
1833*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_mem(unsigned long old_size,
1834*6a54128fSAndroid Build Coastguard Worker 				   unsigned long size, void *ptr);
1835*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_resize_array(unsigned long old_count, unsigned long count,
1836*6a54128fSAndroid Build Coastguard Worker 				     unsigned long size, void *ptr);
1837*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_super_dirty(ext2_filsys fs);
1838*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_changed(ext2_filsys fs);
1839*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_changed(ext2_filsys fs);
1840*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_valid(ext2_filsys fs);
1841*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_unmark_valid(ext2_filsys fs);
1842*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_valid(ext2_filsys fs);
1843*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_ib_dirty(ext2_filsys fs);
1844*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_bb_dirty(ext2_filsys fs);
1845*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_ib_dirty(ext2_filsys fs);
1846*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_bb_dirty(ext2_filsys fs);
1847*6a54128fSAndroid Build Coastguard Worker extern dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
1848*6a54128fSAndroid Build Coastguard Worker extern dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
1849*6a54128fSAndroid Build Coastguard Worker extern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group);
1850*6a54128fSAndroid Build Coastguard Worker extern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group);
1851*6a54128fSAndroid Build Coastguard Worker extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
1852*6a54128fSAndroid Build Coastguard Worker 				      struct ext2_inode *inode);
1853*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_htree_intnode_maxrecs(ext2_filsys fs, int blocks);
1854*6a54128fSAndroid Build Coastguard Worker extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
1855*6a54128fSAndroid Build Coastguard Worker extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b);
1856*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry);
1857*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_dirent_set_name_len(struct ext2_dir_entry *entry, int len);
1858*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_dirent_file_type(const struct ext2_dir_entry *entry);
1859*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_dirent_set_file_type(struct ext2_dir_entry *entry, int type);
1860*6a54128fSAndroid Build Coastguard Worker extern struct ext2_inode *ext2fs_inode(struct ext2_inode_large * large_inode);
1861*6a54128fSAndroid Build Coastguard Worker extern const struct ext2_inode *ext2fs_const_inode(const struct ext2_inode_large * large_inode);
1862*6a54128fSAndroid Build Coastguard Worker 
1863*6a54128fSAndroid Build Coastguard Worker #endif
1864*6a54128fSAndroid Build Coastguard Worker 
1865*6a54128fSAndroid Build Coastguard Worker /*
1866*6a54128fSAndroid Build Coastguard Worker  * The actual inlined functions definitions themselves...
1867*6a54128fSAndroid Build Coastguard Worker  *
1868*6a54128fSAndroid Build Coastguard Worker  * If NO_INLINE_FUNCS is defined, then we won't try to do inline
1869*6a54128fSAndroid Build Coastguard Worker  * functions at all!
1870*6a54128fSAndroid Build Coastguard Worker  */
1871*6a54128fSAndroid Build Coastguard Worker #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
1872*6a54128fSAndroid Build Coastguard Worker #ifdef INCLUDE_INLINE_FUNCS
1873*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ extern
1874*6a54128fSAndroid Build Coastguard Worker #else
1875*6a54128fSAndroid Build Coastguard Worker #if (__STDC_VERSION__ >= 199901L)
1876*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ inline
1877*6a54128fSAndroid Build Coastguard Worker #else
1878*6a54128fSAndroid Build Coastguard Worker #ifdef __GNUC__
1879*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ extern __inline__
1880*6a54128fSAndroid Build Coastguard Worker #else				/* For Watcom C */
1881*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ extern inline
1882*6a54128fSAndroid Build Coastguard Worker #endif /* __GNUC__ */
1883*6a54128fSAndroid Build Coastguard Worker #endif /* __STDC_VERSION__ >= 199901L */
1884*6a54128fSAndroid Build Coastguard Worker #endif
1885*6a54128fSAndroid Build Coastguard Worker 
1886*6a54128fSAndroid Build Coastguard Worker #ifndef EXT2_CUSTOM_MEMORY_ROUTINES
1887*6a54128fSAndroid Build Coastguard Worker #include <string.h>
1888*6a54128fSAndroid Build Coastguard Worker /*
1889*6a54128fSAndroid Build Coastguard Worker  *  Allocate memory.  The 'ptr' arg must point to a pointer.
1890*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_get_mem(unsigned long size,void * ptr)1891*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr)
1892*6a54128fSAndroid Build Coastguard Worker {
1893*6a54128fSAndroid Build Coastguard Worker 	void *pp;
1894*6a54128fSAndroid Build Coastguard Worker 
1895*6a54128fSAndroid Build Coastguard Worker 	pp = malloc(size);
1896*6a54128fSAndroid Build Coastguard Worker 	if (!pp)
1897*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_NO_MEMORY;
1898*6a54128fSAndroid Build Coastguard Worker 	memcpy(ptr, &pp, sizeof (pp));
1899*6a54128fSAndroid Build Coastguard Worker 	return 0;
1900*6a54128fSAndroid Build Coastguard Worker }
1901*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_memzero(unsigned long size,void * ptr)1902*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_get_memzero(unsigned long size, void *ptr)
1903*6a54128fSAndroid Build Coastguard Worker {
1904*6a54128fSAndroid Build Coastguard Worker 	void *pp;
1905*6a54128fSAndroid Build Coastguard Worker 
1906*6a54128fSAndroid Build Coastguard Worker 	pp = malloc(size);
1907*6a54128fSAndroid Build Coastguard Worker 	if (!pp)
1908*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_NO_MEMORY;
1909*6a54128fSAndroid Build Coastguard Worker 	memset(pp, 0, size);
1910*6a54128fSAndroid Build Coastguard Worker 	memcpy(ptr, &pp, sizeof(pp));
1911*6a54128fSAndroid Build Coastguard Worker 	return 0;
1912*6a54128fSAndroid Build Coastguard Worker }
1913*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_array(unsigned long count,unsigned long size,void * ptr)1914*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_get_array(unsigned long count, unsigned long size,
1915*6a54128fSAndroid Build Coastguard Worker 				    void *ptr)
1916*6a54128fSAndroid Build Coastguard Worker {
1917*6a54128fSAndroid Build Coastguard Worker 	if (count && (~0UL)/count < size)
1918*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_NO_MEMORY;
1919*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_mem(count*size, ptr);
1920*6a54128fSAndroid Build Coastguard Worker }
1921*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_arrayzero(unsigned long count,unsigned long size,void * ptr)1922*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_get_arrayzero(unsigned long count,
1923*6a54128fSAndroid Build Coastguard Worker 					unsigned long size, void *ptr)
1924*6a54128fSAndroid Build Coastguard Worker {
1925*6a54128fSAndroid Build Coastguard Worker 	if (count && (~0UL)/count < size)
1926*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_NO_MEMORY;
1927*6a54128fSAndroid Build Coastguard Worker 
1928*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_memzero((size_t)count * size, ptr);
1929*6a54128fSAndroid Build Coastguard Worker }
1930*6a54128fSAndroid Build Coastguard Worker 
1931*6a54128fSAndroid Build Coastguard Worker /*
1932*6a54128fSAndroid Build Coastguard Worker  * Free memory.  The 'ptr' arg must point to a pointer.
1933*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_free_mem(void * ptr)1934*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_free_mem(void *ptr)
1935*6a54128fSAndroid Build Coastguard Worker {
1936*6a54128fSAndroid Build Coastguard Worker 	void *p;
1937*6a54128fSAndroid Build Coastguard Worker 
1938*6a54128fSAndroid Build Coastguard Worker 	memcpy(&p, ptr, sizeof(p));
1939*6a54128fSAndroid Build Coastguard Worker 	free(p);
1940*6a54128fSAndroid Build Coastguard Worker 	p = 0;
1941*6a54128fSAndroid Build Coastguard Worker 	memcpy(ptr, &p, sizeof(p));
1942*6a54128fSAndroid Build Coastguard Worker 	return 0;
1943*6a54128fSAndroid Build Coastguard Worker }
1944*6a54128fSAndroid Build Coastguard Worker 
1945*6a54128fSAndroid Build Coastguard Worker /*
1946*6a54128fSAndroid Build Coastguard Worker  *  Resize memory.  The 'ptr' arg must point to a pointer.
1947*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_resize_mem(unsigned long EXT2FS_ATTR ((unused))old_size,unsigned long size,void * ptr)1948*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size,
1949*6a54128fSAndroid Build Coastguard Worker 				     unsigned long size, void *ptr)
1950*6a54128fSAndroid Build Coastguard Worker {
1951*6a54128fSAndroid Build Coastguard Worker 	void *p;
1952*6a54128fSAndroid Build Coastguard Worker 
1953*6a54128fSAndroid Build Coastguard Worker 	/* Use "memcpy" for pointer assignments here to avoid problems
1954*6a54128fSAndroid Build Coastguard Worker 	 * with C99 strict type aliasing rules. */
1955*6a54128fSAndroid Build Coastguard Worker 	memcpy(&p, ptr, sizeof(p));
1956*6a54128fSAndroid Build Coastguard Worker 	p = realloc(p, size);
1957*6a54128fSAndroid Build Coastguard Worker 	if (!p)
1958*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_NO_MEMORY;
1959*6a54128fSAndroid Build Coastguard Worker 	memcpy(ptr, &p, sizeof(p));
1960*6a54128fSAndroid Build Coastguard Worker 	return 0;
1961*6a54128fSAndroid Build Coastguard Worker }
1962*6a54128fSAndroid Build Coastguard Worker 
1963*6a54128fSAndroid Build Coastguard Worker /*
1964*6a54128fSAndroid Build Coastguard Worker  *  Resize array.  The 'ptr' arg must point to a pointer.
1965*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_resize_array(unsigned long size,unsigned long old_count,unsigned long count,void * ptr)1966*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_resize_array(unsigned long size,
1967*6a54128fSAndroid Build Coastguard Worker 				       unsigned long old_count,
1968*6a54128fSAndroid Build Coastguard Worker 				       unsigned long count, void *ptr)
1969*6a54128fSAndroid Build Coastguard Worker {
1970*6a54128fSAndroid Build Coastguard Worker 	unsigned long old_size;
1971*6a54128fSAndroid Build Coastguard Worker 	errcode_t retval;
1972*6a54128fSAndroid Build Coastguard Worker 
1973*6a54128fSAndroid Build Coastguard Worker 	if (count && (~0UL)/count < size)
1974*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_NO_MEMORY;
1975*6a54128fSAndroid Build Coastguard Worker 
1976*6a54128fSAndroid Build Coastguard Worker 	size *= count;
1977*6a54128fSAndroid Build Coastguard Worker 	old_size = size * old_count;
1978*6a54128fSAndroid Build Coastguard Worker 	retval = ext2fs_resize_mem(old_size, size, ptr);
1979*6a54128fSAndroid Build Coastguard Worker 	if (retval)
1980*6a54128fSAndroid Build Coastguard Worker 		return retval;
1981*6a54128fSAndroid Build Coastguard Worker 
1982*6a54128fSAndroid Build Coastguard Worker 	if (size > old_size) {
1983*6a54128fSAndroid Build Coastguard Worker 		void *p;
1984*6a54128fSAndroid Build Coastguard Worker 
1985*6a54128fSAndroid Build Coastguard Worker 		memcpy(&p, ptr, sizeof(p));
1986*6a54128fSAndroid Build Coastguard Worker 		memset((char *)p + old_size, 0, size - old_size);
1987*6a54128fSAndroid Build Coastguard Worker 		memcpy(ptr, &p, sizeof(p));
1988*6a54128fSAndroid Build Coastguard Worker 	}
1989*6a54128fSAndroid Build Coastguard Worker 
1990*6a54128fSAndroid Build Coastguard Worker 	return 0;
1991*6a54128fSAndroid Build Coastguard Worker }
1992*6a54128fSAndroid Build Coastguard Worker #endif	/* Custom memory routines */
1993*6a54128fSAndroid Build Coastguard Worker 
1994*6a54128fSAndroid Build Coastguard Worker /*
1995*6a54128fSAndroid Build Coastguard Worker  * Mark a filesystem superblock as dirty
1996*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_mark_super_dirty(ext2_filsys fs)1997*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs)
1998*6a54128fSAndroid Build Coastguard Worker {
1999*6a54128fSAndroid Build Coastguard Worker 	fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED;
2000*6a54128fSAndroid Build Coastguard Worker }
2001*6a54128fSAndroid Build Coastguard Worker 
2002*6a54128fSAndroid Build Coastguard Worker /*
2003*6a54128fSAndroid Build Coastguard Worker  * Mark a filesystem as changed
2004*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_mark_changed(ext2_filsys fs)2005*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_mark_changed(ext2_filsys fs)
2006*6a54128fSAndroid Build Coastguard Worker {
2007*6a54128fSAndroid Build Coastguard Worker 	fs->flags |= EXT2_FLAG_CHANGED;
2008*6a54128fSAndroid Build Coastguard Worker }
2009*6a54128fSAndroid Build Coastguard Worker 
2010*6a54128fSAndroid Build Coastguard Worker /*
2011*6a54128fSAndroid Build Coastguard Worker  * Check to see if a filesystem has changed
2012*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_test_changed(ext2_filsys fs)2013*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_changed(ext2_filsys fs)
2014*6a54128fSAndroid Build Coastguard Worker {
2015*6a54128fSAndroid Build Coastguard Worker 	return (fs->flags & EXT2_FLAG_CHANGED);
2016*6a54128fSAndroid Build Coastguard Worker }
2017*6a54128fSAndroid Build Coastguard Worker 
2018*6a54128fSAndroid Build Coastguard Worker /*
2019*6a54128fSAndroid Build Coastguard Worker  * Mark a filesystem as valid
2020*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_mark_valid(ext2_filsys fs)2021*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_mark_valid(ext2_filsys fs)
2022*6a54128fSAndroid Build Coastguard Worker {
2023*6a54128fSAndroid Build Coastguard Worker 	fs->flags |= EXT2_FLAG_VALID;
2024*6a54128fSAndroid Build Coastguard Worker }
2025*6a54128fSAndroid Build Coastguard Worker 
2026*6a54128fSAndroid Build Coastguard Worker /*
2027*6a54128fSAndroid Build Coastguard Worker  * Mark a filesystem as NOT valid
2028*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_unmark_valid(ext2_filsys fs)2029*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_unmark_valid(ext2_filsys fs)
2030*6a54128fSAndroid Build Coastguard Worker {
2031*6a54128fSAndroid Build Coastguard Worker 	fs->flags &= ~EXT2_FLAG_VALID;
2032*6a54128fSAndroid Build Coastguard Worker }
2033*6a54128fSAndroid Build Coastguard Worker 
2034*6a54128fSAndroid Build Coastguard Worker /*
2035*6a54128fSAndroid Build Coastguard Worker  * Check to see if a filesystem is valid
2036*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_test_valid(ext2_filsys fs)2037*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_valid(ext2_filsys fs)
2038*6a54128fSAndroid Build Coastguard Worker {
2039*6a54128fSAndroid Build Coastguard Worker 	return (fs->flags & EXT2_FLAG_VALID);
2040*6a54128fSAndroid Build Coastguard Worker }
2041*6a54128fSAndroid Build Coastguard Worker 
2042*6a54128fSAndroid Build Coastguard Worker /*
2043*6a54128fSAndroid Build Coastguard Worker  * Mark the inode bitmap as dirty
2044*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_mark_ib_dirty(ext2_filsys fs)2045*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs)
2046*6a54128fSAndroid Build Coastguard Worker {
2047*6a54128fSAndroid Build Coastguard Worker 	fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED;
2048*6a54128fSAndroid Build Coastguard Worker }
2049*6a54128fSAndroid Build Coastguard Worker 
2050*6a54128fSAndroid Build Coastguard Worker /*
2051*6a54128fSAndroid Build Coastguard Worker  * Mark the block bitmap as dirty
2052*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_mark_bb_dirty(ext2_filsys fs)2053*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs)
2054*6a54128fSAndroid Build Coastguard Worker {
2055*6a54128fSAndroid Build Coastguard Worker 	fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED;
2056*6a54128fSAndroid Build Coastguard Worker }
2057*6a54128fSAndroid Build Coastguard Worker 
2058*6a54128fSAndroid Build Coastguard Worker /*
2059*6a54128fSAndroid Build Coastguard Worker  * Check to see if a filesystem's inode bitmap is dirty
2060*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_test_ib_dirty(ext2_filsys fs)2061*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs)
2062*6a54128fSAndroid Build Coastguard Worker {
2063*6a54128fSAndroid Build Coastguard Worker 	return (fs->flags & EXT2_FLAG_IB_DIRTY);
2064*6a54128fSAndroid Build Coastguard Worker }
2065*6a54128fSAndroid Build Coastguard Worker 
2066*6a54128fSAndroid Build Coastguard Worker /*
2067*6a54128fSAndroid Build Coastguard Worker  * Check to see if a filesystem's block bitmap is dirty
2068*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_test_bb_dirty(ext2_filsys fs)2069*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
2070*6a54128fSAndroid Build Coastguard Worker {
2071*6a54128fSAndroid Build Coastguard Worker 	return (fs->flags & EXT2_FLAG_BB_DIRTY);
2072*6a54128fSAndroid Build Coastguard Worker }
2073*6a54128fSAndroid Build Coastguard Worker 
2074*6a54128fSAndroid Build Coastguard Worker /*
2075*6a54128fSAndroid Build Coastguard Worker  * Return the group # of a block
2076*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_group_of_blk(ext2_filsys fs,blk_t blk)2077*6a54128fSAndroid Build Coastguard Worker _INLINE_ dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
2078*6a54128fSAndroid Build Coastguard Worker {
2079*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_group_of_blk2(fs, blk);
2080*6a54128fSAndroid Build Coastguard Worker }
2081*6a54128fSAndroid Build Coastguard Worker /*
2082*6a54128fSAndroid Build Coastguard Worker  * Return the group # of an inode number
2083*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_group_of_ino(ext2_filsys fs,ext2_ino_t ino)2084*6a54128fSAndroid Build Coastguard Worker _INLINE_ dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
2085*6a54128fSAndroid Build Coastguard Worker {
2086*6a54128fSAndroid Build Coastguard Worker 	return (ino - 1) / fs->super->s_inodes_per_group;
2087*6a54128fSAndroid Build Coastguard Worker }
2088*6a54128fSAndroid Build Coastguard Worker 
2089*6a54128fSAndroid Build Coastguard Worker /*
2090*6a54128fSAndroid Build Coastguard Worker  * Return the first block (inclusive) in a group
2091*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_group_first_block(ext2_filsys fs,dgrp_t group)2092*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
2093*6a54128fSAndroid Build Coastguard Worker {
2094*6a54128fSAndroid Build Coastguard Worker 	return (blk_t) ext2fs_group_first_block2(fs, group);
2095*6a54128fSAndroid Build Coastguard Worker }
2096*6a54128fSAndroid Build Coastguard Worker 
2097*6a54128fSAndroid Build Coastguard Worker /*
2098*6a54128fSAndroid Build Coastguard Worker  * Return the last block (inclusive) in a group
2099*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_group_last_block(ext2_filsys fs,dgrp_t group)2100*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group)
2101*6a54128fSAndroid Build Coastguard Worker {
2102*6a54128fSAndroid Build Coastguard Worker 	return (blk_t) ext2fs_group_last_block2(fs, group);
2103*6a54128fSAndroid Build Coastguard Worker }
2104*6a54128fSAndroid Build Coastguard Worker 
ext2fs_inode_data_blocks(ext2_filsys fs,struct ext2_inode * inode)2105*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
2106*6a54128fSAndroid Build Coastguard Worker 					struct ext2_inode *inode)
2107*6a54128fSAndroid Build Coastguard Worker {
2108*6a54128fSAndroid Build Coastguard Worker 	return (blk_t) ext2fs_inode_data_blocks2(fs, inode);
2109*6a54128fSAndroid Build Coastguard Worker }
2110*6a54128fSAndroid Build Coastguard Worker 
ext2fs_htree_intnode_maxrecs(ext2_filsys fs,int blocks)2111*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_htree_intnode_maxrecs(ext2_filsys fs, int blocks)
2112*6a54128fSAndroid Build Coastguard Worker {
2113*6a54128fSAndroid Build Coastguard Worker 	int csum_size = 0;
2114*6a54128fSAndroid Build Coastguard Worker 
2115*6a54128fSAndroid Build Coastguard Worker 	if ((EXT2_SB(fs->super)->s_feature_ro_compat &
2116*6a54128fSAndroid Build Coastguard Worker 	     EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) != 0)
2117*6a54128fSAndroid Build Coastguard Worker 		csum_size = sizeof(struct ext2_dx_tail);
2118*6a54128fSAndroid Build Coastguard Worker 	return blocks * ((fs->blocksize - (8 + csum_size)) /
2119*6a54128fSAndroid Build Coastguard Worker 						sizeof(struct ext2_dx_entry));
2120*6a54128fSAndroid Build Coastguard Worker }
2121*6a54128fSAndroid Build Coastguard Worker 
2122*6a54128fSAndroid Build Coastguard Worker /*
2123*6a54128fSAndroid Build Coastguard Worker  * This is an efficient, overflow safe way of calculating ceil((1.0 * a) / b)
2124*6a54128fSAndroid Build Coastguard Worker  */
ext2fs_div_ceil(unsigned int a,unsigned int b)2125*6a54128fSAndroid Build Coastguard Worker _INLINE_ unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b)
2126*6a54128fSAndroid Build Coastguard Worker {
2127*6a54128fSAndroid Build Coastguard Worker 	if (!a)
2128*6a54128fSAndroid Build Coastguard Worker 		return 0;
2129*6a54128fSAndroid Build Coastguard Worker 	return ((a - 1) / b) + 1;
2130*6a54128fSAndroid Build Coastguard Worker }
2131*6a54128fSAndroid Build Coastguard Worker 
ext2fs_div64_ceil(__u64 a,__u64 b)2132*6a54128fSAndroid Build Coastguard Worker _INLINE_ __u64 ext2fs_div64_ceil(__u64 a, __u64 b)
2133*6a54128fSAndroid Build Coastguard Worker {
2134*6a54128fSAndroid Build Coastguard Worker 	if (!a)
2135*6a54128fSAndroid Build Coastguard Worker 		return 0;
2136*6a54128fSAndroid Build Coastguard Worker 	return ((a - 1) / b) + 1;
2137*6a54128fSAndroid Build Coastguard Worker }
2138*6a54128fSAndroid Build Coastguard Worker 
ext2fs_dirent_name_len(const struct ext2_dir_entry * entry)2139*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry)
2140*6a54128fSAndroid Build Coastguard Worker {
2141*6a54128fSAndroid Build Coastguard Worker 	return entry->name_len & 0xff;
2142*6a54128fSAndroid Build Coastguard Worker }
2143*6a54128fSAndroid Build Coastguard Worker 
ext2fs_dirent_set_name_len(struct ext2_dir_entry * entry,int len)2144*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_dirent_set_name_len(struct ext2_dir_entry *entry, int len)
2145*6a54128fSAndroid Build Coastguard Worker {
2146*6a54128fSAndroid Build Coastguard Worker 	entry->name_len = (entry->name_len & 0xff00) | (len & 0xff);
2147*6a54128fSAndroid Build Coastguard Worker }
2148*6a54128fSAndroid Build Coastguard Worker 
ext2fs_dirent_file_type(const struct ext2_dir_entry * entry)2149*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_dirent_file_type(const struct ext2_dir_entry *entry)
2150*6a54128fSAndroid Build Coastguard Worker {
2151*6a54128fSAndroid Build Coastguard Worker 	return entry->name_len >> 8;
2152*6a54128fSAndroid Build Coastguard Worker }
2153*6a54128fSAndroid Build Coastguard Worker 
ext2fs_dirent_set_file_type(struct ext2_dir_entry * entry,int type)2154*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_dirent_set_file_type(struct ext2_dir_entry *entry, int type)
2155*6a54128fSAndroid Build Coastguard Worker {
2156*6a54128fSAndroid Build Coastguard Worker 	entry->name_len = (entry->name_len & 0xff) | (type << 8);
2157*6a54128fSAndroid Build Coastguard Worker }
2158*6a54128fSAndroid Build Coastguard Worker 
ext2fs_inode(struct ext2_inode_large * large_inode)2159*6a54128fSAndroid Build Coastguard Worker _INLINE_ struct ext2_inode *ext2fs_inode(struct ext2_inode_large * large_inode)
2160*6a54128fSAndroid Build Coastguard Worker {
2161*6a54128fSAndroid Build Coastguard Worker 	/* It is always safe to convert large inode to a small inode */
2162*6a54128fSAndroid Build Coastguard Worker 	return (struct ext2_inode *) large_inode;
2163*6a54128fSAndroid Build Coastguard Worker }
2164*6a54128fSAndroid Build Coastguard Worker 
2165*6a54128fSAndroid Build Coastguard Worker _INLINE_ const struct ext2_inode *
ext2fs_const_inode(const struct ext2_inode_large * large_inode)2166*6a54128fSAndroid Build Coastguard Worker ext2fs_const_inode(const struct ext2_inode_large * large_inode)
2167*6a54128fSAndroid Build Coastguard Worker {
2168*6a54128fSAndroid Build Coastguard Worker 	/* It is always safe to convert large inode to a small inode */
2169*6a54128fSAndroid Build Coastguard Worker 	return (const struct ext2_inode *) large_inode;
2170*6a54128fSAndroid Build Coastguard Worker }
2171*6a54128fSAndroid Build Coastguard Worker 
2172*6a54128fSAndroid Build Coastguard Worker #undef _INLINE_
2173*6a54128fSAndroid Build Coastguard Worker #endif
2174*6a54128fSAndroid Build Coastguard Worker 
2175*6a54128fSAndroid Build Coastguard Worker /* htree levels for ext4 */
2176*6a54128fSAndroid Build Coastguard Worker #define EXT4_HTREE_LEVEL_COMPAT 2
2177*6a54128fSAndroid Build Coastguard Worker #define EXT4_HTREE_LEVEL	3
2178*6a54128fSAndroid Build Coastguard Worker 
ext2_dir_htree_level(ext2_filsys fs)2179*6a54128fSAndroid Build Coastguard Worker static inline unsigned int ext2_dir_htree_level(ext2_filsys fs)
2180*6a54128fSAndroid Build Coastguard Worker {
2181*6a54128fSAndroid Build Coastguard Worker 	if (ext2fs_has_feature_largedir(fs->super))
2182*6a54128fSAndroid Build Coastguard Worker 		return EXT4_HTREE_LEVEL;
2183*6a54128fSAndroid Build Coastguard Worker 
2184*6a54128fSAndroid Build Coastguard Worker 	return EXT4_HTREE_LEVEL_COMPAT;
2185*6a54128fSAndroid Build Coastguard Worker }
2186*6a54128fSAndroid Build Coastguard Worker 
2187*6a54128fSAndroid Build Coastguard Worker #ifdef __cplusplus
2188*6a54128fSAndroid Build Coastguard Worker }
2189*6a54128fSAndroid Build Coastguard Worker #endif
2190*6a54128fSAndroid Build Coastguard Worker 
2191*6a54128fSAndroid Build Coastguard Worker #endif /* _EXT2FS_EXT2FS_H */
2192