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