⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reiserfs_fs.h

📁 reiserfsprogs-3.6.19.tar.gz 源码 给有需要的人!
💻 H
📖 第 1 页 / 共 5 页
字号:
} __attribute__ ((__packed__));/* size of item header     */#define IH_SIZE (sizeof(struct item_head))/* set/get fields of item head on disk with these defines */#define get_ih_entry_count(ih)		get_le16 (ih, u.ih2_entry_count)#define set_ih_entry_count(ih,val)	set_le16 (ih, u.ih2_entry_count, val)#define get_ih_free_space(ih)		get_le16 (ih, u.ih2_free_space)#define set_ih_free_space(ih,val)	set_le16 (ih, u.ih2_free_space, 0)#define get_ih_item_len(ih)		get_le16 (ih, ih2_item_len)#define set_ih_item_len(ih,val)		set_le16 (ih, ih2_item_len, val)#define get_ih_location(ih)		get_le16 (ih, ih2_item_location)#define set_ih_location(ih,val)		set_le16 (ih, ih2_item_location, val)__u16 get_ih_flags (const struct item_head * ih);__u16 get_ih_key_format (const struct item_head * ih);void set_ih_flags (struct item_head * ih, __u16 val);void set_ih_key_format (struct item_head * ih, __u16 val);/*#define get_ih_key_format(ih)		get_le16 (ih, ih2_format.key_format)#define set_ih_key_format(ih,val)	set_le16 (ih, ih2_format.key_format, val)#define get_ih_flags(ih)		get_le16 (ih, ih2_format.flags)#define set_ih_flags(ih,val)		set_le16 (ih, ih2_format.flags, val)*/#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \    ( ! not_of_one_file(p_s_ih, p_s_key) && \          I_OFF_BYTE_IN_ITEM(p_s_ih, get_offset (p_s_key), n_blocksize) )#define IH_Unreachable 0#define IH_Was_Tail    1#define IH_Checked     2#define IH_Writable    3/* Bad item flag is set temporary by recover_leaf *//*extern_inline __u16 mark_ih_bad( struct item_head *ih ){    set_ih_flags(ih, get_ih_flags(ih) | IH_Bad );    return get_ih_flags(ih);}extern_inline __u16 ih_bad( struct item_head *ih ){    __u16 tmp = get_ih_flags(ih);    return test_bit(IH_Bad, &tmp );}extern_inline __u16 unmark_item_bad( struct item_head *ih ){    __u16 tmp = get_ih_flags(ih);    clear_bit( IH_Bad, &tmp );    set_ih_flags( ih, tmp );    return tmp;}*//* Unreachable bit is set on tree rebuilding and is cleared in semantic pass */#define clean_ih_flags(ih) set_ih_flags (ih, 0)#define ih_reachable(ih)        (!(get_ih_flags (ih) & (1 << IH_Unreachable)))#define mark_ih_reachable(ih)   set_ih_flags (ih, get_ih_flags (ih) & ~(1 << IH_Unreachable))#define mark_ih_unreachable(ih) set_ih_flags (ih, get_ih_flags (ih) | (1 << IH_Unreachable))#define ih_was_tail(ih)         (get_ih_flags (ih) & (1 << IH_Was_Tail))#define mark_ih_was_tail(ih)    set_ih_flags (ih, get_ih_flags (ih) | (1 << IH_Was_Tail))#define mark_ih_become_tail(ih) set_ih_flags (ih, get_ih_flags (ih) & ~(1 << IH_Was_Tail))#define ih_checked(ih)          (get_ih_flags (ih) & (1 << IH_Checked))#define mark_ih_checked(ih)     set_ih_flags (ih, get_ih_flags (ih) | (1 << IH_Checked))#define clear_ih_checked(ih)    set_ih_flags (ih, get_ih_flags (ih) & ~(1 << IH_Checked))#define ih_writable(ih)         (get_ih_flags (ih) & (1 << IH_Writable))#define mark_ih_writable(ih)    set_ih_flags (ih, get_ih_flags (ih) | (1 << IH_Writable))#define clear_ih_writable(ih)   set_ih_flags (ih, get_ih_flags (ih) & ~(1 << IH_Writable))/* maximal length of item */#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)#define MIN_ITEM_LEN 1/* object identifier for root dir */#define REISERFS_ROOT_OBJECTID 2#define REISERFS_ROOT_PARENT_OBJECTID 1/*  * Picture represents a leaf of internal tree *  ______________________________________________________ * |      |  Array of     |                   |           | * |Block |  Object-Item  |      F r e e      |  Objects- | * | head |  Headers      |     S p a c e     |   Items   | * |______|_______________|___________________|___________| *//* Header of a disk block.  More precisely, header of a formatted leaf   or internal node, and not the header of an unformatted node. */struct block_head {           __u16 blk2_level;        /* Level of a block in the tree. */    __u16 blk2_nr_item;      /* Number of keys/items in a block. */    __u16 blk2_free_space;   /* Block free space in bytes. */    __u16 blk_reserved;    __u32 reserved [4];};#define BLKH_SIZE (sizeof(struct block_head))/* set/get fields of block head on disk with these defines */#define get_blkh_level(blkh)		get_le16 (blkh, blk2_level)#define set_blkh_level(blkh,val)	set_le16 (blkh, blk2_level, val)#define get_blkh_nr_items(blkh)		get_le16 (blkh, blk2_nr_item)#define set_blkh_nr_items(blkh,val)	set_le16 (blkh, blk2_nr_item, val)#define get_blkh_free_space(blkh)	get_le16 (blkh, blk2_free_space)#define set_blkh_free_space(blkh,val)	set_le16 (blkh, blk2_free_space, val)/* * values for blk_type field */#define FREE_LEVEL        0 /* Node of this level is out of the tree. */#define DISK_LEAF_NODE_LEVEL  1 /* Leaf node level.                       */#define is_leaf_block_head(buf) (get_blkh_level ((struct block_head *)(buf)) == DISK_LEAF_NODE_LEVEL)#define is_internal_block_head(buf) \((get_blkh_level (((struct block_head *)(buf))) > DISK_LEAF_NODE_LEVEL) &&\ (get_blkh_level (((struct block_head *)(buf))) <= MAX_HEIGHT))/* Given the buffer head of a formatted node, resolve to the block head of that node. */#define B_BLK_HEAD(p_s_bh)  ((struct block_head *)((p_s_bh)->b_data))#define B_NR_ITEMS(bh)		get_blkh_nr_items (B_BLK_HEAD(bh))#define B_LEVEL(bh)		get_blkh_level (B_BLK_HEAD(bh))#define B_FREE_SPACE(bh)	get_blkh_free_space (B_BLK_HEAD(bh))#define is_leaf_node(bh) is_leaf_block_head ((bh)->b_data)#define is_internal_node(bh) is_internal_block_head ((bh)->b_data)/***************************************************************************//*                             STAT DATA                                   *//***************************************************************************//* Stat Data on disk (reiserfs version of UFS disk inode minus the address blocks) *//* The sense of adding union to stat data is to keep a value of real number of   blocks used by file.  The necessity of adding such information is caused by   existing of files with holes.  Reiserfs should keep number of used blocks   for file, but not calculate it from file size (that is not correct for   holed files). Thus we have to add additional information to stat data.   When we have a device special file, there is no need to get number of used   blocks for them, and, accordingly, we doesn't need to keep major and minor   numbers for regular files, which might have holes. So this field is being   overloaded.  */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 MAX_KEY_OFFSET 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 SD_V1_SIZE (sizeof(struct stat_data_v1))/* this is used to check sd_size of stat data v1 */#define MAX_FILE_SIZE_V1 0x7fffffff// sd_first_direct_byte is set to this when there are no direct items in a// file#define NO_BYTES_IN_DIRECT_ITEM 0xffffffff/* 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;    __u32 sd_nlink;	/* 32 bit nlink! */    __u64 sd_size;	/* 64 bit size!*/    __u32 sd_uid;	/* 32 bit uid! */    __u32 sd_gid;	/* 32 bit gid! */    __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__));//// this is 44 bytes long//#define SD_SIZE (sizeof(struct stat_data))// there are two ways: to check length of item or ih_format field// (for old stat data it is set to 0 (KEY_FORMAT_1))#define stat_data_v1(ih) (get_ih_key_format (ih) == KEY_FORMAT_1)/* this is used to check sd_size of stat data v2: max offset which can   be reached with a key of format 2 is 60 bits */#define MAX_FILE_SIZE_V2 0xfffffffffffffffLL/***************************************************************************//*                      DIRECTORY STRUCTURE                                *//***************************************************************************//*    Picture represents the structure of directory items   ________________________________________________   |  Array of     |   |     |        |       |   |   | directory     |N-1| N-2 | ....   |   1st |0th|   | entry headers |   |     |        |       |   |   |_______________|___|_____|________|_______|___|                    <----   directory entries         ------> First directory item has k_offset component 1. We store "." and ".." in one item, always, we never split "." and ".." into differing items.  This makes, among other things, the code for removing directories simpler. */#define SD_OFFSET  0#define DOT_OFFSET 1#define DOT_DOT_OFFSET 2/* Each directory entry has its header. This header has deh_dir_id and   deh_objectid fields, those are key of object, entry points to *//* NOT IMPLEMENTED:      Directory will someday contain stat data of object */struct reiserfs_de_head{    __u32 deh2_offset;  /* third component of the directory entry key */    __u32 deh2_dir_id;  /* objectid of the parent directory of the object,			   that is referenced by directory entry */    __u32 deh2_objectid;/* objectid of the object, that is referenced by			   directory entry */    __u16 deh2_location;/* offset of name in the whole item */    __u16 deh2_state;   /* whether 1) entry contains stat data (for future),			   and 2) whether entry is hidden (unlinked) */} __attribute__ ((__packed__));#define DEH_SIZE sizeof(struct reiserfs_de_head)/* set/get fields of dir entry head these defines */#define get_deh_offset(deh)	get_le32 (deh, deh2_offset)#define set_deh_offset(deh,val)	set_le32 (deh, deh2_offset, val)#define get_deh_dirid(deh)	get_le32 (deh, deh2_dir_id)#define set_deh_dirid(deh,val)	set_le32 (deh, deh2_dir_id, val)#define get_deh_objectid(deh)		get_le32 (deh, deh2_objectid)#define set_deh_objectid(deh,val)	set_le32 (deh, deh2_objectid, val)#define get_deh_location(deh)		get_le16 (deh, deh2_location)#define set_deh_location(deh,val)	set_le16 (deh, deh2_location, val)#define get_deh_state(deh)	get_le16 (deh, deh2_state)#define set_deh_state(deh,val)	set_le16 (deh, deh2_state, val)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -