Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ext2fs.h --- ext2fs |
| 3 | * |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +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% |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | /* |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 13 | * Non-GNU C compilers won't necessarily understand inline |
| 14 | */ |
| 15 | #ifndef __GNUC__ |
| 16 | #define NO_INLINE_FUNCS |
| 17 | #endif |
| 18 | |
| 19 | /* |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 20 | * Where the master copy of the superblock is located, and how big |
| 21 | * superblocks are supposed to be. We define SUPERBLOCK_SIZE because |
| 22 | * the size of the superblock structure is not necessarily trustworthy |
| 23 | * (some versions have the padding set up so that the superblock is |
| 24 | * 1032 bytes long). |
| 25 | */ |
| 26 | #define SUPERBLOCK_OFFSET 1024 |
| 27 | #define SUPERBLOCK_SIZE 1024 |
| 28 | |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 29 | /* |
| 30 | * The last ext2fs revision level that this version of the library is |
| 31 | * able to support. |
| 32 | */ |
| 33 | #define EXT2_LIB_CURRENT_REV 0 |
| 34 | |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 35 | #include <sys/types.h> |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 36 | #include <linux/types.h> |
| 37 | |
| 38 | typedef __u32 blk_t; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 39 | typedef unsigned int dgrp_t; |
| 40 | |
| 41 | #include "et/com_err.h" |
| 42 | #include "ext2fs/io.h" |
| 43 | #include "ext2fs/ext2_err.h" |
| 44 | |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 45 | typedef struct struct_ext2_filsys *ext2_filsys; |
| 46 | |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 47 | struct ext2fs_struct_generic_bitmap { |
| 48 | int magic; |
| 49 | ext2_filsys fs; |
| 50 | __u32 start, end; |
| 51 | __u32 real_end; |
| 52 | char * description; |
| 53 | char * bitmap; |
| 54 | errcode_t base_error_code; |
| 55 | __u32 reserved[7]; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 58 | #define EXT2FS_MARK_ERROR 0 |
| 59 | #define EXT2FS_UNMARK_ERROR 1 |
| 60 | #define EXT2FS_TEST_ERROR 2 |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 61 | |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 62 | typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap; |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 63 | typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap; |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 64 | typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 65 | |
Theodore Ts'o | 7f88b04 | 1997-04-26 14:48:50 +0000 | [diff] [blame] | 66 | #ifdef EXT2_DYNAMIC_REV |
| 67 | #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s) |
| 68 | #else |
| 69 | #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO |
| 70 | #define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode) |
| 71 | #endif |
| 72 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 73 | /* |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 74 | * badblocks list definitions |
| 75 | */ |
| 76 | |
| 77 | typedef struct ext2_struct_badblocks_list *ext2_badblocks_list; |
| 78 | typedef struct ext2_struct_badblocks_iterate *ext2_badblocks_iterate; |
| 79 | |
| 80 | /* old */ |
| 81 | typedef struct ext2_struct_badblocks_list *badblocks_list; |
| 82 | typedef struct ext2_struct_badblocks_iterate *badblocks_iterate; |
| 83 | |
| 84 | #define BADBLOCKS_FLAG_DIRTY 1 |
| 85 | |
| 86 | /* |
| 87 | * ext2_dblist structure and abstractions (see dblist.c) |
| 88 | */ |
| 89 | struct ext2_db_entry { |
| 90 | ino_t ino; |
| 91 | blk_t blk; |
| 92 | int blockcnt; |
| 93 | }; |
| 94 | |
| 95 | typedef struct ext2_struct_dblist *ext2_dblist; |
| 96 | |
| 97 | #define DBLIST_ABORT 1 |
| 98 | |
| 99 | /* |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 100 | * Flags for the ext2_filsys structure |
| 101 | */ |
| 102 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 103 | #define EXT2_FLAG_RW 0x01 |
| 104 | #define EXT2_FLAG_CHANGED 0x02 |
| 105 | #define EXT2_FLAG_DIRTY 0x04 |
| 106 | #define EXT2_FLAG_VALID 0x08 |
| 107 | #define EXT2_FLAG_IB_DIRTY 0x10 |
| 108 | #define EXT2_FLAG_BB_DIRTY 0x20 |
Theodore Ts'o | 5c57647 | 1997-04-29 15:29:49 +0000 | [diff] [blame] | 109 | #define EXT2_FLAG_SWAP_BYTES 0x40 |
| 110 | #define EXT2_FLAG_SWAP_BYTES_READ 0x80 |
| 111 | #define EXT2_FLAG_SWAP_BYTES_WRITE 0x100 |
| 112 | #define EXT2_FLAG_MASTER_SB_ONLY 0x200 |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 113 | #define EXT2_FLAG_FORCE 0x400 |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 114 | |
Theodore Ts'o | 7f88b04 | 1997-04-26 14:48:50 +0000 | [diff] [blame] | 115 | /* |
| 116 | * Special flag in the ext2 inode i_flag field that means that this is |
| 117 | * a new inode. (So that ext2_write_inode() can clear extra fields.) |
| 118 | */ |
| 119 | #define EXT2_NEW_INODE_FL 0x80000000 |
| 120 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 121 | struct struct_ext2_filsys { |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 122 | int magic; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 123 | io_channel io; |
| 124 | int flags; |
| 125 | char * device_name; |
| 126 | struct ext2_super_block * super; |
| 127 | int blocksize; |
| 128 | int fragsize; |
| 129 | unsigned long group_desc_count; |
| 130 | unsigned long desc_blocks; |
| 131 | struct ext2_group_desc * group_desc; |
| 132 | int inode_blocks_per_group; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 133 | ext2fs_inode_bitmap inode_map; |
| 134 | ext2fs_block_bitmap block_map; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 135 | errcode_t (*get_blocks)(ext2_filsys fs, ino_t ino, blk_t *blocks); |
| 136 | errcode_t (*check_directory)(ext2_filsys fs, ino_t ino); |
| 137 | errcode_t (*write_bitmaps)(ext2_filsys fs); |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 138 | errcode_t (*read_inode)(ext2_filsys fs, ino_t ino, |
| 139 | struct ext2_inode *inode); |
| 140 | errcode_t (*write_inode)(ext2_filsys fs, ino_t ino, |
| 141 | struct ext2_inode *inode); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 142 | badblocks_list badblocks; |
| 143 | ext2_dblist dblist; |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 144 | __u32 stride; /* for mke2fs */ |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 145 | /* |
| 146 | * Reserved for future expansion |
| 147 | */ |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 148 | __u32 reserved[11]; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 149 | |
| 150 | /* |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 151 | * Reserved for the use of the calling application. |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 152 | */ |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 153 | void * private; |
| 154 | |
| 155 | /* |
| 156 | * Inode cache |
| 157 | */ |
| 158 | struct ext2_inode_cache *icache; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 161 | #include "ext2fs/bitops.h" |
| 162 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 163 | /* |
| 164 | * Return flags for the block iterator functions |
| 165 | */ |
| 166 | #define BLOCK_CHANGED 1 |
| 167 | #define BLOCK_ABORT 2 |
| 168 | #define BLOCK_ERROR 4 |
| 169 | |
| 170 | /* |
| 171 | * Block interate flags |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 172 | * |
| 173 | * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator |
| 174 | * function should be called on blocks where the block number is zero. |
| 175 | * This is used by ext2fs_expand_dir() to be able to add a new block |
| 176 | * to an inode. It can also be used for programs that want to be able |
| 177 | * to deal with files that contain "holes". |
| 178 | * |
| 179 | * BLOCK_FLAG_TRAVERSE indicates that the iterator function for the |
| 180 | * indirect, doubly indirect, etc. blocks should be called after all |
| 181 | * of the blocks containined in the indirect blocks are processed. |
| 182 | * This is useful if you are going to be deallocating blocks from an |
| 183 | * inode. |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 184 | * |
| 185 | * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be |
| 186 | * called for data blocks only. |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 187 | */ |
| 188 | #define BLOCK_FLAG_APPEND 1 |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 189 | #define BLOCK_FLAG_HOLE 1 |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 190 | #define BLOCK_FLAG_DEPTH_TRAVERSE 2 |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 191 | #define BLOCK_FLAG_DATA_ONLY 4 |
| 192 | |
| 193 | /* |
| 194 | * Magic "block count" return values for the block iterator function. |
| 195 | */ |
| 196 | #define BLOCK_COUNT_IND (-1) |
| 197 | #define BLOCK_COUNT_DIND (-2) |
| 198 | #define BLOCK_COUNT_TIND (-3) |
| 199 | #define BLOCK_COUNT_TRANSLATOR (-4) |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 200 | |
| 201 | /* |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame^] | 202 | * Flags for ext2fs_move_blocks |
| 203 | */ |
| 204 | #define EXT2_BMOVE_GET_DBLIST 0x0001 |
| 205 | |
| 206 | /* |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 207 | * Return flags for the directory iterator functions |
| 208 | */ |
| 209 | #define DIRENT_CHANGED 1 |
| 210 | #define DIRENT_ABORT 2 |
| 211 | #define DIRENT_ERROR 3 |
| 212 | |
| 213 | /* |
| 214 | * Directory iterator flags |
| 215 | */ |
| 216 | |
| 217 | #define DIRENT_FLAG_INCLUDE_EMPTY 1 |
| 218 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 219 | |
| 220 | #define DIRENT_DOT_FILE 1 |
| 221 | #define DIRENT_DOT_DOT_FILE 2 |
| 222 | #define DIRENT_OTHER_FILE 3 |
| 223 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 224 | /* |
| 225 | * Inode scan definitions |
| 226 | */ |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 227 | typedef struct ext2_struct_inode_scan *ext2_inode_scan; |
| 228 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 229 | /* |
| 230 | * ext2fs_scan flags |
| 231 | */ |
| 232 | #define EXT2_SF_CHK_BADBLOCKS 0x0001 |
| 233 | #define EXT2_SF_BAD_INODE_BLK 0x0002 |
| 234 | #define EXT2_SF_BAD_EXTRA_BYTES 0x0004 |
| 235 | #define EXT2_SF_SKIP_MISSING_ITABLE 0x0008 |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 236 | |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 237 | /* |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 238 | * ext2fs_check_if_mounted flags |
| 239 | */ |
| 240 | #define EXT2_MF_MOUNTED 1 |
| 241 | #define EXT2_MF_ISROOT 2 |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 242 | #define EXT2_MF_READONLY 4 |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 243 | |
| 244 | /* |
| 245 | * Ext2/linux mode flags. We define them here so that we don't need |
| 246 | * to depend on the OS's sys/stat.h, since we may be compiling on a |
| 247 | * non-Linux system. |
| 248 | */ |
| 249 | #define LINUX_S_IFMT 00170000 |
| 250 | #define LINUX_S_IFSOCK 0140000 |
| 251 | #define LINUX_S_IFLNK 0120000 |
| 252 | #define LINUX_S_IFREG 0100000 |
| 253 | #define LINUX_S_IFBLK 0060000 |
| 254 | #define LINUX_S_IFDIR 0040000 |
| 255 | #define LINUX_S_IFCHR 0020000 |
| 256 | #define LINUX_S_IFIFO 0010000 |
| 257 | #define LINUX_S_ISUID 0004000 |
| 258 | #define LINUX_S_ISGID 0002000 |
| 259 | #define LINUX_S_ISVTX 0001000 |
| 260 | |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 261 | #define LINUX_S_IRWXU 00700 |
| 262 | #define LINUX_S_IRUSR 00400 |
| 263 | #define LINUX_S_IWUSR 00200 |
| 264 | #define LINUX_S_IXUSR 00100 |
| 265 | |
| 266 | #define LINUX_S_IRWXG 00070 |
| 267 | #define LINUX_S_IRGRP 00040 |
| 268 | #define LINUX_S_IWGRP 00020 |
| 269 | #define LINUX_S_IXGRP 00010 |
| 270 | |
| 271 | #define LINUX_S_IRWXO 00007 |
| 272 | #define LINUX_S_IROTH 00004 |
| 273 | #define LINUX_S_IWOTH 00002 |
| 274 | #define LINUX_S_IXOTH 00001 |
| 275 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 276 | #define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK) |
| 277 | #define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG) |
| 278 | #define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR) |
| 279 | #define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR) |
| 280 | #define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK) |
| 281 | #define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO) |
| 282 | #define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK) |
| 283 | |
| 284 | /* |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 285 | * ext2_icount_t abstraction |
| 286 | */ |
| 287 | #define EXT2_ICOUNT_OPT_INCREMENT 0x01 |
| 288 | |
| 289 | typedef struct ext2_icount *ext2_icount_t; |
| 290 | |
| 291 | /* |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 292 | * For checking structure magic numbers... |
| 293 | */ |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 294 | |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 295 | #define EXT2_CHECK_MAGIC(struct, code) \ |
| 296 | if ((struct)->magic != (code)) return (code) |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 297 | |
| 298 | |
| 299 | /* |
| 300 | * The ext2fs library private definition of the ext2 superblock, so we |
| 301 | * don't have to depend on the kernel's definition of the superblock, |
| 302 | * which might not have the latest features. |
| 303 | */ |
| 304 | struct ext2fs_sb { |
| 305 | __u32 s_inodes_count; /* Inodes count */ |
| 306 | __u32 s_blocks_count; /* Blocks count */ |
| 307 | __u32 s_r_blocks_count; /* Reserved blocks count */ |
| 308 | __u32 s_free_blocks_count; /* Free blocks count */ |
| 309 | __u32 s_free_inodes_count; /* Free inodes count */ |
| 310 | __u32 s_first_data_block; /* First Data Block */ |
| 311 | __u32 s_log_block_size; /* Block size */ |
| 312 | __s32 s_log_frag_size; /* Fragment size */ |
| 313 | __u32 s_blocks_per_group; /* # Blocks per group */ |
| 314 | __u32 s_frags_per_group; /* # Fragments per group */ |
| 315 | __u32 s_inodes_per_group; /* # Inodes per group */ |
| 316 | __u32 s_mtime; /* Mount time */ |
| 317 | __u32 s_wtime; /* Write time */ |
| 318 | __u16 s_mnt_count; /* Mount count */ |
| 319 | __s16 s_max_mnt_count; /* Maximal mount count */ |
| 320 | __u16 s_magic; /* Magic signature */ |
| 321 | __u16 s_state; /* File system state */ |
| 322 | __u16 s_errors; /* Behaviour when detecting errors */ |
| 323 | __u16 s_minor_rev_level; /* minor revision level */ |
| 324 | __u32 s_lastcheck; /* time of last check */ |
| 325 | __u32 s_checkinterval; /* max. time between checks */ |
| 326 | __u32 s_creator_os; /* OS */ |
| 327 | __u32 s_rev_level; /* Revision level */ |
| 328 | __u16 s_def_resuid; /* Default uid for reserved blocks */ |
| 329 | __u16 s_def_resgid; /* Default gid for reserved blocks */ |
| 330 | /* |
| 331 | * These fields are for EXT2_DYNAMIC_REV superblocks only. |
| 332 | * |
| 333 | * Note: the difference between the compatible feature set and |
| 334 | * the incompatible feature set is that if there is a bit set |
| 335 | * in the incompatible feature set that the kernel doesn't |
| 336 | * know about, it should refuse to mount the filesystem. |
| 337 | * |
| 338 | * e2fsck's requirements are more strict; if it doesn't know |
| 339 | * about a feature in either the compatible or incompatible |
| 340 | * feature set, it must abort and not try to meddle with |
| 341 | * things it doesn't understand... |
| 342 | */ |
| 343 | __u32 s_first_ino; /* First non-reserved inode */ |
| 344 | __u16 s_inode_size; /* size of inode structure */ |
| 345 | __u16 s_block_group_nr; /* block group # of this superblock */ |
| 346 | __u32 s_feature_compat; /* compatible feature set */ |
| 347 | __u32 s_feature_incompat; /* incompatible feature set */ |
| 348 | __u32 s_feature_ro_compat; /* readonly-compatible feature set */ |
| 349 | __u8 s_uuid[16]; /* 128-bit uuid for volume */ |
| 350 | char s_volume_name[16]; /* volume name */ |
| 351 | char s_last_mounted[64]; /* directory where last mounted */ |
| 352 | __u32 s_reserved[206]; /* Padding to the end of the block */ |
| 353 | }; |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 354 | |
| 355 | /* |
| 356 | * Feature set definitions (that might not be in ext2_fs.h |
| 357 | * (was EXT2_COMPAT_SPARSE_SUPER) |
| 358 | */ |
| 359 | #ifndef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER |
| 360 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
| 361 | #endif |
| 362 | |
| 363 | #define EXT2_LIB_FEATURE_COMPAT_SUPP 0 |
| 364 | #define EXT2_LIB_FEATURE_INCOMPAT_SUPP 0 |
| 365 | #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER |
| 366 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 367 | /* |
| 368 | * function prototypes |
| 369 | */ |
| 370 | |
| 371 | /* alloc.c */ |
| 372 | extern errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 373 | ext2fs_inode_bitmap map, ino_t *ret); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 374 | extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 375 | ext2fs_block_bitmap map, blk_t *ret); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 376 | extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 377 | blk_t finish, int num, |
| 378 | ext2fs_block_bitmap map, |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 379 | blk_t *ret); |
| 380 | |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame^] | 381 | /* alloc_tables.c */ |
| 382 | extern errcode_t ext2fs_allocate_tables(ext2_filsys fs); |
| 383 | extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, int group, |
| 384 | ext2fs_block_bitmap bmap); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 385 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 386 | /* badblocks.c */ |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 387 | extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, |
| 388 | int size); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 389 | extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, |
| 390 | blk_t blk); |
| 391 | extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb, |
| 392 | blk_t blk); |
| 393 | extern errcode_t |
| 394 | ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb, |
| 395 | ext2_badblocks_iterate *ret); |
| 396 | extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter, |
| 397 | blk_t *blk); |
| 398 | extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter); |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 399 | extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src, |
| 400 | ext2_badblocks_list *dest); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 401 | |
| 402 | /* bb_compat */ |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 403 | extern errcode_t badblocks_list_create(badblocks_list *ret, int size); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 404 | extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk); |
| 405 | extern int badblocks_list_test(badblocks_list bb, blk_t blk); |
| 406 | extern errcode_t badblocks_list_iterate_begin(badblocks_list bb, |
| 407 | badblocks_iterate *ret); |
| 408 | extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk); |
| 409 | extern void badblocks_list_iterate_end(badblocks_iterate iter); |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 410 | extern void badblocks_list_free(badblocks_list bb); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 411 | |
| 412 | /* bb_inode.c */ |
| 413 | extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs, |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 414 | ext2_badblocks_list bb_list); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 415 | |
| 416 | /* bitmaps.c */ |
| 417 | extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs); |
| 418 | extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs); |
| 419 | extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs); |
| 420 | extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs); |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 421 | extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start, |
| 422 | __u32 end, |
| 423 | __u32 real_end, |
| 424 | const char *descr, |
| 425 | ext2fs_generic_bitmap *ret); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 426 | extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, |
| 427 | const char *descr, |
| 428 | ext2fs_block_bitmap *ret); |
| 429 | extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, |
| 430 | const char *descr, |
| 431 | ext2fs_inode_bitmap *ret); |
| 432 | extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap, |
| 433 | ino_t end, ino_t *oend); |
| 434 | extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap, |
| 435 | blk_t end, blk_t *oend); |
| 436 | extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap); |
| 437 | extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 438 | extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs); |
| 439 | extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs); |
| 440 | |
| 441 | /* block.c */ |
| 442 | extern errcode_t ext2fs_block_iterate(ext2_filsys fs, |
| 443 | ino_t ino, |
| 444 | int flags, |
| 445 | char *block_buf, |
| 446 | int (*func)(ext2_filsys fs, |
| 447 | blk_t *blocknr, |
| 448 | int blockcnt, |
| 449 | void *private), |
| 450 | void *private); |
| 451 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 452 | errcode_t ext2fs_block_iterate2(ext2_filsys fs, |
| 453 | ino_t ino, |
| 454 | int flags, |
| 455 | char *block_buf, |
| 456 | int (*func)(ext2_filsys fs, |
| 457 | blk_t *blocknr, |
| 458 | int blockcnt, |
| 459 | blk_t ref_blk, |
| 460 | int ref_offset, |
| 461 | void *private), |
| 462 | void *private); |
| 463 | |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame^] | 464 | /* bmove.c */ |
| 465 | extern errcode_t ext2fs_move_blocks(ext2_filsys fs, |
| 466 | ext2fs_block_bitmap reserve, |
| 467 | int flags); |
| 468 | |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 469 | /* check_desc.c */ |
| 470 | extern errcode_t ext2fs_check_desc(ext2_filsys fs); |
| 471 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 472 | /* closefs.c */ |
| 473 | extern errcode_t ext2fs_close(ext2_filsys fs); |
| 474 | extern errcode_t ext2fs_flush(ext2_filsys fs); |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 475 | extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 476 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 477 | /* cmp_bitmaps.c */ |
| 478 | extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1, |
| 479 | ext2fs_block_bitmap bm2); |
| 480 | extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1, |
| 481 | ext2fs_inode_bitmap bm2); |
| 482 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 483 | /* dblist.c */ |
| 484 | |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 485 | extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs); |
| 486 | extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist); |
| 487 | extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino, |
| 488 | blk_t blk, int blockcnt); |
| 489 | extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, |
| 490 | int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info, |
| 491 | void *private), |
| 492 | void *private); |
| 493 | extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino, |
| 494 | blk_t blk, int blockcnt); |
| 495 | extern errcode_t ext2fs_copy_dblist(ext2_dblist src, |
| 496 | ext2_dblist *dest); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 497 | |
| 498 | /* dblist_dir.c */ |
| 499 | extern errcode_t |
| 500 | ext2fs_dblist_dir_iterate(ext2_dblist dblist, |
| 501 | int flags, |
| 502 | char *block_buf, |
| 503 | int (*func)(ino_t dir, |
| 504 | int entry, |
| 505 | struct ext2_dir_entry *dirent, |
| 506 | int offset, |
| 507 | int blocksize, |
| 508 | char *buf, |
| 509 | void *private), |
| 510 | void *private); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 511 | |
| 512 | /* dirblock.c */ |
| 513 | extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block, |
| 514 | void *buf); |
| 515 | extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block, |
| 516 | void *buf); |
| 517 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 518 | /* dir_iterate.c */ |
| 519 | extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, |
| 520 | ino_t dir, |
| 521 | int flags, |
| 522 | char *block_buf, |
| 523 | int (*func)(struct ext2_dir_entry *dirent, |
| 524 | int offset, |
| 525 | int blocksize, |
| 526 | char *buf, |
| 527 | void *private), |
| 528 | void *private); |
| 529 | /* private to library */ |
| 530 | extern int ext2fs_process_dir_block(ext2_filsys fs, |
| 531 | blk_t *blocknr, |
| 532 | int blockcnt, |
| 533 | void *private); |
| 534 | |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 535 | /* dupfs.c */ |
| 536 | extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 537 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 538 | /* expanddir.c */ |
| 539 | extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir); |
| 540 | |
| 541 | /* freefs.c */ |
| 542 | extern void ext2fs_free(ext2_filsys fs); |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 543 | extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 544 | extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap); |
| 545 | extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap); |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 546 | extern void ext2fs_free_dblist(ext2_dblist dblist); |
| 547 | extern void ext2fs_badblocks_list_free(badblocks_list bb); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 548 | |
| 549 | /* getsize.c */ |
| 550 | extern errcode_t ext2fs_get_device_size(const char *file, int blocksize, |
| 551 | blk_t *retblocks); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 552 | |
| 553 | /* initialize.c */ |
| 554 | extern errcode_t ext2fs_initialize(const char *name, int flags, |
| 555 | struct ext2_super_block *param, |
| 556 | io_manager manager, ext2_filsys *ret_fs); |
| 557 | |
| 558 | /* inode.c */ |
| 559 | extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, |
| 560 | ext2_inode_scan *ret_scan); |
| 561 | extern void ext2fs_close_inode_scan(ext2_inode_scan scan); |
| 562 | extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino, |
| 563 | struct ext2_inode *inode); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 564 | extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan, |
| 565 | int group); |
| 566 | extern void ext2fs_set_inode_callback |
| 567 | (ext2_inode_scan scan, |
| 568 | errcode_t (*done_group)(ext2_filsys fs, |
| 569 | ext2_inode_scan scan, |
| 570 | dgrp_t group, |
| 571 | void * private), |
| 572 | void *done_group_data); |
| 573 | extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags, |
| 574 | int clear_flags); |
| 575 | extern errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino, |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 576 | struct ext2_inode * inode); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 577 | extern errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino, |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 578 | struct ext2_inode * inode); |
| 579 | extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks); |
| 580 | extern errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino); |
| 581 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 582 | /* icount.c */ |
| 583 | extern void ext2fs_free_icount(ext2_icount_t icount); |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 584 | extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, int size, |
| 585 | ext2_icount_t hint, ext2_icount_t *ret); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 586 | extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, int size, |
| 587 | ext2_icount_t *ret); |
| 588 | extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ino_t ino, |
| 589 | __u16 *ret); |
| 590 | extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ino_t ino, |
| 591 | __u16 *ret); |
| 592 | extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ino_t ino, |
| 593 | __u16 *ret); |
| 594 | extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ino_t ino, |
| 595 | __u16 count); |
| 596 | extern ino_t ext2fs_get_icount_size(ext2_icount_t icount); |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 597 | errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 598 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 599 | /* ismounted.c */ |
| 600 | extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags); |
| 601 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 602 | /* namei.c */ |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 603 | extern errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name, |
| 604 | int namelen, char *buf, ino_t *inode); |
| 605 | extern errcode_t ext2fs_namei(ext2_filsys fs, ino_t root, ino_t cwd, |
| 606 | const char *name, ino_t *inode); |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 607 | errcode_t ext2fs_namei_follow(ext2_filsys fs, ino_t root, ino_t cwd, |
| 608 | const char *name, ino_t *inode); |
| 609 | extern errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd, |
| 610 | ino_t inode, ino_t *res_inode); |
| 611 | |
| 612 | /* native.c */ |
| 613 | int ext2fs_native_flag(void); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 614 | |
| 615 | /* newdir.c */ |
| 616 | extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino, |
| 617 | ino_t parent_ino, char **block); |
| 618 | |
| 619 | /* mkdir.c */ |
| 620 | extern errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, |
| 621 | const char *name); |
| 622 | |
| 623 | /* openfs.c */ |
| 624 | extern errcode_t ext2fs_open(const char *name, int flags, int superblock, |
| 625 | int block_size, io_manager manager, |
| 626 | ext2_filsys *ret_fs); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 627 | |
| 628 | /* get_pathname.c */ |
| 629 | extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino, |
| 630 | char **name); |
| 631 | |
| 632 | /* link.c */ |
| 633 | errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name, |
| 634 | ino_t ino, int flags); |
| 635 | errcode_t ext2fs_unlink(ext2_filsys fs, ino_t dir, const char *name, |
| 636 | ino_t ino, int flags); |
| 637 | |
| 638 | /* read_bb.c */ |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 639 | extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs, |
| 640 | ext2_badblocks_list *bb_list); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 641 | |
| 642 | /* read_bb_file.c */ |
| 643 | extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 644 | ext2_badblocks_list *bb_list, |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 645 | void (*invalid)(ext2_filsys fs, |
| 646 | blk_t blk)); |
| 647 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 648 | /* rs_bitmap.c */ |
| 649 | extern errcode_t ext2fs_resize_generic_bitmap(__u32 new_end, |
| 650 | __u32 new_real_end, |
| 651 | ext2fs_generic_bitmap bmap); |
| 652 | extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end, |
| 653 | ext2fs_inode_bitmap bmap); |
| 654 | extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end, |
| 655 | ext2fs_block_bitmap bmap); |
Theodore Ts'o | a29f4d3 | 1997-04-29 21:26:48 +0000 | [diff] [blame] | 656 | extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src, |
| 657 | ext2fs_generic_bitmap *dest); |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 658 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 659 | /* swapfs.c */ |
| 660 | extern void ext2fs_swap_super(struct ext2_super_block * super); |
| 661 | extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp); |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 662 | extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t, |
| 663 | struct ext2_inode *f, int hostorder); |
| 664 | |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 665 | /* valid_blk.c */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 666 | extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode); |
| 667 | |
| 668 | /* version.c */ |
| 669 | extern int ext2fs_parse_version_string(const char *ver_string); |
| 670 | extern int ext2fs_get_library_version(const char **ver_string, |
| 671 | const char **date_string); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 672 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 673 | /* inline functions */ |
| 674 | extern void ext2fs_mark_super_dirty(ext2_filsys fs); |
| 675 | extern void ext2fs_mark_changed(ext2_filsys fs); |
| 676 | extern int ext2fs_test_changed(ext2_filsys fs); |
| 677 | extern void ext2fs_mark_valid(ext2_filsys fs); |
| 678 | extern void ext2fs_unmark_valid(ext2_filsys fs); |
| 679 | extern int ext2fs_test_valid(ext2_filsys fs); |
| 680 | extern void ext2fs_mark_ib_dirty(ext2_filsys fs); |
| 681 | extern void ext2fs_mark_bb_dirty(ext2_filsys fs); |
| 682 | extern int ext2fs_test_ib_dirty(ext2_filsys fs); |
| 683 | extern int ext2fs_test_bb_dirty(ext2_filsys fs); |
| 684 | extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk); |
| 685 | extern int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino); |
| 686 | |
| 687 | /* |
| 688 | * The actual inlined functions definitions themselves... |
| 689 | * |
| 690 | * If NO_INLINE_FUNCS is defined, then we won't try to do inline |
| 691 | * functions at all! |
| 692 | */ |
| 693 | #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) |
| 694 | #ifdef INCLUDE_INLINE_FUNCS |
| 695 | #define _INLINE_ extern |
| 696 | #else |
| 697 | #define _INLINE_ extern __inline__ |
| 698 | #endif |
| 699 | |
| 700 | /* |
| 701 | * Mark a filesystem superblock as dirty |
| 702 | */ |
| 703 | _INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs) |
| 704 | { |
| 705 | fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED; |
| 706 | } |
| 707 | |
| 708 | /* |
| 709 | * Mark a filesystem as changed |
| 710 | */ |
| 711 | _INLINE_ void ext2fs_mark_changed(ext2_filsys fs) |
| 712 | { |
| 713 | fs->flags |= EXT2_FLAG_CHANGED; |
| 714 | } |
| 715 | |
| 716 | /* |
| 717 | * Check to see if a filesystem has changed |
| 718 | */ |
| 719 | _INLINE_ int ext2fs_test_changed(ext2_filsys fs) |
| 720 | { |
| 721 | return (fs->flags & EXT2_FLAG_CHANGED); |
| 722 | } |
| 723 | |
| 724 | /* |
| 725 | * Mark a filesystem as valid |
| 726 | */ |
| 727 | _INLINE_ void ext2fs_mark_valid(ext2_filsys fs) |
| 728 | { |
| 729 | fs->flags |= EXT2_FLAG_VALID; |
| 730 | } |
| 731 | |
| 732 | /* |
| 733 | * Mark a filesystem as NOT valid |
| 734 | */ |
| 735 | _INLINE_ void ext2fs_unmark_valid(ext2_filsys fs) |
| 736 | { |
| 737 | fs->flags &= ~EXT2_FLAG_VALID; |
| 738 | } |
| 739 | |
| 740 | /* |
| 741 | * Check to see if a filesystem is valid |
| 742 | */ |
| 743 | _INLINE_ int ext2fs_test_valid(ext2_filsys fs) |
| 744 | { |
| 745 | return (fs->flags & EXT2_FLAG_VALID); |
| 746 | } |
| 747 | |
| 748 | /* |
| 749 | * Mark the inode bitmap as dirty |
| 750 | */ |
| 751 | _INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs) |
| 752 | { |
| 753 | fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED; |
| 754 | } |
| 755 | |
| 756 | /* |
| 757 | * Mark the block bitmap as dirty |
| 758 | */ |
| 759 | _INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs) |
| 760 | { |
| 761 | fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED; |
| 762 | } |
| 763 | |
| 764 | /* |
| 765 | * Check to see if a filesystem's inode bitmap is dirty |
| 766 | */ |
| 767 | _INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs) |
| 768 | { |
| 769 | return (fs->flags & EXT2_FLAG_IB_DIRTY); |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | * Check to see if a filesystem's block bitmap is dirty |
| 774 | */ |
| 775 | _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs) |
| 776 | { |
| 777 | return (fs->flags & EXT2_FLAG_BB_DIRTY); |
| 778 | } |
| 779 | |
| 780 | /* |
| 781 | * Return the group # of a block |
| 782 | */ |
| 783 | _INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk) |
| 784 | { |
| 785 | return (blk - fs->super->s_first_data_block) / |
| 786 | fs->super->s_blocks_per_group; |
| 787 | } |
| 788 | |
| 789 | /* |
| 790 | * Return the group # of an inode number |
| 791 | */ |
| 792 | _INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino) |
| 793 | { |
| 794 | return (ino - 1) / fs->super->s_inodes_per_group; |
| 795 | } |
| 796 | #undef _INLINE_ |
| 797 | #endif |
| 798 | |