• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ext2fsP.h --- private header file for ext2 library
3  *
4  * Copyright (C) 1997 Theodore Ts'o.
5  *
6  * %Begin-Header%
7  * This file may be redistributed under the terms of the GNU Library
8  * General Public License, version 2.
9  * %End-Header%
10  */
11 
12 #include "ext2fs.h"
13 
14 #define EXT2FS_MAX_NESTED_LINKS  8
15 
16 /*
17  * Badblocks list
18  */
19 struct ext2_struct_u32_list {
20 	int	magic;
21 	int	num;
22 	int	size;
23 	__u32	*list;
24 	int	badblocks_flags;
25 };
26 
27 struct ext2_struct_u32_iterate {
28 	int			magic;
29 	ext2_u32_list		bb;
30 	int			ptr;
31 };
32 
33 
34 /*
35  * Directory block iterator definition
36  */
37 struct ext2_struct_dblist {
38 	int			magic;
39 	ext2_filsys		fs;
40 	unsigned long long	size;
41 	unsigned long long	count;
42 	int			sorted;
43 	struct ext2_db_entry2 *	list;
44 };
45 
46 /*
47  * For directory iterators
48  */
49 struct dir_context {
50 	ext2_ino_t		dir;
51 	int		flags;
52 	char		*buf;
53 	unsigned int	buflen;
54 	int (*func)(ext2_ino_t	dir,
55 		    int	entry,
56 		    struct ext2_dir_entry *dirent,
57 		    int	offset,
58 		    int	blocksize,
59 		    char	*buf,
60 		    void	*priv_data);
61 	void		*priv_data;
62 	errcode_t	errcode;
63 };
64 
65 /*
66  * Inode cache structure
67  */
68 struct ext2_inode_cache {
69 	void *				buffer;
70 	blk64_t				buffer_blk;
71 	int				cache_last;
72 	unsigned int			cache_size;
73 	int				refcount;
74 	struct ext2_inode_cache_ent	*cache;
75 };
76 
77 struct ext2_inode_cache_ent {
78 	ext2_ino_t		ino;
79 	struct ext2_inode	*inode;
80 };
81 
82 /* Function prototypes */
83 
84 extern int ext2fs_process_dir_block(ext2_filsys  	fs,
85 				    blk64_t		*blocknr,
86 				    e2_blkcnt_t		blockcnt,
87 				    blk64_t		ref_block,
88 				    int			ref_offset,
89 				    void		*priv_data);
90 
91 extern errcode_t ext2fs_inline_data_ea_remove(ext2_filsys fs, ext2_ino_t ino);
92 extern errcode_t ext2fs_inline_data_expand(ext2_filsys fs, ext2_ino_t ino);
93 extern int ext2fs_inline_data_dir_iterate(ext2_filsys fs,
94 					  ext2_ino_t ino,
95 					  void *priv_data);
96 
97 /* Generic numeric progress meter */
98 
99 struct ext2fs_numeric_progress_struct {
100 	__u64		max;
101 	int		log_max;
102 	int		skip_progress;
103 };
104 
105 /*
106  * progress callback functions
107  */
108 struct ext2fs_progress_ops {
109 	void (*init)(ext2_filsys fs,
110 		     struct ext2fs_numeric_progress_struct * progress,
111 		     const char *label, __u64 max);
112 	void (*update)(ext2_filsys fs,
113 		       struct ext2fs_numeric_progress_struct * progress,
114 		       __u64 val);
115 	void (*close)(ext2_filsys fs,
116 		      struct ext2fs_numeric_progress_struct * progress,
117 		      const char *message);
118 };
119 
120 extern struct ext2fs_progress_ops ext2fs_numeric_progress_ops;
121 
122 extern void ext2fs_numeric_progress_init(ext2_filsys fs,
123 					 struct ext2fs_numeric_progress_struct * progress,
124 					 const char *label, __u64 max);
125 extern void ext2fs_numeric_progress_update(ext2_filsys fs,
126 					   struct ext2fs_numeric_progress_struct * progress,
127 					   __u64 val);
128 extern void ext2fs_numeric_progress_close(ext2_filsys fs,
129 					  struct ext2fs_numeric_progress_struct * progress,
130 					  const char *message);
131 
132 /*
133  * 64-bit bitmap support
134  */
135 
136 extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
137 					   int type, __u64 start, __u64 end,
138 					   __u64 real_end,
139 					   const char * description,
140 					   ext2fs_generic_bitmap *bmap);
141 
142 extern void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
143 
144 extern errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
145 					  ext2fs_generic_bitmap *dest);
146 
147 extern errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
148 					    __u64 new_end,
149 					    __u64 new_real_end);
150 extern errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
151 					       errcode_t neq,
152 					       __u64 end, __u64 *oend);
153 extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
154 				    __u64 arg);
155 extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
156 				      __u64 arg);
157 extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
158 				    __u64 arg);
159 extern errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bitmap,
160 					       __u64 start, unsigned int num,
161 					       void *in);
162 extern errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bitmap,
163 					       __u64 start, unsigned int num,
164 					       void *out);
165 extern void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap,const char *func);
166 
167 extern int ext2fs_mem_is_zero(const char *mem, size_t len);
168 
169 extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
170 					    struct ext2_inode *inode,
171 					    blk64_t offset);
172 
173 /* atexit support */
174 typedef void (*ext2_exit_fn)(void *);
175 errcode_t ext2fs_add_exit_fn(ext2_exit_fn fn, void *data);
176 errcode_t ext2fs_remove_exit_fn(ext2_exit_fn fn, void *data);
177