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