?? ext2fs.h
字號:
/* vi: set sw=4 ts=4: *//* * ext2fs.h --- ext2fs * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% */#ifndef _EXT2FS_EXT2FS_H#define _EXT2FS_EXT2FS_H#define EXT2FS_ATTR(x)#ifdef __cplusplusextern "C" {#endif/* * Where the master copy of the superblock is located, and how big * superblocks are supposed to be. We define SUPERBLOCK_SIZE because * the size of the superblock structure is not necessarily trustworthy * (some versions have the padding set up so that the superblock is * 1032 bytes long). */#define SUPERBLOCK_OFFSET 1024#define SUPERBLOCK_SIZE 1024/* * The last ext2fs revision level that this version of the library is * able to support. */#define EXT2_LIB_CURRENT_REV EXT2_DYNAMIC_REV#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#include <stdio.h>#include <stdlib.h>#include "ext2_types.h"#include "ext2_fs.h"typedef __u32 ext2_ino_t;typedef __u32 blk_t;typedef __u32 dgrp_t;typedef __u32 ext2_off_t;typedef __s64 e2_blkcnt_t;typedef __u32 ext2_dirhash_t;#include "ext2_io.h"#include "ext2_err.h"typedef struct struct_ext2_filsys *ext2_filsys;struct ext2fs_struct_generic_bitmap { errcode_t magic; ext2_filsys fs; __u32 start, end; __u32 real_end; char * description; char * bitmap; errcode_t base_error_code; __u32 reserved[7];};#define EXT2FS_MARK_ERROR 0#define EXT2FS_UNMARK_ERROR 1#define EXT2FS_TEST_ERROR 2typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)/* * badblocks list definitions */typedef struct ext2_struct_u32_list *ext2_badblocks_list;typedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate;typedef struct ext2_struct_u32_list *ext2_u32_list;typedef struct ext2_struct_u32_iterate *ext2_u32_iterate;/* old */typedef struct ext2_struct_u32_list *badblocks_list;typedef struct ext2_struct_u32_iterate *badblocks_iterate;#define BADBLOCKS_FLAG_DIRTY 1/* * ext2_dblist structure and abstractions (see dblist.c) */struct ext2_db_entry { ext2_ino_t ino; blk_t blk; int blockcnt;};typedef struct ext2_struct_dblist *ext2_dblist;#define DBLIST_ABORT 1/* * ext2_fileio definitions */#define EXT2_FILE_WRITE 0x0001#define EXT2_FILE_CREATE 0x0002#define EXT2_FILE_MASK 0x00FF#define EXT2_FILE_BUF_DIRTY 0x4000#define EXT2_FILE_BUF_VALID 0x2000typedef struct ext2_file *ext2_file_t;#define EXT2_SEEK_SET 0#define EXT2_SEEK_CUR 1#define EXT2_SEEK_END 2/* * Flags for the ext2_filsys structure and for ext2fs_open() */#define EXT2_FLAG_RW 0x01#define EXT2_FLAG_CHANGED 0x02#define EXT2_FLAG_DIRTY 0x04#define EXT2_FLAG_VALID 0x08#define EXT2_FLAG_IB_DIRTY 0x10#define EXT2_FLAG_BB_DIRTY 0x20#define EXT2_FLAG_SWAP_BYTES 0x40#define EXT2_FLAG_SWAP_BYTES_READ 0x80#define EXT2_FLAG_SWAP_BYTES_WRITE 0x100#define EXT2_FLAG_MASTER_SB_ONLY 0x200#define EXT2_FLAG_FORCE 0x400#define EXT2_FLAG_SUPER_ONLY 0x800#define EXT2_FLAG_JOURNAL_DEV_OK 0x1000#define EXT2_FLAG_IMAGE_FILE 0x2000/* * Special flag in the ext2 inode i_flag field that means that this is * a new inode. (So that ext2_write_inode() can clear extra fields.) */#define EXT2_NEW_INODE_FL 0x80000000/* * Flags for mkjournal * * EXT2_MKJOURNAL_V1_SUPER Make a (deprecated) V1 journal superblock */#define EXT2_MKJOURNAL_V1_SUPER 0x0000001struct struct_ext2_filsys { errcode_t magic; io_channel io; int flags; char * device_name; struct ext2_super_block * super; unsigned int blocksize; int fragsize; dgrp_t group_desc_count; unsigned long desc_blocks; struct ext2_group_desc * group_desc; int inode_blocks_per_group; ext2fs_inode_bitmap inode_map; ext2fs_block_bitmap block_map; errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks); errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino); errcode_t (*write_bitmaps)(ext2_filsys fs); errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode); errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode); ext2_badblocks_list badblocks; ext2_dblist dblist; __u32 stride; /* for mke2fs */ struct ext2_super_block * orig_super; struct ext2_image_hdr * image_header; __u32 umask; /* * Reserved for future expansion */ __u32 reserved[8]; /* * Reserved for the use of the calling application. */ void * priv_data; /* * Inode cache */ struct ext2_inode_cache *icache; io_channel image_io;};#include "bitops.h"/* * Return flags for the block iterator functions */#define BLOCK_CHANGED 1#define BLOCK_ABORT 2#define BLOCK_ERROR 4/* * Block interate flags * * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator * function should be called on blocks where the block number is zero. * This is used by ext2fs_expand_dir() to be able to add a new block * to an inode. It can also be used for programs that want to be able * to deal with files that contain "holes". * * BLOCK_FLAG_TRAVERSE indicates that the iterator function for the * indirect, doubly indirect, etc. blocks should be called after all * of the blocks containined in the indirect blocks are processed. * This is useful if you are going to be deallocating blocks from an * inode. * * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be * called for data blocks only. * * BLOCK_FLAG_NO_LARGE is for internal use only. It informs * ext2fs_block_iterate2 that large files won't be accepted. */#define BLOCK_FLAG_APPEND 1#define BLOCK_FLAG_HOLE 1#define BLOCK_FLAG_DEPTH_TRAVERSE 2#define BLOCK_FLAG_DATA_ONLY 4#define BLOCK_FLAG_NO_LARGE 0x1000/* * Magic "block count" return values for the block iterator function. */#define BLOCK_COUNT_IND (-1)#define BLOCK_COUNT_DIND (-2)#define BLOCK_COUNT_TIND (-3)#define BLOCK_COUNT_TRANSLATOR (-4)#if 0/* * Flags for ext2fs_move_blocks */#define EXT2_BMOVE_GET_DBLIST 0x0001#define EXT2_BMOVE_DEBUG 0x0002#endif/* * Flags for directory block reading and writing functions */#define EXT2_DIRBLOCK_V2_STRUCT 0x0001/* * Return flags for the directory iterator functions */#define DIRENT_CHANGED 1#define DIRENT_ABORT 2#define DIRENT_ERROR 3/* * Directory iterator flags */#define DIRENT_FLAG_INCLUDE_EMPTY 1#define DIRENT_FLAG_INCLUDE_REMOVED 2#define DIRENT_DOT_FILE 1#define DIRENT_DOT_DOT_FILE 2#define DIRENT_OTHER_FILE 3#define DIRENT_DELETED_FILE 4/* * Inode scan definitions */typedef struct ext2_struct_inode_scan *ext2_inode_scan;/* * ext2fs_scan flags */#define EXT2_SF_CHK_BADBLOCKS 0x0001#define EXT2_SF_BAD_INODE_BLK 0x0002#define EXT2_SF_BAD_EXTRA_BYTES 0x0004#define EXT2_SF_SKIP_MISSING_ITABLE 0x0008/* * ext2fs_check_if_mounted flags */#define EXT2_MF_MOUNTED 1#define EXT2_MF_ISROOT 2#define EXT2_MF_READONLY 4#define EXT2_MF_SWAP 8#define EXT2_MF_BUSY 16/* * Ext2/linux mode flags. We define them here so that we don't need * to depend on the OS's sys/stat.h, since we may be compiling on a * non-Linux system. */#define LINUX_S_IFMT 00170000#define LINUX_S_IFSOCK 0140000#define LINUX_S_IFLNK 0120000#define LINUX_S_IFREG 0100000#define LINUX_S_IFBLK 0060000#define LINUX_S_IFDIR 0040000#define LINUX_S_IFCHR 0020000#define LINUX_S_IFIFO 0010000#define LINUX_S_ISUID 0004000#define LINUX_S_ISGID 0002000#define LINUX_S_ISVTX 0001000#define LINUX_S_IRWXU 00700#define LINUX_S_IRUSR 00400#define LINUX_S_IWUSR 00200#define LINUX_S_IXUSR 00100#define LINUX_S_IRWXG 00070#define LINUX_S_IRGRP 00040#define LINUX_S_IWGRP 00020#define LINUX_S_IXGRP 00010#define LINUX_S_IRWXO 00007#define LINUX_S_IROTH 00004#define LINUX_S_IWOTH 00002#define LINUX_S_IXOTH 00001#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)/* * ext2 size of an inode */#define EXT2_I_SIZE(i) ((i)->i_size | ((__u64) (i)->i_size_high << 32))/* * ext2_icount_t abstraction */#define EXT2_ICOUNT_OPT_INCREMENT 0x01typedef struct ext2_icount *ext2_icount_t;/* * Flags for ext2fs_bmap */#define BMAP_ALLOC 0x0001#define BMAP_SET 0x0002/* * Flags for imager.c functions */#define IMAGER_FLAG_INODEMAP 1#define IMAGER_FLAG_SPARSEWRITE 2/* * For checking structure magic numbers... */#define EXT2_CHECK_MAGIC(struct, code) \ if ((struct)->magic != (code)) return (code)/* * For ext2 compression support */#define EXT2FS_COMPRESSED_BLKADDR ((blk_t) 0xffffffff)#define HOLE_BLKADDR(_b) ((_b) == 0 || (_b) == EXT2FS_COMPRESSED_BLKADDR)/* * Features supported by this version of the library */#define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\ EXT2_FEATURE_COMPAT_IMAGIC_INODES|\ EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ EXT2_FEATURE_COMPAT_RESIZE_INODE|\ EXT2_FEATURE_COMPAT_DIR_INDEX|\ EXT2_FEATURE_COMPAT_EXT_ATTR)/* This #ifdef is temporary until compression is fully supported */#ifdef ENABLE_COMPRESSION#ifndef I_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL/* If the below warning bugs you, then have `CPPFLAGS=-DI_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL' in your environment at configure time. */ #warning "Compression support is experimental"#endif#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\ EXT2_FEATURE_INCOMPAT_COMPRESSION|\ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\ EXT2_FEATURE_INCOMPAT_META_BG|\ EXT3_FEATURE_INCOMPAT_RECOVER)#else#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\ EXT2_FEATURE_INCOMPAT_META_BG|\ EXT3_FEATURE_INCOMPAT_RECOVER)#endif#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\ EXT2_FEATURE_RO_COMPAT_LARGE_FILE)/* * function prototypes *//* alloc.c */extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode, ext2fs_inode_bitmap map, ext2_ino_t *ret);extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, ext2fs_block_bitmap map, blk_t *ret);extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish, int num, ext2fs_block_bitmap map, blk_t *ret);extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, char *block_buf, blk_t *ret);/* alloc_sb.c */extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap);/* alloc_stats.c */void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse);void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino, int inuse, int isdir);void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse);/* alloc_tables.c */extern errcode_t ext2fs_allocate_tables(ext2_filsys fs);extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap);/* badblocks.c */extern errcode_t ext2fs_u32_list_create(ext2_u32_list *ret, int size);extern errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk);extern int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk);extern int ext2fs_u32_list_test(ext2_u32_list bb, blk_t blk);extern errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb, ext2_u32_iterate *ret);extern int ext2fs_u32_list_iterate(ext2_u32_iterate iter, blk_t *blk);extern void ext2fs_u32_list_iterate_end(ext2_u32_iterate iter);extern errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest);extern int ext2fs_u32_list_equal(ext2_u32_list bb1, ext2_u32_list bb2);extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size);extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, blk_t blk);extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb, blk_t blk);extern int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -