Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * ext2fs.h --- ext2fs |
| 3 | * |
| 4 | * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. |
| 5 | * |
| 6 | * %Begin-Header% |
| 7 | * This file may be redistributed under the terms of the GNU Public |
| 8 | * License. |
| 9 | * %End-Header% |
| 10 | */ |
| 11 | |
| 12 | #ifndef _EXT2FS_EXT2FS_H |
| 13 | #define _EXT2FS_EXT2FS_H |
| 14 | |
| 15 | #ifdef __GNUC__ |
| 16 | #define EXT2FS_ATTR(x) __attribute__(x) |
| 17 | #else |
| 18 | #define EXT2FS_ATTR(x) |
| 19 | #endif |
| 20 | |
| 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | /* |
| 26 | * Non-GNU C compilers won't necessarily understand inline |
| 27 | */ |
| 28 | #if (!defined(__GNUC__) && !defined(__WATCOMC__)) |
| 29 | #define NO_INLINE_FUNCS |
| 30 | #endif |
| 31 | |
| 32 | /* |
| 33 | * Build in support for byte-swapping filesystems if we the feature |
| 34 | * has been configured or if we're being built on a CPU architecture |
| 35 | * with a non-native byte order. |
| 36 | */ |
| 37 | #if defined(ENABLE_SWAPFS) || defined(WORDS_BIGENDIAN) |
| 38 | #define EXT2FS_ENABLE_SWAPFS |
| 39 | #endif |
| 40 | |
| 41 | /* |
| 42 | * Where the master copy of the superblock is located, and how big |
| 43 | * superblocks are supposed to be. We define SUPERBLOCK_SIZE because |
| 44 | * the size of the superblock structure is not necessarily trustworthy |
| 45 | * (some versions have the padding set up so that the superblock is |
| 46 | * 1032 bytes long). |
| 47 | */ |
| 48 | #define SUPERBLOCK_OFFSET 1024 |
| 49 | #define SUPERBLOCK_SIZE 1024 |
| 50 | |
| 51 | /* |
| 52 | * The last ext2fs revision level that this version of the library is |
| 53 | * able to support. |
| 54 | */ |
| 55 | #define EXT2_LIB_CURRENT_REV EXT2_DYNAMIC_REV |
| 56 | |
| 57 | #ifdef HAVE_SYS_TYPES_H |
| 58 | #include <sys/types.h> |
| 59 | #endif |
| 60 | |
| 61 | #include <stdio.h> |
| 62 | #include <stdlib.h> |
| 63 | |
| 64 | #if EXT2_FLAT_INCLUDES |
| 65 | #include "e2_types.h" |
| 66 | #include "ext2_fs.h" |
| 67 | #else |
| 68 | #include <ext2fs/ext2_types.h> |
| 69 | #include <ext2fs/ext2_fs.h> |
| 70 | #endif /* EXT2_FLAT_INCLUDES */ |
| 71 | |
| 72 | typedef __u32 ext2_ino_t; |
| 73 | typedef __u32 blk_t; |
| 74 | typedef __u32 dgrp_t; |
| 75 | typedef __u32 ext2_off_t; |
| 76 | typedef __s64 e2_blkcnt_t; |
| 77 | typedef __u32 ext2_dirhash_t; |
| 78 | |
| 79 | #if EXT2_FLAT_INCLUDES |
| 80 | #include "com_err.h" |
| 81 | #include "ext2_io.h" |
| 82 | #include "ext2_err.h" |
| 83 | #else |
| 84 | #include <et/com_err.h> |
| 85 | #include <ext2fs/ext2_io.h> |
| 86 | #include <ext2fs/ext2_err.h> |
| 87 | #endif |
| 88 | |
| 89 | /* |
| 90 | * Portability help for Microsoft Visual C++ |
| 91 | */ |
| 92 | #ifdef _MSC_VER |
| 93 | #define EXT2_QSORT_TYPE int __cdecl |
| 94 | #else |
| 95 | #define EXT2_QSORT_TYPE int |
| 96 | #endif |
| 97 | |
| 98 | typedef struct struct_ext2_filsys *ext2_filsys; |
| 99 | |
| 100 | struct ext2fs_struct_generic_bitmap { |
| 101 | errcode_t magic; |
| 102 | ext2_filsys fs; |
| 103 | __u32 start, end; |
| 104 | __u32 real_end; |
| 105 | char * description; |
| 106 | char * bitmap; |
| 107 | errcode_t base_error_code; |
| 108 | __u32 reserved[7]; |
| 109 | }; |
| 110 | |
| 111 | #define EXT2FS_MARK_ERROR 0 |
| 112 | #define EXT2FS_UNMARK_ERROR 1 |
| 113 | #define EXT2FS_TEST_ERROR 2 |
| 114 | |
| 115 | typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap; |
| 116 | typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap; |
| 117 | typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap; |
| 118 | |
| 119 | #ifdef EXT2_DYNAMIC_REV |
| 120 | #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s) |
| 121 | #else |
| 122 | #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO |
| 123 | #define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode) |
| 124 | #endif |
| 125 | |
| 126 | /* |
| 127 | * badblocks list definitions |
| 128 | */ |
| 129 | |
| 130 | typedef struct ext2_struct_u32_list *ext2_badblocks_list; |
| 131 | typedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate; |
| 132 | |
| 133 | typedef struct ext2_struct_u32_list *ext2_u32_list; |
| 134 | typedef struct ext2_struct_u32_iterate *ext2_u32_iterate; |
| 135 | |
| 136 | /* old */ |
| 137 | typedef struct ext2_struct_u32_list *badblocks_list; |
| 138 | typedef struct ext2_struct_u32_iterate *badblocks_iterate; |
| 139 | |
| 140 | #define BADBLOCKS_FLAG_DIRTY 1 |
| 141 | |
| 142 | /* |
| 143 | * ext2_dblist structure and abstractions (see dblist.c) |
| 144 | */ |
| 145 | struct ext2_db_entry { |
| 146 | ext2_ino_t ino; |
| 147 | blk_t blk; |
| 148 | int blockcnt; |
| 149 | }; |
| 150 | |
| 151 | typedef struct ext2_struct_dblist *ext2_dblist; |
| 152 | |
| 153 | #define DBLIST_ABORT 1 |
| 154 | |
| 155 | /* |
| 156 | * ext2_fileio definitions |
| 157 | */ |
| 158 | |
| 159 | #define EXT2_FILE_WRITE 0x0001 |
| 160 | #define EXT2_FILE_CREATE 0x0002 |
| 161 | |
| 162 | #define EXT2_FILE_MASK 0x00FF |
| 163 | |
| 164 | #define EXT2_FILE_BUF_DIRTY 0x4000 |
| 165 | #define EXT2_FILE_BUF_VALID 0x2000 |
| 166 | |
| 167 | typedef struct ext2_file *ext2_file_t; |
| 168 | |
| 169 | #define EXT2_SEEK_SET 0 |
| 170 | #define EXT2_SEEK_CUR 1 |
| 171 | #define EXT2_SEEK_END 2 |
| 172 | |
| 173 | /* |
| 174 | * Flags for the ext2_filsys structure and for ext2fs_open() |
| 175 | */ |
| 176 | #define EXT2_FLAG_RW 0x01 |
| 177 | #define EXT2_FLAG_CHANGED 0x02 |
| 178 | #define EXT2_FLAG_DIRTY 0x04 |
| 179 | #define EXT2_FLAG_VALID 0x08 |
| 180 | #define EXT2_FLAG_IB_DIRTY 0x10 |
| 181 | #define EXT2_FLAG_BB_DIRTY 0x20 |
| 182 | #define EXT2_FLAG_SWAP_BYTES 0x40 |
| 183 | #define EXT2_FLAG_SWAP_BYTES_READ 0x80 |
| 184 | #define EXT2_FLAG_SWAP_BYTES_WRITE 0x100 |
| 185 | #define EXT2_FLAG_MASTER_SB_ONLY 0x200 |
| 186 | #define EXT2_FLAG_FORCE 0x400 |
| 187 | #define EXT2_FLAG_SUPER_ONLY 0x800 |
| 188 | #define EXT2_FLAG_JOURNAL_DEV_OK 0x1000 |
| 189 | #define EXT2_FLAG_IMAGE_FILE 0x2000 |
| 190 | |
| 191 | /* |
| 192 | * Special flag in the ext2 inode i_flag field that means that this is |
| 193 | * a new inode. (So that ext2_write_inode() can clear extra fields.) |
| 194 | */ |
| 195 | #define EXT2_NEW_INODE_FL 0x80000000 |
| 196 | |
| 197 | /* |
| 198 | * Flags for mkjournal |
| 199 | * |
| 200 | * EXT2_MKJOURNAL_V1_SUPER Make a (deprecated) V1 journal superblock |
| 201 | */ |
| 202 | #define EXT2_MKJOURNAL_V1_SUPER 0x0000001 |
| 203 | |
| 204 | struct struct_ext2_filsys { |
| 205 | errcode_t magic; |
| 206 | io_channel io; |
| 207 | int flags; |
| 208 | char * device_name; |
| 209 | struct ext2_super_block * super; |
| 210 | unsigned int blocksize; |
| 211 | int fragsize; |
| 212 | dgrp_t group_desc_count; |
| 213 | unsigned long desc_blocks; |
| 214 | struct ext2_group_desc * group_desc; |
| 215 | int inode_blocks_per_group; |
| 216 | ext2fs_inode_bitmap inode_map; |
| 217 | ext2fs_block_bitmap block_map; |
| 218 | errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks); |
| 219 | errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino); |
| 220 | errcode_t (*write_bitmaps)(ext2_filsys fs); |
| 221 | errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino, |
| 222 | struct ext2_inode *inode); |
| 223 | errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino, |
| 224 | struct ext2_inode *inode); |
| 225 | ext2_badblocks_list badblocks; |
| 226 | ext2_dblist dblist; |
| 227 | __u32 stride; /* for mke2fs */ |
| 228 | struct ext2_super_block * orig_super; |
| 229 | struct ext2_image_hdr * image_header; |
| 230 | __u32 umask; |
| 231 | /* |
| 232 | * Reserved for future expansion |
| 233 | */ |
| 234 | __u32 reserved[8]; |
| 235 | |
| 236 | /* |
| 237 | * Reserved for the use of the calling application. |
| 238 | */ |
| 239 | void * priv_data; |
| 240 | |
| 241 | /* |
| 242 | * Inode cache |
| 243 | */ |
| 244 | struct ext2_inode_cache *icache; |
| 245 | io_channel image_io; |
| 246 | }; |
| 247 | |
| 248 | #if EXT2_FLAT_INCLUDES |
| 249 | #include "e2_bitops.h" |
| 250 | #else |
| 251 | #include <ext2fs/bitops.h> |
| 252 | #endif |
| 253 | |
| 254 | /* |
| 255 | * Return flags for the block iterator functions |
| 256 | */ |
| 257 | #define BLOCK_CHANGED 1 |
| 258 | #define BLOCK_ABORT 2 |
| 259 | #define BLOCK_ERROR 4 |
| 260 | |
| 261 | /* |
| 262 | * Block interate flags |
| 263 | * |
| 264 | * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator |
| 265 | * function should be called on blocks where the block number is zero. |
| 266 | * This is used by ext2fs_expand_dir() to be able to add a new block |
| 267 | * to an inode. It can also be used for programs that want to be able |
| 268 | * to deal with files that contain "holes". |
| 269 | * |
| 270 | * BLOCK_FLAG_TRAVERSE indicates that the iterator function for the |
| 271 | * indirect, doubly indirect, etc. blocks should be called after all |
| 272 | * of the blocks containined in the indirect blocks are processed. |
| 273 | * This is useful if you are going to be deallocating blocks from an |
| 274 | * inode. |
| 275 | * |
| 276 | * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be |
| 277 | * called for data blocks only. |
| 278 | * |
| 279 | * BLOCK_FLAG_NO_LARGE is for internal use only. It informs |
| 280 | * ext2fs_block_iterate2 that large files won't be accepted. |
| 281 | */ |
| 282 | #define BLOCK_FLAG_APPEND 1 |
| 283 | #define BLOCK_FLAG_HOLE 1 |
| 284 | #define BLOCK_FLAG_DEPTH_TRAVERSE 2 |
| 285 | #define BLOCK_FLAG_DATA_ONLY 4 |
| 286 | |
| 287 | #define BLOCK_FLAG_NO_LARGE 0x1000 |
| 288 | |
| 289 | /* |
| 290 | * Magic "block count" return values for the block iterator function. |
| 291 | */ |
| 292 | #define BLOCK_COUNT_IND (-1) |
| 293 | #define BLOCK_COUNT_DIND (-2) |
| 294 | #define BLOCK_COUNT_TIND (-3) |
| 295 | #define BLOCK_COUNT_TRANSLATOR (-4) |
| 296 | |
| 297 | #if 0 |
| 298 | /* |
| 299 | * Flags for ext2fs_move_blocks |
| 300 | */ |
| 301 | #define EXT2_BMOVE_GET_DBLIST 0x0001 |
| 302 | #define EXT2_BMOVE_DEBUG 0x0002 |
| 303 | #endif |
| 304 | |
| 305 | /* |
| 306 | * Flags for directory block reading and writing functions |
| 307 | */ |
| 308 | #define EXT2_DIRBLOCK_V2_STRUCT 0x0001 |
| 309 | |
| 310 | /* |
| 311 | * Return flags for the directory iterator functions |
| 312 | */ |
| 313 | #define DIRENT_CHANGED 1 |
| 314 | #define DIRENT_ABORT 2 |
| 315 | #define DIRENT_ERROR 3 |
| 316 | |
| 317 | /* |
| 318 | * Directory iterator flags |
| 319 | */ |
| 320 | |
| 321 | #define DIRENT_FLAG_INCLUDE_EMPTY 1 |
| 322 | #define DIRENT_FLAG_INCLUDE_REMOVED 2 |
| 323 | |
| 324 | #define DIRENT_DOT_FILE 1 |
| 325 | #define DIRENT_DOT_DOT_FILE 2 |
| 326 | #define DIRENT_OTHER_FILE 3 |
| 327 | #define DIRENT_DELETED_FILE 4 |
| 328 | |
| 329 | /* |
| 330 | * Inode scan definitions |
| 331 | */ |
| 332 | typedef struct ext2_struct_inode_scan *ext2_inode_scan; |
| 333 | |
| 334 | /* |
| 335 | * ext2fs_scan flags |
| 336 | */ |
| 337 | #define EXT2_SF_CHK_BADBLOCKS 0x0001 |
| 338 | #define EXT2_SF_BAD_INODE_BLK 0x0002 |
| 339 | #define EXT2_SF_BAD_EXTRA_BYTES 0x0004 |
| 340 | #define EXT2_SF_SKIP_MISSING_ITABLE 0x0008 |
| 341 | |
| 342 | /* |
| 343 | * ext2fs_check_if_mounted flags |
| 344 | */ |
| 345 | #define EXT2_MF_MOUNTED 1 |
| 346 | #define EXT2_MF_ISROOT 2 |
| 347 | #define EXT2_MF_READONLY 4 |
| 348 | #define EXT2_MF_SWAP 8 |
| 349 | |
| 350 | /* |
| 351 | * Ext2/linux mode flags. We define them here so that we don't need |
| 352 | * to depend on the OS's sys/stat.h, since we may be compiling on a |
| 353 | * non-Linux system. |
| 354 | */ |
| 355 | #define LINUX_S_IFMT 00170000 |
| 356 | #define LINUX_S_IFSOCK 0140000 |
| 357 | #define LINUX_S_IFLNK 0120000 |
| 358 | #define LINUX_S_IFREG 0100000 |
| 359 | #define LINUX_S_IFBLK 0060000 |
| 360 | #define LINUX_S_IFDIR 0040000 |
| 361 | #define LINUX_S_IFCHR 0020000 |
| 362 | #define LINUX_S_IFIFO 0010000 |
| 363 | #define LINUX_S_ISUID 0004000 |
| 364 | #define LINUX_S_ISGID 0002000 |
| 365 | #define LINUX_S_ISVTX 0001000 |
| 366 | |
| 367 | #define LINUX_S_IRWXU 00700 |
| 368 | #define LINUX_S_IRUSR 00400 |
| 369 | #define LINUX_S_IWUSR 00200 |
| 370 | #define LINUX_S_IXUSR 00100 |
| 371 | |
| 372 | #define LINUX_S_IRWXG 00070 |
| 373 | #define LINUX_S_IRGRP 00040 |
| 374 | #define LINUX_S_IWGRP 00020 |
| 375 | #define LINUX_S_IXGRP 00010 |
| 376 | |
| 377 | #define LINUX_S_IRWXO 00007 |
| 378 | #define LINUX_S_IROTH 00004 |
| 379 | #define LINUX_S_IWOTH 00002 |
| 380 | #define LINUX_S_IXOTH 00001 |
| 381 | |
| 382 | #define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK) |
| 383 | #define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG) |
| 384 | #define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR) |
| 385 | #define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR) |
| 386 | #define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK) |
| 387 | #define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO) |
| 388 | #define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK) |
| 389 | |
| 390 | /* |
| 391 | * ext2 size of an inode |
| 392 | */ |
| 393 | #define EXT2_I_SIZE(i) ((i)->i_size | ((__u64) (i)->i_size_high << 32)) |
| 394 | |
| 395 | /* |
| 396 | * ext2_icount_t abstraction |
| 397 | */ |
| 398 | #define EXT2_ICOUNT_OPT_INCREMENT 0x01 |
| 399 | |
| 400 | typedef struct ext2_icount *ext2_icount_t; |
| 401 | |
| 402 | /* |
| 403 | * Flags for ext2fs_bmap |
| 404 | */ |
| 405 | #define BMAP_ALLOC 0x0001 |
| 406 | #define BMAP_SET 0x0002 |
| 407 | |
| 408 | /* |
| 409 | * Flags for imager.c functions |
| 410 | */ |
| 411 | #define IMAGER_FLAG_INODEMAP 1 |
| 412 | #define IMAGER_FLAG_SPARSEWRITE 2 |
| 413 | |
| 414 | /* |
| 415 | * For checking structure magic numbers... |
| 416 | */ |
| 417 | |
| 418 | #define EXT2_CHECK_MAGIC(struct, code) \ |
| 419 | if ((struct)->magic != (code)) return (code) |
| 420 | |
| 421 | |
| 422 | /* |
| 423 | * For ext2 compression support |
| 424 | */ |
| 425 | #define EXT2FS_COMPRESSED_BLKADDR ((blk_t) 0xffffffff) |
| 426 | #define HOLE_BLKADDR(_b) ((_b) == 0 || (_b) == EXT2FS_COMPRESSED_BLKADDR) |
| 427 | |
| 428 | /* |
| 429 | * Features supported by this version of the library |
| 430 | */ |
| 431 | #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\ |
| 432 | EXT2_FEATURE_COMPAT_IMAGIC_INODES|\ |
| 433 | EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ |
| 434 | EXT2_FEATURE_COMPAT_RESIZE_INODE|\ |
| 435 | EXT2_FEATURE_COMPAT_DIR_INDEX|\ |
| 436 | EXT2_FEATURE_COMPAT_EXT_ATTR) |
| 437 | |
| 438 | /* This #ifdef is temporary until compression is fully supported */ |
| 439 | #ifdef ENABLE_COMPRESSION |
| 440 | #ifndef I_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL |
| 441 | /* If the below warning bugs you, then have |
| 442 | `CPPFLAGS=-DI_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL' in your |
| 443 | environment at configure time. */ |
| 444 | #warning "Compression support is experimental" |
| 445 | #endif |
| 446 | #define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\ |
| 447 | EXT2_FEATURE_INCOMPAT_COMPRESSION|\ |
| 448 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\ |
| 449 | EXT2_FEATURE_INCOMPAT_META_BG|\ |
| 450 | EXT3_FEATURE_INCOMPAT_RECOVER) |
| 451 | #else |
| 452 | #define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\ |
| 453 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\ |
| 454 | EXT2_FEATURE_INCOMPAT_META_BG|\ |
| 455 | EXT3_FEATURE_INCOMPAT_RECOVER) |
| 456 | #endif |
| 457 | #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\ |
| 458 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE) |
| 459 | /* |
| 460 | * function prototypes |
| 461 | */ |
| 462 | |
| 463 | /* alloc.c */ |
| 464 | extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode, |
| 465 | ext2fs_inode_bitmap map, ext2_ino_t *ret); |
| 466 | extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, |
| 467 | ext2fs_block_bitmap map, blk_t *ret); |
| 468 | extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, |
| 469 | blk_t finish, int num, |
| 470 | ext2fs_block_bitmap map, |
| 471 | blk_t *ret); |
| 472 | extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, |
| 473 | char *block_buf, blk_t *ret); |
| 474 | |
| 475 | /* alloc_sb.c */ |
| 476 | extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, |
| 477 | dgrp_t group, |
| 478 | ext2fs_block_bitmap bmap); |
| 479 | |
| 480 | /* alloc_stats.c */ |
| 481 | void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse); |
| 482 | void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino, |
| 483 | int inuse, int isdir); |
| 484 | void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse); |
| 485 | |
| 486 | /* alloc_tables.c */ |
| 487 | extern errcode_t ext2fs_allocate_tables(ext2_filsys fs); |
| 488 | extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, |
| 489 | ext2fs_block_bitmap bmap); |
| 490 | |
| 491 | /* badblocks.c */ |
| 492 | extern errcode_t ext2fs_u32_list_create(ext2_u32_list *ret, int size); |
| 493 | extern errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk); |
| 494 | extern int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk); |
| 495 | extern int ext2fs_u32_list_test(ext2_u32_list bb, blk_t blk); |
| 496 | extern errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb, |
| 497 | ext2_u32_iterate *ret); |
| 498 | extern int ext2fs_u32_list_iterate(ext2_u32_iterate iter, blk_t *blk); |
| 499 | extern void ext2fs_u32_list_iterate_end(ext2_u32_iterate iter); |
| 500 | extern errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest); |
| 501 | extern int ext2fs_u32_list_equal(ext2_u32_list bb1, ext2_u32_list bb2); |
| 502 | |
| 503 | extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, |
| 504 | int size); |
| 505 | extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, |
| 506 | blk_t blk); |
| 507 | extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb, |
| 508 | blk_t blk); |
| 509 | extern int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk); |
| 510 | extern void ext2fs_badblocks_list_del(ext2_u32_list bb, __u32 blk); |
| 511 | extern errcode_t |
| 512 | ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb, |
| 513 | ext2_badblocks_iterate *ret); |
| 514 | extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter, |
| 515 | blk_t *blk); |
| 516 | extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter); |
| 517 | extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src, |
| 518 | ext2_badblocks_list *dest); |
| 519 | extern int ext2fs_badblocks_equal(ext2_badblocks_list bb1, |
| 520 | ext2_badblocks_list bb2); |
| 521 | extern int ext2fs_u32_list_count(ext2_u32_list bb); |
| 522 | |
| 523 | /* bb_compat */ |
| 524 | extern errcode_t badblocks_list_create(badblocks_list *ret, int size); |
| 525 | extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk); |
| 526 | extern int badblocks_list_test(badblocks_list bb, blk_t blk); |
| 527 | extern errcode_t badblocks_list_iterate_begin(badblocks_list bb, |
| 528 | badblocks_iterate *ret); |
| 529 | extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk); |
| 530 | extern void badblocks_list_iterate_end(badblocks_iterate iter); |
| 531 | extern void badblocks_list_free(badblocks_list bb); |
| 532 | |
| 533 | /* bb_inode.c */ |
| 534 | extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs, |
| 535 | ext2_badblocks_list bb_list); |
| 536 | |
| 537 | /* bitmaps.c */ |
| 538 | extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs); |
| 539 | extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs); |
| 540 | extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs); |
| 541 | extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs); |
| 542 | extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start, |
| 543 | __u32 end, |
| 544 | __u32 real_end, |
| 545 | const char *descr, |
| 546 | ext2fs_generic_bitmap *ret); |
| 547 | extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, |
| 548 | const char *descr, |
| 549 | ext2fs_block_bitmap *ret); |
| 550 | extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, |
| 551 | const char *descr, |
| 552 | ext2fs_inode_bitmap *ret); |
| 553 | extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap, |
| 554 | ext2_ino_t end, ext2_ino_t *oend); |
| 555 | extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap, |
| 556 | blk_t end, blk_t *oend); |
| 557 | extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap); |
| 558 | extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap); |
| 559 | extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs); |
| 560 | extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs); |
| 561 | |
| 562 | /* block.c */ |
| 563 | extern errcode_t ext2fs_block_iterate(ext2_filsys fs, |
| 564 | ext2_ino_t ino, |
| 565 | int flags, |
| 566 | char *block_buf, |
| 567 | int (*func)(ext2_filsys fs, |
| 568 | blk_t *blocknr, |
| 569 | int blockcnt, |
| 570 | void *priv_data), |
| 571 | void *priv_data); |
| 572 | errcode_t ext2fs_block_iterate2(ext2_filsys fs, |
| 573 | ext2_ino_t ino, |
| 574 | int flags, |
| 575 | char *block_buf, |
| 576 | int (*func)(ext2_filsys fs, |
| 577 | blk_t *blocknr, |
| 578 | e2_blkcnt_t blockcnt, |
| 579 | blk_t ref_blk, |
| 580 | int ref_offset, |
| 581 | void *priv_data), |
| 582 | void *priv_data); |
| 583 | |
| 584 | /* bmap.c */ |
| 585 | extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, |
| 586 | struct ext2_inode *inode, |
| 587 | char *block_buf, int bmap_flags, |
| 588 | blk_t block, blk_t *phys_blk); |
| 589 | |
| 590 | |
| 591 | #if 0 |
| 592 | /* bmove.c */ |
| 593 | extern errcode_t ext2fs_move_blocks(ext2_filsys fs, |
| 594 | ext2fs_block_bitmap reserve, |
| 595 | ext2fs_block_bitmap alloc_map, |
| 596 | int flags); |
| 597 | #endif |
| 598 | |
| 599 | /* check_desc.c */ |
| 600 | extern errcode_t ext2fs_check_desc(ext2_filsys fs); |
| 601 | |
| 602 | /* closefs.c */ |
| 603 | extern errcode_t ext2fs_close(ext2_filsys fs); |
| 604 | extern errcode_t ext2fs_flush(ext2_filsys fs); |
| 605 | extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block); |
| 606 | extern int ext2fs_super_and_bgd_loc(ext2_filsys fs, |
| 607 | dgrp_t group, |
| 608 | blk_t *ret_super_blk, |
| 609 | blk_t *ret_old_desc_blk, |
| 610 | blk_t *ret_new_desc_blk, |
| 611 | int *ret_meta_bg); |
| 612 | extern void ext2fs_update_dynamic_rev(ext2_filsys fs); |
| 613 | |
| 614 | /* cmp_bitmaps.c */ |
| 615 | extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1, |
| 616 | ext2fs_block_bitmap bm2); |
| 617 | extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1, |
| 618 | ext2fs_inode_bitmap bm2); |
| 619 | |
| 620 | /* dblist.c */ |
| 621 | |
| 622 | extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs); |
| 623 | extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist); |
| 624 | extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, |
| 625 | blk_t blk, int blockcnt); |
| 626 | extern void ext2fs_dblist_sort(ext2_dblist dblist, |
| 627 | EXT2_QSORT_TYPE (*sortfunc)(const void *, |
| 628 | const void *)); |
| 629 | extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, |
| 630 | int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info, |
| 631 | void *priv_data), |
| 632 | void *priv_data); |
| 633 | extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, |
| 634 | blk_t blk, int blockcnt); |
| 635 | extern errcode_t ext2fs_copy_dblist(ext2_dblist src, |
| 636 | ext2_dblist *dest); |
| 637 | extern int ext2fs_dblist_count(ext2_dblist dblist); |
| 638 | |
| 639 | /* dblist_dir.c */ |
| 640 | extern errcode_t |
| 641 | ext2fs_dblist_dir_iterate(ext2_dblist dblist, |
| 642 | int flags, |
| 643 | char *block_buf, |
| 644 | int (*func)(ext2_ino_t dir, |
| 645 | int entry, |
| 646 | struct ext2_dir_entry *dirent, |
| 647 | int offset, |
| 648 | int blocksize, |
| 649 | char *buf, |
| 650 | void *priv_data), |
| 651 | void *priv_data); |
| 652 | |
| 653 | /* dirblock.c */ |
| 654 | extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block, |
| 655 | void *buf); |
| 656 | extern errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block, |
| 657 | void *buf, int flags); |
| 658 | extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block, |
| 659 | void *buf); |
| 660 | extern errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block, |
| 661 | void *buf, int flags); |
| 662 | |
| 663 | /* dirhash.c */ |
| 664 | extern errcode_t ext2fs_dirhash(int version, const char *name, int len, |
| 665 | const __u32 *seed, |
| 666 | ext2_dirhash_t *ret_hash, |
| 667 | ext2_dirhash_t *ret_minor_hash); |
| 668 | |
| 669 | |
| 670 | /* dir_iterate.c */ |
| 671 | extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, |
| 672 | ext2_ino_t dir, |
| 673 | int flags, |
| 674 | char *block_buf, |
| 675 | int (*func)(struct ext2_dir_entry *dirent, |
| 676 | int offset, |
| 677 | int blocksize, |
| 678 | char *buf, |
| 679 | void *priv_data), |
| 680 | void *priv_data); |
| 681 | extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs, |
| 682 | ext2_ino_t dir, |
| 683 | int flags, |
| 684 | char *block_buf, |
| 685 | int (*func)(ext2_ino_t dir, |
| 686 | int entry, |
| 687 | struct ext2_dir_entry *dirent, |
| 688 | int offset, |
| 689 | int blocksize, |
| 690 | char *buf, |
| 691 | void *priv_data), |
| 692 | void *priv_data); |
| 693 | |
| 694 | /* dupfs.c */ |
| 695 | extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest); |
| 696 | |
| 697 | /* expanddir.c */ |
| 698 | extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir); |
| 699 | |
| 700 | /* ext_attr.c */ |
| 701 | extern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf); |
| 702 | extern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, |
| 703 | void *buf); |
| 704 | extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk, |
| 705 | char *block_buf, |
| 706 | int adjust, __u32 *newcount); |
| 707 | |
| 708 | /* fileio.c */ |
| 709 | extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, |
| 710 | struct ext2_inode *inode, |
| 711 | int flags, ext2_file_t *ret); |
| 712 | extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino, |
| 713 | int flags, ext2_file_t *ret); |
| 714 | extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file); |
| 715 | extern errcode_t ext2fs_file_close(ext2_file_t file); |
| 716 | extern errcode_t ext2fs_file_flush(ext2_file_t file); |
| 717 | extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf, |
| 718 | unsigned int wanted, unsigned int *got); |
| 719 | extern errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, |
| 720 | unsigned int nbytes, unsigned int *written); |
| 721 | extern errcode_t ext2fs_file_llseek(ext2_file_t file, __u64 offset, |
| 722 | int whence, __u64 *ret_pos); |
| 723 | extern errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset, |
| 724 | int whence, ext2_off_t *ret_pos); |
| 725 | errcode_t ext2fs_file_get_lsize(ext2_file_t file, __u64 *ret_size); |
| 726 | extern ext2_off_t ext2fs_file_get_size(ext2_file_t file); |
| 727 | extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size); |
| 728 | |
| 729 | /* finddev.c */ |
| 730 | extern char *ext2fs_find_block_device(dev_t device); |
| 731 | |
| 732 | /* flushb.c */ |
| 733 | extern errcode_t ext2fs_sync_device(int fd, int flushb); |
| 734 | |
| 735 | /* freefs.c */ |
| 736 | extern void ext2fs_free(ext2_filsys fs); |
| 737 | extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap); |
| 738 | extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap); |
| 739 | extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap); |
| 740 | extern void ext2fs_free_dblist(ext2_dblist dblist); |
| 741 | extern void ext2fs_badblocks_list_free(ext2_badblocks_list bb); |
| 742 | extern void ext2fs_u32_list_free(ext2_u32_list bb); |
| 743 | |
| 744 | /* getsize.c */ |
| 745 | extern errcode_t ext2fs_get_device_size(const char *file, int blocksize, |
| 746 | blk_t *retblocks); |
| 747 | |
| 748 | /* getsectsize.c */ |
| 749 | errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize); |
| 750 | |
| 751 | /* imager.c */ |
| 752 | extern errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags); |
| 753 | extern errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags); |
| 754 | extern errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags); |
| 755 | extern errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags); |
| 756 | extern errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags); |
| 757 | extern errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags); |
| 758 | |
| 759 | /* ind_block.c */ |
| 760 | errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf); |
| 761 | errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf); |
| 762 | |
| 763 | /* initialize.c */ |
| 764 | extern errcode_t ext2fs_initialize(const char *name, int flags, |
| 765 | struct ext2_super_block *param, |
| 766 | io_manager manager, ext2_filsys *ret_fs); |
| 767 | |
| 768 | /* icount.c */ |
| 769 | extern void ext2fs_free_icount(ext2_icount_t icount); |
| 770 | extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, |
| 771 | unsigned int size, |
| 772 | ext2_icount_t hint, ext2_icount_t *ret); |
| 773 | extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, |
| 774 | unsigned int size, |
| 775 | ext2_icount_t *ret); |
| 776 | extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, |
| 777 | __u16 *ret); |
| 778 | extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino, |
| 779 | __u16 *ret); |
| 780 | extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino, |
| 781 | __u16 *ret); |
| 782 | extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino, |
| 783 | __u16 count); |
| 784 | extern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount); |
| 785 | errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *); |
| 786 | |
| 787 | /* inode.c */ |
| 788 | extern errcode_t ext2fs_flush_icache(ext2_filsys fs); |
| 789 | extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, |
| 790 | ext2_ino_t *ino, |
| 791 | struct ext2_inode *inode, |
| 792 | int bufsize); |
| 793 | extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, |
| 794 | ext2_inode_scan *ret_scan); |
| 795 | extern void ext2fs_close_inode_scan(ext2_inode_scan scan); |
| 796 | extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino, |
| 797 | struct ext2_inode *inode); |
| 798 | extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan, |
| 799 | int group); |
| 800 | extern void ext2fs_set_inode_callback |
| 801 | (ext2_inode_scan scan, |
| 802 | errcode_t (*done_group)(ext2_filsys fs, |
| 803 | ext2_inode_scan scan, |
| 804 | dgrp_t group, |
| 805 | void * priv_data), |
| 806 | void *done_group_data); |
| 807 | extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags, |
| 808 | int clear_flags); |
| 809 | extern errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, |
| 810 | struct ext2_inode * inode, |
| 811 | int bufsize); |
| 812 | extern errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino, |
| 813 | struct ext2_inode * inode); |
| 814 | extern errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, |
| 815 | struct ext2_inode * inode, |
| 816 | int bufsize); |
| 817 | extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, |
| 818 | struct ext2_inode * inode); |
| 819 | extern errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, |
| 820 | struct ext2_inode * inode); |
| 821 | extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks); |
| 822 | extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino); |
| 823 | |
| 824 | /* inode_io.c */ |
| 825 | extern io_manager inode_io_manager; |
| 826 | extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, |
| 827 | char **name); |
| 828 | extern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino, |
| 829 | struct ext2_inode *inode, |
| 830 | char **name); |
| 831 | |
| 832 | /* ismounted.c */ |
| 833 | extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags); |
| 834 | extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, |
| 835 | char *mtpt, int mtlen); |
| 836 | |
| 837 | /* namei.c */ |
| 838 | extern errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name, |
| 839 | int namelen, char *buf, ext2_ino_t *inode); |
| 840 | extern errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, |
| 841 | const char *name, ext2_ino_t *inode); |
| 842 | errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, |
| 843 | const char *name, ext2_ino_t *inode); |
| 844 | extern errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, |
| 845 | ext2_ino_t inode, ext2_ino_t *res_inode); |
| 846 | |
| 847 | /* native.c */ |
| 848 | int ext2fs_native_flag(void); |
| 849 | |
| 850 | /* newdir.c */ |
| 851 | extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino, |
| 852 | ext2_ino_t parent_ino, char **block); |
| 853 | |
| 854 | /* mkdir.c */ |
| 855 | extern errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, |
| 856 | const char *name); |
| 857 | |
| 858 | /* mkjournal.c */ |
| 859 | extern errcode_t ext2fs_create_journal_superblock(ext2_filsys fs, |
| 860 | __u32 size, int flags, |
| 861 | char **ret_jsb); |
| 862 | extern errcode_t ext2fs_add_journal_device(ext2_filsys fs, |
| 863 | ext2_filsys journal_dev); |
| 864 | extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, |
| 865 | int flags); |
| 866 | |
| 867 | /* openfs.c */ |
| 868 | extern errcode_t ext2fs_open(const char *name, int flags, int superblock, |
| 869 | unsigned int block_size, io_manager manager, |
| 870 | ext2_filsys *ret_fs); |
| 871 | extern errcode_t ext2fs_open2(const char *name, const char *io_options, |
| 872 | int flags, int superblock, |
| 873 | unsigned int block_size, io_manager manager, |
| 874 | ext2_filsys *ret_fs); |
| 875 | extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, |
| 876 | dgrp_t i); |
| 877 | errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io); |
| 878 | errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io); |
| 879 | errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io); |
| 880 | |
| 881 | /* get_pathname.c */ |
| 882 | extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino, |
| 883 | char **name); |
| 884 | |
| 885 | /* link.c */ |
| 886 | errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name, |
| 887 | ext2_ino_t ino, int flags); |
| 888 | errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name, |
| 889 | ext2_ino_t ino, int flags); |
| 890 | |
| 891 | /* read_bb.c */ |
| 892 | extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs, |
| 893 | ext2_badblocks_list *bb_list); |
| 894 | |
| 895 | /* read_bb_file.c */ |
| 896 | extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, |
| 897 | ext2_badblocks_list *bb_list, |
| 898 | void *priv_data, |
| 899 | void (*invalid)(ext2_filsys fs, |
| 900 | blk_t blk, |
| 901 | char *badstr, |
| 902 | void *priv_data)); |
| 903 | extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, |
| 904 | ext2_badblocks_list *bb_list, |
| 905 | void (*invalid)(ext2_filsys fs, |
| 906 | blk_t blk)); |
| 907 | |
| 908 | /* res_gdt.c */ |
| 909 | extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs); |
| 910 | |
| 911 | /* rs_bitmap.c */ |
| 912 | extern errcode_t ext2fs_resize_generic_bitmap(__u32 new_end, |
| 913 | __u32 new_real_end, |
| 914 | ext2fs_generic_bitmap bmap); |
| 915 | extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end, |
| 916 | ext2fs_inode_bitmap bmap); |
| 917 | extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end, |
| 918 | ext2fs_block_bitmap bmap); |
| 919 | extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src, |
| 920 | ext2fs_generic_bitmap *dest); |
| 921 | |
| 922 | /* swapfs.c */ |
| 923 | extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, |
| 924 | int has_header); |
| 925 | extern void ext2fs_swap_super(struct ext2_super_block * super); |
| 926 | extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp); |
| 927 | extern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, |
| 928 | struct ext2_inode_large *f, int hostorder, |
| 929 | int bufsize); |
| 930 | extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t, |
| 931 | struct ext2_inode *f, int hostorder); |
| 932 | |
| 933 | /* valid_blk.c */ |
| 934 | extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode); |
| 935 | |
| 936 | /* version.c */ |
| 937 | extern int ext2fs_parse_version_string(const char *ver_string); |
| 938 | extern int ext2fs_get_library_version(const char **ver_string, |
| 939 | const char **date_string); |
| 940 | |
| 941 | /* write_bb_file.c */ |
| 942 | extern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list, |
| 943 | unsigned int flags, |
| 944 | FILE *f); |
| 945 | |
| 946 | |
| 947 | /* inline functions */ |
| 948 | extern errcode_t ext2fs_get_mem(unsigned long size, void *ptr); |
| 949 | extern errcode_t ext2fs_free_mem(void *ptr); |
| 950 | extern errcode_t ext2fs_resize_mem(unsigned long old_size, |
| 951 | unsigned long size, void *ptr); |
| 952 | extern void ext2fs_mark_super_dirty(ext2_filsys fs); |
| 953 | extern void ext2fs_mark_changed(ext2_filsys fs); |
| 954 | extern int ext2fs_test_changed(ext2_filsys fs); |
| 955 | extern void ext2fs_mark_valid(ext2_filsys fs); |
| 956 | extern void ext2fs_unmark_valid(ext2_filsys fs); |
| 957 | extern int ext2fs_test_valid(ext2_filsys fs); |
| 958 | extern void ext2fs_mark_ib_dirty(ext2_filsys fs); |
| 959 | extern void ext2fs_mark_bb_dirty(ext2_filsys fs); |
| 960 | extern int ext2fs_test_ib_dirty(ext2_filsys fs); |
| 961 | extern int ext2fs_test_bb_dirty(ext2_filsys fs); |
| 962 | extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk); |
| 963 | extern int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino); |
| 964 | extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs, |
| 965 | struct ext2_inode *inode); |
| 966 | |
| 967 | /* |
| 968 | * The actual inlined functions definitions themselves... |
| 969 | * |
| 970 | * If NO_INLINE_FUNCS is defined, then we won't try to do inline |
| 971 | * functions at all! |
| 972 | */ |
| 973 | #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) |
| 974 | #ifdef INCLUDE_INLINE_FUNCS |
| 975 | #define _INLINE_ extern |
| 976 | #else |
| 977 | #ifdef __GNUC__ |
| 978 | #define _INLINE_ extern __inline__ |
| 979 | #else /* For Watcom C */ |
| 980 | #define _INLINE_ extern inline |
| 981 | #endif |
| 982 | #endif |
| 983 | |
| 984 | #ifndef EXT2_CUSTOM_MEMORY_ROUTINES |
| 985 | /* |
| 986 | * Allocate memory |
| 987 | */ |
| 988 | _INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr) |
| 989 | { |
| 990 | void **pp = (void **)ptr; |
| 991 | |
| 992 | *pp = malloc(size); |
| 993 | if (!*pp) |
| 994 | return EXT2_ET_NO_MEMORY; |
| 995 | return 0; |
| 996 | } |
| 997 | |
| 998 | /* |
| 999 | * Free memory |
| 1000 | */ |
| 1001 | _INLINE_ errcode_t ext2fs_free_mem(void *ptr) |
| 1002 | { |
| 1003 | void **pp = (void **)ptr; |
| 1004 | |
| 1005 | free(*pp); |
| 1006 | *pp = 0; |
| 1007 | return 0; |
| 1008 | } |
| 1009 | |
| 1010 | /* |
| 1011 | * Resize memory |
| 1012 | */ |
| 1013 | _INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size, |
| 1014 | unsigned long size, void *ptr) |
| 1015 | { |
| 1016 | void *p; |
| 1017 | void **pp = (void **)ptr; |
| 1018 | |
| 1019 | p = realloc(*pp, size); |
| 1020 | if (!p) |
| 1021 | return EXT2_ET_NO_MEMORY; |
| 1022 | *pp = p; |
| 1023 | return 0; |
| 1024 | } |
| 1025 | #endif /* Custom memory routines */ |
| 1026 | |
| 1027 | /* |
| 1028 | * Mark a filesystem superblock as dirty |
| 1029 | */ |
| 1030 | _INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs) |
| 1031 | { |
| 1032 | fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED; |
| 1033 | } |
| 1034 | |
| 1035 | /* |
| 1036 | * Mark a filesystem as changed |
| 1037 | */ |
| 1038 | _INLINE_ void ext2fs_mark_changed(ext2_filsys fs) |
| 1039 | { |
| 1040 | fs->flags |= EXT2_FLAG_CHANGED; |
| 1041 | } |
| 1042 | |
| 1043 | /* |
| 1044 | * Check to see if a filesystem has changed |
| 1045 | */ |
| 1046 | _INLINE_ int ext2fs_test_changed(ext2_filsys fs) |
| 1047 | { |
| 1048 | return (fs->flags & EXT2_FLAG_CHANGED); |
| 1049 | } |
| 1050 | |
| 1051 | /* |
| 1052 | * Mark a filesystem as valid |
| 1053 | */ |
| 1054 | _INLINE_ void ext2fs_mark_valid(ext2_filsys fs) |
| 1055 | { |
| 1056 | fs->flags |= EXT2_FLAG_VALID; |
| 1057 | } |
| 1058 | |
| 1059 | /* |
| 1060 | * Mark a filesystem as NOT valid |
| 1061 | */ |
| 1062 | _INLINE_ void ext2fs_unmark_valid(ext2_filsys fs) |
| 1063 | { |
| 1064 | fs->flags &= ~EXT2_FLAG_VALID; |
| 1065 | } |
| 1066 | |
| 1067 | /* |
| 1068 | * Check to see if a filesystem is valid |
| 1069 | */ |
| 1070 | _INLINE_ int ext2fs_test_valid(ext2_filsys fs) |
| 1071 | { |
| 1072 | return (fs->flags & EXT2_FLAG_VALID); |
| 1073 | } |
| 1074 | |
| 1075 | /* |
| 1076 | * Mark the inode bitmap as dirty |
| 1077 | */ |
| 1078 | _INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs) |
| 1079 | { |
| 1080 | fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED; |
| 1081 | } |
| 1082 | |
| 1083 | /* |
| 1084 | * Mark the block bitmap as dirty |
| 1085 | */ |
| 1086 | _INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs) |
| 1087 | { |
| 1088 | fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED; |
| 1089 | } |
| 1090 | |
| 1091 | /* |
| 1092 | * Check to see if a filesystem's inode bitmap is dirty |
| 1093 | */ |
| 1094 | _INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs) |
| 1095 | { |
| 1096 | return (fs->flags & EXT2_FLAG_IB_DIRTY); |
| 1097 | } |
| 1098 | |
| 1099 | /* |
| 1100 | * Check to see if a filesystem's block bitmap is dirty |
| 1101 | */ |
| 1102 | _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs) |
| 1103 | { |
| 1104 | return (fs->flags & EXT2_FLAG_BB_DIRTY); |
| 1105 | } |
| 1106 | |
| 1107 | /* |
| 1108 | * Return the group # of a block |
| 1109 | */ |
| 1110 | _INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk) |
| 1111 | { |
| 1112 | return (blk - fs->super->s_first_data_block) / |
| 1113 | fs->super->s_blocks_per_group; |
| 1114 | } |
| 1115 | |
| 1116 | /* |
| 1117 | * Return the group # of an inode number |
| 1118 | */ |
| 1119 | _INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino) |
| 1120 | { |
| 1121 | return (ino - 1) / fs->super->s_inodes_per_group; |
| 1122 | } |
| 1123 | |
| 1124 | _INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs, |
| 1125 | struct ext2_inode *inode) |
| 1126 | { |
| 1127 | return inode->i_blocks - |
| 1128 | (inode->i_file_acl ? fs->blocksize >> 9 : 0); |
| 1129 | } |
| 1130 | #undef _INLINE_ |
| 1131 | #endif |
| 1132 | |
| 1133 | #ifdef __cplusplus |
| 1134 | } |
| 1135 | #endif |
| 1136 | |
| 1137 | #endif /* _EXT2FS_EXT2FS_H */ |