4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
13 * Non-GNU C compilers won't necessarily understand inline
16 #define NO_INLINE_FUNCS
20 * Where the master copy of the superblock is located, and how big
21 * superblocks are supposed to be. We define SUPERBLOCK_SIZE because
22 * the size of the superblock structure is not necessarily trustworthy
23 * (some versions have the padding set up so that the superblock is
26 #define SUPERBLOCK_OFFSET 1024
27 #define SUPERBLOCK_SIZE 1024
30 * The last ext2fs revision level that this version of the library is
33 #define EXT2_LIB_CURRENT_REV 0
35 #include <sys/types.h>
36 #include <linux/types.h>
39 typedef unsigned int dgrp_t;
41 #include "et/com_err.h"
42 #include "ext2fs/io.h"
43 #include "ext2fs/ext2_err.h"
45 typedef struct struct_ext2_filsys *ext2_filsys;
47 struct ext2fs_struct_generic_bitmap {
54 errcode_t base_error_code;
58 #define EXT2FS_MARK_ERROR 0
59 #define EXT2FS_UNMARK_ERROR 1
60 #define EXT2FS_TEST_ERROR 2
62 typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
63 typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
64 typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
66 #ifdef EXT2_DYNAMIC_REV
67 #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
69 #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO
70 #define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode)
74 * badblocks list definitions
77 typedef struct ext2_struct_badblocks_list *ext2_badblocks_list;
78 typedef struct ext2_struct_badblocks_iterate *ext2_badblocks_iterate;
81 typedef struct ext2_struct_badblocks_list *badblocks_list;
82 typedef struct ext2_struct_badblocks_iterate *badblocks_iterate;
84 #define BADBLOCKS_FLAG_DIRTY 1
87 * ext2_dblist structure and abstractions (see dblist.c)
89 struct ext2_db_entry {
95 typedef struct ext2_struct_dblist *ext2_dblist;
97 #define DBLIST_ABORT 1
100 * Flags for the ext2_filsys structure
103 #define EXT2_FLAG_RW 0x01
104 #define EXT2_FLAG_CHANGED 0x02
105 #define EXT2_FLAG_DIRTY 0x04
106 #define EXT2_FLAG_VALID 0x08
107 #define EXT2_FLAG_IB_DIRTY 0x10
108 #define EXT2_FLAG_BB_DIRTY 0x20
109 #define EXT2_FLAG_SWAP_BYTES 0x40
110 #define EXT2_FLAG_SWAP_BYTES_READ 0x80
111 #define EXT2_FLAG_SWAP_BYTES_WRITE 0x100
112 #define EXT2_FLAG_MASTER_SB_ONLY 0x200
113 #define EXT2_FLAG_FORCE 0x400
116 * Special flag in the ext2 inode i_flag field that means that this is
117 * a new inode. (So that ext2_write_inode() can clear extra fields.)
119 #define EXT2_NEW_INODE_FL 0x80000000
121 struct struct_ext2_filsys {
126 struct ext2_super_block * super;
129 unsigned long group_desc_count;
130 unsigned long desc_blocks;
131 struct ext2_group_desc * group_desc;
132 int inode_blocks_per_group;
133 ext2fs_inode_bitmap inode_map;
134 ext2fs_block_bitmap block_map;
135 errcode_t (*get_blocks)(ext2_filsys fs, ino_t ino, blk_t *blocks);
136 errcode_t (*check_directory)(ext2_filsys fs, ino_t ino);
137 errcode_t (*write_bitmaps)(ext2_filsys fs);
138 errcode_t (*read_inode)(ext2_filsys fs, ino_t ino,
139 struct ext2_inode *inode);
140 errcode_t (*write_inode)(ext2_filsys fs, ino_t ino,
141 struct ext2_inode *inode);
142 badblocks_list badblocks;
144 __u32 stride; /* for mke2fs */
146 * Reserved for future expansion
151 * Reserved for the use of the calling application.
158 struct ext2_inode_cache *icache;
161 #include "ext2fs/bitops.h"
164 * Return flags for the block iterator functions
166 #define BLOCK_CHANGED 1
167 #define BLOCK_ABORT 2
168 #define BLOCK_ERROR 4
171 * Block interate flags
173 * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator
174 * function should be called on blocks where the block number is zero.
175 * This is used by ext2fs_expand_dir() to be able to add a new block
176 * to an inode. It can also be used for programs that want to be able
177 * to deal with files that contain "holes".
179 * BLOCK_FLAG_TRAVERSE indicates that the iterator function for the
180 * indirect, doubly indirect, etc. blocks should be called after all
181 * of the blocks containined in the indirect blocks are processed.
182 * This is useful if you are going to be deallocating blocks from an
185 * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be
186 * called for data blocks only.
188 #define BLOCK_FLAG_APPEND 1
189 #define BLOCK_FLAG_HOLE 1
190 #define BLOCK_FLAG_DEPTH_TRAVERSE 2
191 #define BLOCK_FLAG_DATA_ONLY 4
194 * Magic "block count" return values for the block iterator function.
196 #define BLOCK_COUNT_IND (-1)
197 #define BLOCK_COUNT_DIND (-2)
198 #define BLOCK_COUNT_TIND (-3)
199 #define BLOCK_COUNT_TRANSLATOR (-4)
202 * Return flags for the directory iterator functions
204 #define DIRENT_CHANGED 1
205 #define DIRENT_ABORT 2
206 #define DIRENT_ERROR 3
209 * Directory iterator flags
212 #define DIRENT_FLAG_INCLUDE_EMPTY 1
215 #define DIRENT_DOT_FILE 1
216 #define DIRENT_DOT_DOT_FILE 2
217 #define DIRENT_OTHER_FILE 3
220 * Inode scan definitions
222 typedef struct ext2_struct_inode_scan *ext2_inode_scan;
227 #define EXT2_SF_CHK_BADBLOCKS 0x0001
228 #define EXT2_SF_BAD_INODE_BLK 0x0002
229 #define EXT2_SF_BAD_EXTRA_BYTES 0x0004
230 #define EXT2_SF_SKIP_MISSING_ITABLE 0x0008
233 * ext2fs_check_if_mounted flags
235 #define EXT2_MF_MOUNTED 1
236 #define EXT2_MF_ISROOT 2
237 #define EXT2_MF_READONLY 4
240 * Ext2/linux mode flags. We define them here so that we don't need
241 * to depend on the OS's sys/stat.h, since we may be compiling on a
244 #define LINUX_S_IFMT 00170000
245 #define LINUX_S_IFSOCK 0140000
246 #define LINUX_S_IFLNK 0120000
247 #define LINUX_S_IFREG 0100000
248 #define LINUX_S_IFBLK 0060000
249 #define LINUX_S_IFDIR 0040000
250 #define LINUX_S_IFCHR 0020000
251 #define LINUX_S_IFIFO 0010000
252 #define LINUX_S_ISUID 0004000
253 #define LINUX_S_ISGID 0002000
254 #define LINUX_S_ISVTX 0001000
256 #define LINUX_S_IRWXU 00700
257 #define LINUX_S_IRUSR 00400
258 #define LINUX_S_IWUSR 00200
259 #define LINUX_S_IXUSR 00100
261 #define LINUX_S_IRWXG 00070
262 #define LINUX_S_IRGRP 00040
263 #define LINUX_S_IWGRP 00020
264 #define LINUX_S_IXGRP 00010
266 #define LINUX_S_IRWXO 00007
267 #define LINUX_S_IROTH 00004
268 #define LINUX_S_IWOTH 00002
269 #define LINUX_S_IXOTH 00001
271 #define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
272 #define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
273 #define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
274 #define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
275 #define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
276 #define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
277 #define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
280 * ext2_icount_t abstraction
282 #define EXT2_ICOUNT_OPT_INCREMENT 0x01
284 typedef struct ext2_icount *ext2_icount_t;
287 * For checking structure magic numbers...
290 #define EXT2_CHECK_MAGIC(struct, code) \
291 if ((struct)->magic != (code)) return (code)
295 * The ext2fs library private definition of the ext2 superblock, so we
296 * don't have to depend on the kernel's definition of the superblock,
297 * which might not have the latest features.
300 __u32 s_inodes_count; /* Inodes count */
301 __u32 s_blocks_count; /* Blocks count */
302 __u32 s_r_blocks_count; /* Reserved blocks count */
303 __u32 s_free_blocks_count; /* Free blocks count */
304 __u32 s_free_inodes_count; /* Free inodes count */
305 __u32 s_first_data_block; /* First Data Block */
306 __u32 s_log_block_size; /* Block size */
307 __s32 s_log_frag_size; /* Fragment size */
308 __u32 s_blocks_per_group; /* # Blocks per group */
309 __u32 s_frags_per_group; /* # Fragments per group */
310 __u32 s_inodes_per_group; /* # Inodes per group */
311 __u32 s_mtime; /* Mount time */
312 __u32 s_wtime; /* Write time */
313 __u16 s_mnt_count; /* Mount count */
314 __s16 s_max_mnt_count; /* Maximal mount count */
315 __u16 s_magic; /* Magic signature */
316 __u16 s_state; /* File system state */
317 __u16 s_errors; /* Behaviour when detecting errors */
318 __u16 s_minor_rev_level; /* minor revision level */
319 __u32 s_lastcheck; /* time of last check */
320 __u32 s_checkinterval; /* max. time between checks */
321 __u32 s_creator_os; /* OS */
322 __u32 s_rev_level; /* Revision level */
323 __u16 s_def_resuid; /* Default uid for reserved blocks */
324 __u16 s_def_resgid; /* Default gid for reserved blocks */
326 * These fields are for EXT2_DYNAMIC_REV superblocks only.
328 * Note: the difference between the compatible feature set and
329 * the incompatible feature set is that if there is a bit set
330 * in the incompatible feature set that the kernel doesn't
331 * know about, it should refuse to mount the filesystem.
333 * e2fsck's requirements are more strict; if it doesn't know
334 * about a feature in either the compatible or incompatible
335 * feature set, it must abort and not try to meddle with
336 * things it doesn't understand...
338 __u32 s_first_ino; /* First non-reserved inode */
339 __u16 s_inode_size; /* size of inode structure */
340 __u16 s_block_group_nr; /* block group # of this superblock */
341 __u32 s_feature_compat; /* compatible feature set */
342 __u32 s_feature_incompat; /* incompatible feature set */
343 __u32 s_feature_ro_compat; /* readonly-compatible feature set */
344 __u8 s_uuid[16]; /* 128-bit uuid for volume */
345 char s_volume_name[16]; /* volume name */
346 char s_last_mounted[64]; /* directory where last mounted */
347 __u32 s_reserved[206]; /* Padding to the end of the block */
351 * Feature set definitions (that might not be in ext2_fs.h
352 * (was EXT2_COMPAT_SPARSE_SUPER)
354 #ifndef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
355 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
358 #define EXT2_LIB_FEATURE_COMPAT_SUPP 0
359 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP 0
360 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
363 * function prototypes
367 extern errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode,
368 ext2fs_inode_bitmap map, ino_t *ret);
369 extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
370 ext2fs_block_bitmap map, blk_t *ret);
371 extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start,
372 blk_t finish, int num,
373 ext2fs_block_bitmap map,
376 /* allocate_tables.c */
377 errcode_t ext2fs_allocate_tables(ext2_filsys fs);
380 extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret,
382 extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb,
384 extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb,
387 ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb,
388 ext2_badblocks_iterate *ret);
389 extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter,
391 extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter);
392 extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src,
393 ext2_badblocks_list *dest);
396 extern errcode_t badblocks_list_create(badblocks_list *ret, int size);
397 extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk);
398 extern int badblocks_list_test(badblocks_list bb, blk_t blk);
399 extern errcode_t badblocks_list_iterate_begin(badblocks_list bb,
400 badblocks_iterate *ret);
401 extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk);
402 extern void badblocks_list_iterate_end(badblocks_iterate iter);
403 extern void badblocks_list_free(badblocks_list bb);
406 extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs,
407 ext2_badblocks_list bb_list);
410 extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs);
411 extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs);
412 extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs);
413 extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
414 extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
418 ext2fs_generic_bitmap *ret);
419 extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
421 ext2fs_block_bitmap *ret);
422 extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
424 ext2fs_inode_bitmap *ret);
425 extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
426 ino_t end, ino_t *oend);
427 extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
428 blk_t end, blk_t *oend);
429 extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap);
430 extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap);
431 extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs);
432 extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs);
435 extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
439 int (*func)(ext2_filsys fs,
445 errcode_t ext2fs_block_iterate2(ext2_filsys fs,
449 int (*func)(ext2_filsys fs,
458 extern errcode_t ext2fs_check_desc(ext2_filsys fs);
461 extern errcode_t ext2fs_close(ext2_filsys fs);
462 extern errcode_t ext2fs_flush(ext2_filsys fs);
463 extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block);
466 extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
467 ext2fs_block_bitmap bm2);
468 extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
469 ext2fs_inode_bitmap bm2);
473 extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs);
474 extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
475 extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino,
476 blk_t blk, int blockcnt);
477 extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
478 int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
481 extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino,
482 blk_t blk, int blockcnt);
483 extern errcode_t ext2fs_copy_dblist(ext2_dblist src,
488 ext2fs_dblist_dir_iterate(ext2_dblist dblist,
491 int (*func)(ino_t dir,
493 struct ext2_dir_entry *dirent,
501 extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
503 extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
507 extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
511 int (*func)(struct ext2_dir_entry *dirent,
517 /* private to library */
518 extern int ext2fs_process_dir_block(ext2_filsys fs,
524 extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest);
527 extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir);
530 extern void ext2fs_free(ext2_filsys fs);
531 extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap);
532 extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap);
533 extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap);
534 extern void ext2fs_free_dblist(ext2_dblist dblist);
535 extern void ext2fs_badblocks_list_free(badblocks_list bb);
538 extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
542 extern errcode_t ext2fs_initialize(const char *name, int flags,
543 struct ext2_super_block *param,
544 io_manager manager, ext2_filsys *ret_fs);
547 extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
548 ext2_inode_scan *ret_scan);
549 extern void ext2fs_close_inode_scan(ext2_inode_scan scan);
550 extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino,
551 struct ext2_inode *inode);
552 extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
554 extern void ext2fs_set_inode_callback
555 (ext2_inode_scan scan,
556 errcode_t (*done_group)(ext2_filsys fs,
557 ext2_inode_scan scan,
560 void *done_group_data);
561 extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags,
563 extern errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino,
564 struct ext2_inode * inode);
565 extern errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino,
566 struct ext2_inode * inode);
567 extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
568 extern errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino);
571 extern void ext2fs_free_icount(ext2_icount_t icount);
572 extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, int size,
573 ext2_icount_t hint, ext2_icount_t *ret);
574 extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, int size,
576 extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ino_t ino,
578 extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ino_t ino,
580 extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ino_t ino,
582 extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ino_t ino,
584 extern ino_t ext2fs_get_icount_size(ext2_icount_t icount);
585 errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *);
588 extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags);
591 extern errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name,
592 int namelen, char *buf, ino_t *inode);
593 extern errcode_t ext2fs_namei(ext2_filsys fs, ino_t root, ino_t cwd,
594 const char *name, ino_t *inode);
595 errcode_t ext2fs_namei_follow(ext2_filsys fs, ino_t root, ino_t cwd,
596 const char *name, ino_t *inode);
597 extern errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd,
598 ino_t inode, ino_t *res_inode);
601 int ext2fs_native_flag(void);
604 extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino,
605 ino_t parent_ino, char **block);
608 extern errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum,
612 extern errcode_t ext2fs_open(const char *name, int flags, int superblock,
613 int block_size, io_manager manager,
614 ext2_filsys *ret_fs);
617 extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino,
621 errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name,
622 ino_t ino, int flags);
623 errcode_t ext2fs_unlink(ext2_filsys fs, ino_t dir, const char *name,
624 ino_t ino, int flags);
627 extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
628 ext2_badblocks_list *bb_list);
631 extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
632 ext2_badblocks_list *bb_list,
633 void (*invalid)(ext2_filsys fs,
637 extern errcode_t ext2fs_resize_generic_bitmap(__u32 new_end,
639 ext2fs_generic_bitmap bmap);
640 extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
641 ext2fs_inode_bitmap bmap);
642 extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
643 ext2fs_block_bitmap bmap);
644 extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
645 ext2fs_generic_bitmap *dest);
648 extern void ext2fs_swap_super(struct ext2_super_block * super);
649 extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp);
650 extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
651 struct ext2_inode *f, int hostorder);
654 extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
657 extern int ext2fs_parse_version_string(const char *ver_string);
658 extern int ext2fs_get_library_version(const char **ver_string,
659 const char **date_string);
661 /* inline functions */
662 extern void ext2fs_mark_super_dirty(ext2_filsys fs);
663 extern void ext2fs_mark_changed(ext2_filsys fs);
664 extern int ext2fs_test_changed(ext2_filsys fs);
665 extern void ext2fs_mark_valid(ext2_filsys fs);
666 extern void ext2fs_unmark_valid(ext2_filsys fs);
667 extern int ext2fs_test_valid(ext2_filsys fs);
668 extern void ext2fs_mark_ib_dirty(ext2_filsys fs);
669 extern void ext2fs_mark_bb_dirty(ext2_filsys fs);
670 extern int ext2fs_test_ib_dirty(ext2_filsys fs);
671 extern int ext2fs_test_bb_dirty(ext2_filsys fs);
672 extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
673 extern int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino);
676 * The actual inlined functions definitions themselves...
678 * If NO_INLINE_FUNCS is defined, then we won't try to do inline
681 #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
682 #ifdef INCLUDE_INLINE_FUNCS
683 #define _INLINE_ extern
685 #define _INLINE_ extern __inline__
689 * Mark a filesystem superblock as dirty
691 _INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs)
693 fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED;
697 * Mark a filesystem as changed
699 _INLINE_ void ext2fs_mark_changed(ext2_filsys fs)
701 fs->flags |= EXT2_FLAG_CHANGED;
705 * Check to see if a filesystem has changed
707 _INLINE_ int ext2fs_test_changed(ext2_filsys fs)
709 return (fs->flags & EXT2_FLAG_CHANGED);
713 * Mark a filesystem as valid
715 _INLINE_ void ext2fs_mark_valid(ext2_filsys fs)
717 fs->flags |= EXT2_FLAG_VALID;
721 * Mark a filesystem as NOT valid
723 _INLINE_ void ext2fs_unmark_valid(ext2_filsys fs)
725 fs->flags &= ~EXT2_FLAG_VALID;
729 * Check to see if a filesystem is valid
731 _INLINE_ int ext2fs_test_valid(ext2_filsys fs)
733 return (fs->flags & EXT2_FLAG_VALID);
737 * Mark the inode bitmap as dirty
739 _INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs)
741 fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED;
745 * Mark the block bitmap as dirty
747 _INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs)
749 fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED;
753 * Check to see if a filesystem's inode bitmap is dirty
755 _INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs)
757 return (fs->flags & EXT2_FLAG_IB_DIRTY);
761 * Check to see if a filesystem's block bitmap is dirty
763 _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
765 return (fs->flags & EXT2_FLAG_BB_DIRTY);
769 * Return the group # of a block
771 _INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
773 return (blk - fs->super->s_first_data_block) /
774 fs->super->s_blocks_per_group;
778 * Return the group # of an inode number
780 _INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino)
782 return (ino - 1) / fs->super->s_inodes_per_group;