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