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