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