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