📄 reiserfs_private.h
字号:
#define ih_version(ih) (__le16_to_cpu((ih)->ih_version))#define IH_KEY_OFFSET(ih) (ih_version(ih) == ITEM_VERSION_1 \ ? __le32_to_cpu((ih)->ih_key.u.v1.k_offset) \ : offset_v2_k_offset(&((ih)->ih_key.u.v2)))#define IH_KEY_ISTYPE(ih, type) (ih_version(ih) == ITEM_VERSION_1 \ ? __le32_to_cpu((ih)->ih_key.u.v1.k_uniqueness) == V1_##type \ : offset_v2_k_type(&((ih)->ih_key.u.v2)) == V2_##type)/***************************************************************************//* DISK CHILD *//***************************************************************************//* Disk child pointer: The pointer from an internal node of the tree to a node that is on disk. */struct disk_child { __u32 dc_block_number; /* Disk child's block number. */ __u16 dc_size; /* Disk child's used space. */ __u16 dc_reserved;};#define DC_SIZE (sizeof(struct disk_child))#define dc_block_number(dc_p) (__le32_to_cpu((dc_p)->dc_block_number))/* * old stat data is 32 bytes long. We are going to distinguish new one by * different size */struct stat_data_v1{ __u16 sd_mode; /* file type, permissions */ __u16 sd_nlink; /* number of hard links */ __u16 sd_uid; /* owner */ __u16 sd_gid; /* group */ __u32 sd_size; /* file size */ __u32 sd_atime; /* time of last access */ __u32 sd_mtime; /* time file was last modified */ __u32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */ union { __u32 sd_rdev; __u32 sd_blocks; /* number of blocks file uses */ } __attribute__ ((__packed__)) u; __u32 sd_first_direct_byte; /* first byte of file which is stored in a direct item: except that if it equals 1 it is a symlink and if it equals ~(__u32)0 there is no direct item. The existence of this field really grates on me. Let's replace it with a macro based on sd_size and our tail suppression policy. Someday. -Hans */} __attribute__ ((__packed__));#define stat_data_v1(ih) (ih_version(ih) == ITEM_VERSION_1)#define sd_v1_mode(sdp) ((sdp)->sd_mode)#define sd_v1_nlink(sdp) (__le16_to_cpu((sdp)->sd_nlink))#define sd_v1_uid(sdp) (__le16_to_cpu((sdp)->sd_uid))#define sd_v1_gid(sdp) (__le16_to_cpu((sdp)->sd_gid))#define sd_v1_size(sdp) (__le32_to_cpu((sdp)->sd_size))#define sd_v1_mtime(sdp) (__le32_to_cpu((sdp)->sd_mtime))/* Stat Data on disk (reiserfs version of UFS disk inode minus the address blocks) */struct stat_data { __u16 sd_mode; /* file type, permissions */ __u16 sd_attrs; /* persistent inode flags */ __u32 sd_nlink; /* number of hard links */ __u64 sd_size; /* file size */ __u32 sd_uid; /* owner */ __u32 sd_gid; /* group */ __u32 sd_atime; /* time of last access */ __u32 sd_mtime; /* time file was last modified */ __u32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */ __u32 sd_blocks; union { __u32 sd_rdev; __u32 sd_generation; /*__u32 sd_first_direct_byte; */ /* first byte of file which is stored in a direct item: except that if it equals 1 it is a symlink and if it equals ~(__u32)0 there is no direct item. The existence of this field really grates on me. Let's replace it with a macro based on sd_size and our tail suppression policy? */ } __attribute__ ((__packed__)) u;} __attribute__ ((__packed__));#define stat_data_v2(ih) (ih_version(ih) == ITEM_VERSION_2)#define sd_v2_mode(sdp) (__le16_to_cpu((sdp)->sd_mode))#define sd_v2_nlink(sdp) (__le32_to_cpu((sdp)->sd_nlink))#define sd_v2_size(sdp) (__le64_to_cpu((sdp)->sd_size))#define sd_v2_uid(sdp) (__le32_to_cpu((sdp)->sd_uid))#define sd_v2_gid(sdp) (__le32_to_cpu((sdp)->sd_gid))#define sd_v2_mtime(sdp) (__le32_to_cpu((sdp)->sd_mtime))#define sd_mode(sdp) (__le16_to_cpu((sdp)->sd_mode))#define sd_size(sdp) (__le32_to_cpu((sdp)->sd_size))#define sd_size_hi(sdp) (__le32_to_cpu((sdp)->sd_size_hi))struct reiserfs_de_head{ __u32 deh_offset; /* third component of the directory entry key */ __u32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced by directory entry */ __u32 deh_objectid;/* objectid of the object, that is referenced by directory entry */ __u16 deh_location;/* offset of name in the whole item */ __u16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether entry is hidden (unlinked) */};#define DEH_SIZE (sizeof (struct reiserfs_de_head))#define deh_offset(p_deh) (__le32_to_cpu((p_deh)->deh_offset))#define deh_dir_id(p_deh) (__le32_to_cpu((p_deh)->deh_dir_id))#define deh_objectid(p_deh) (__le32_to_cpu((p_deh)->deh_objectid))#define deh_location(p_deh) (__le16_to_cpu((p_deh)->deh_location))#define deh_state(p_deh) (__le16_to_cpu((p_deh)->deh_state))#define DEH_Statdata (1 << 0) /* not used now */#define DEH_Visible (1 << 2)#define SD_OFFSET 0#define SD_UNIQUENESS 0#define DOT_OFFSET 1#define DOT_DOT_OFFSET 2#define DIRENTRY_UNIQUENESS 500#define V1_TYPE_STAT_DATA 0x0#define V1_TYPE_DIRECT 0xffffffff#define V1_TYPE_INDIRECT 0xfffffffe#define V1_TYPE_DIRECTORY_MAX 0xfffffffd#define V2_TYPE_STAT_DATA 0#define V2_TYPE_INDIRECT 1#define V2_TYPE_DIRECT 2#define V2_TYPE_DIRENTRY 3#define REISERFS_ROOT_OBJECTID 2#define REISERFS_ROOT_PARENT_OBJECTID 1#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)/* the spot for the super in versions 3.5 - 3.5.11 (inclusive) */#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)#define REISERFS_OLD_BLOCKSIZE 4096#define S_ISREG(mode) (((mode) & 0170000) == 0100000)#define S_ISDIR(mode) (((mode) & 0170000) == 0040000)#define S_ISLNK(mode) (((mode) & 0170000) == 0120000)#define PATH_MAX 1024 /* include/linux/limits.h */#define MAX_LINK_COUNT 5 /* number of symbolic links to follow *//* The size of the node cache */#define FSYSREISER_CACHE_SIZE 24*1024#define FSYSREISER_MIN_BLOCKSIZE SECTOR_SIZE#define FSYSREISER_MAX_BLOCKSIZE FSYSREISER_CACHE_SIZE / 3/* Info about currently opened file */struct fsys_reiser_fileinfo{ __u32 k_dir_id; __u32 k_objectid;};/* In memory info about the currently mounted filesystem */struct fsys_reiser_info{ /* The last read item head */ struct item_head *current_ih; /* The last read item */ char *current_item; /* The information for the currently opened file */ struct fsys_reiser_fileinfo fileinfo; /* The start of the journal */ __u32 journal_block; /* The size of the journal */ __u32 journal_block_count; /* The first valid descriptor block in journal (relative to journal_block) */ __u32 journal_first_desc; /* The ReiserFS version. */ __u16 version; /* The current depth of the reiser tree. */ __u16 tree_depth; /* SECTOR_SIZE << blocksize_shift == blocksize. */ __u8 blocksize_shift; /* 1 << full_blocksize_shift == blocksize. */ __u8 fullblocksize_shift; /* The reiserfs block size (must be a power of 2) */ __u16 blocksize; /* The number of cached tree nodes */ __u16 cached_slots; /* The number of valid transactions in journal */ __u16 journal_transactions; unsigned int blocks[MAX_HEIGHT]; unsigned int next_key_nr[MAX_HEIGHT];};/* The cached s+tree blocks in FSYS_BUF, see below * for a more detailed description. */#define ROOT ((char *) ((int) FSYS_BUF))#define CACHE(i) (ROOT + ((i) << INFO->fullblocksize_shift))#define LEAF CACHE (DISK_LEAF_NODE_LEVEL)#define BLOCKHEAD(cache) ((struct block_head *) cache)#define ITEMHEAD ((struct item_head *) ((int) LEAF + BLKH_SIZE))#define KEY(cache) ((struct key *) ((int) cache + BLKH_SIZE))#define DC(cache) ((struct disk_child *) \ ((int) cache + BLKH_SIZE + KEY_SIZE * nr_item))/* The fsys_reiser_info block. */#define INFO \ ((struct fsys_reiser_info *) ((int) FSYS_BUF + FSYSREISER_CACHE_SIZE))/* * The journal cache. For each transaction it contains the number of * blocks followed by the real block numbers of this transaction. * * If the block numbers of some transaction won't fit in this space, * this list is stopped with a 0xffffffff marker and the remaining * uncommitted transactions aren't cached. */#define JOURNAL_START ((__u32 *) (INFO + 1))#define JOURNAL_END ((__u32 *) (FSYS_BUF + FSYS_BUFLEN))static __inline__ unsigned longlog2 (unsigned long word){#ifdef __I386__ __asm__ ("bsfl %1,%0" : "=r" (word) : "r" (word)); return word;#else int i; for(i=0; i<(8*sizeof(word)); i++) if ((1<<i) & word) return i; return 0;#endif}static __inline__ intis_power_of_two (unsigned long word){ return (word & -word) == word;}extern const char *bb_mode_string(int mode);extern int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -