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

📄 reiserfs_fs.h

📁 unxi下共享内存的使用
💻 H
📖 第 1 页 / 共 5 页
字号:
#define DISK_LEAF_NODE_LEVEL  1 /* Leaf node level.*//* 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))/* Number of items that are in buffer. */#define B_NR_ITEMS(p_s_bh)            (blkh_nr_item(B_BLK_HEAD(p_s_bh)))#define B_LEVEL(p_s_bh)               (blkh_level(B_BLK_HEAD(p_s_bh)))#define B_FREE_SPACE(p_s_bh)          (blkh_free_space(B_BLK_HEAD(p_s_bh)))#define PUT_B_NR_ITEMS(p_s_bh,val)    do { set_blkh_nr_item(B_BLK_HEAD(p_s_bh),val); } while (0)#define PUT_B_LEVEL(p_s_bh,val)       do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)#define PUT_B_FREE_SPACE(p_s_bh,val)  do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)/* Get right delimiting key. -- little endian */#define B_PRIGHT_DELIM_KEY(p_s_bh)   (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))/* Does the buffer contain a disk leaf. */#define B_IS_ITEMS_LEVEL(p_s_bh)     (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)/* Does the buffer contain a disk internal node */#define B_IS_KEYS_LEVEL(p_s_bh)      (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \                                            && B_LEVEL(p_s_bh) <= MAX_HEIGHT)/***************************************************************************//*                             STAT DATA                                   *//***************************************************************************///// 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 SD_V1_SIZE              (sizeof(struct stat_data_v1))#define stat_data_v1(ih)        (ih_version (ih) == KEY_FORMAT_3_5)#define sd_v1_mode(sdp)         (le16_to_cpu((sdp)->sd_mode))#define set_sd_v1_mode(sdp,v)   ((sdp)->sd_mode = cpu_to_le16(v))#define sd_v1_nlink(sdp)        (le16_to_cpu((sdp)->sd_nlink))#define set_sd_v1_nlink(sdp,v)  ((sdp)->sd_nlink = cpu_to_le16(v))#define sd_v1_uid(sdp)          (le16_to_cpu((sdp)->sd_uid))#define set_sd_v1_uid(sdp,v)    ((sdp)->sd_uid = cpu_to_le16(v))#define sd_v1_gid(sdp)          (le16_to_cpu((sdp)->sd_gid))#define set_sd_v1_gid(sdp,v)    ((sdp)->sd_gid = cpu_to_le16(v))#define sd_v1_size(sdp)         (le32_to_cpu((sdp)->sd_size))#define set_sd_v1_size(sdp,v)   ((sdp)->sd_size = cpu_to_le32(v))#define sd_v1_atime(sdp)        (le32_to_cpu((sdp)->sd_atime))#define set_sd_v1_atime(sdp,v)  ((sdp)->sd_atime = cpu_to_le32(v))#define sd_v1_mtime(sdp)        (le32_to_cpu((sdp)->sd_mtime))#define set_sd_v1_mtime(sdp,v)  ((sdp)->sd_mtime = cpu_to_le32(v))#define sd_v1_ctime(sdp)        (le32_to_cpu((sdp)->sd_ctime))#define set_sd_v1_ctime(sdp,v)  ((sdp)->sd_ctime = cpu_to_le32(v))#define sd_v1_rdev(sdp)         (le32_to_cpu((sdp)->u.sd_rdev))#define set_sd_v1_rdev(sdp,v)   ((sdp)->u.sd_rdev = cpu_to_le32(v))#define sd_v1_blocks(sdp)       (le32_to_cpu((sdp)->u.sd_blocks))#define set_sd_v1_blocks(sdp,v) ((sdp)->u.sd_blocks = cpu_to_le32(v))#define sd_v1_first_direct_byte(sdp) \                                (le32_to_cpu((sdp)->sd_first_direct_byte))#define set_sd_v1_first_direct_byte(sdp,v) \                                ((sdp)->sd_first_direct_byte = cpu_to_le32(v))#include <linux/ext2_fs.h>/* inode flags stored in sd_attrs (nee sd_reserved) *//* we want common flags to have the same values as in ext2,   so chattr(1) will work without problems */#define REISERFS_IMMUTABLE_FL EXT2_IMMUTABLE_FL#define REISERFS_SYNC_FL      EXT2_SYNC_FL#define REISERFS_NOATIME_FL   EXT2_NOATIME_FL#define REISERFS_NODUMP_FL    EXT2_NODUMP_FL#define REISERFS_SECRM_FL     EXT2_SECRM_FL#define REISERFS_UNRM_FL      EXT2_UNRM_FL#define REISERFS_COMPR_FL     EXT2_COMPR_FL/* persistent flag to disable tails on per-file basic.   Note, that is inheritable: mark directory with this and   all new files inside will not have tails.    Teodore Tso allocated EXT2_NODUMP_FL (0x00008000) for this. Change   numeric constant to ext2 macro when available. */#define REISERFS_NOTAIL_FL    (0x00008000) /* EXT2_NOTAIL_FL *//* persistent flags that file inherits from the parent directory */#define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |	\				REISERFS_SYNC_FL |	\				REISERFS_NOATIME_FL |	\				REISERFS_NODUMP_FL |	\				REISERFS_SECRM_FL |	\				REISERFS_COMPR_FL |	\				REISERFS_NOTAIL_FL )/* 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__));//// this is 44 bytes long//#define SD_SIZE (sizeof(struct stat_data))#define SD_V2_SIZE              SD_SIZE#define stat_data_v2(ih)        (ih_version (ih) == KEY_FORMAT_3_6)#define sd_v2_mode(sdp)         (le16_to_cpu((sdp)->sd_mode))#define set_sd_v2_mode(sdp,v)   ((sdp)->sd_mode = cpu_to_le16(v))/* sd_reserved *//* set_sd_reserved */#define sd_v2_nlink(sdp)        (le32_to_cpu((sdp)->sd_nlink))#define set_sd_v2_nlink(sdp,v)  ((sdp)->sd_nlink = cpu_to_le32(v))#define sd_v2_size(sdp)         (le64_to_cpu((sdp)->sd_size))#define set_sd_v2_size(sdp,v)   ((sdp)->sd_size = cpu_to_le64(v))#define sd_v2_uid(sdp)          (le32_to_cpu((sdp)->sd_uid))#define set_sd_v2_uid(sdp,v)    ((sdp)->sd_uid = cpu_to_le32(v))#define sd_v2_gid(sdp)          (le32_to_cpu((sdp)->sd_gid))#define set_sd_v2_gid(sdp,v)    ((sdp)->sd_gid = cpu_to_le32(v))#define sd_v2_atime(sdp)        (le32_to_cpu((sdp)->sd_atime))#define set_sd_v2_atime(sdp,v)  ((sdp)->sd_atime = cpu_to_le32(v))#define sd_v2_mtime(sdp)        (le32_to_cpu((sdp)->sd_mtime))#define set_sd_v2_mtime(sdp,v)  ((sdp)->sd_mtime = cpu_to_le32(v))#define sd_v2_ctime(sdp)        (le32_to_cpu((sdp)->sd_ctime))#define set_sd_v2_ctime(sdp,v)  ((sdp)->sd_ctime = cpu_to_le32(v))#define sd_v2_blocks(sdp)       (le32_to_cpu((sdp)->sd_blocks))#define set_sd_v2_blocks(sdp,v) ((sdp)->sd_blocks = cpu_to_le32(v))#define sd_v2_rdev(sdp)         (le32_to_cpu((sdp)->u.sd_rdev))#define set_sd_v2_rdev(sdp,v)   ((sdp)->u.sd_rdev = cpu_to_le32(v))#define sd_v2_generation(sdp)   (le32_to_cpu((sdp)->u.sd_generation))#define set_sd_v2_generation(sdp,v) ((sdp)->u.sd_generation = cpu_to_le32(v))#define sd_v2_attrs(sdp)         (le16_to_cpu((sdp)->sd_attrs))#define set_sd_v2_attrs(sdp,v)   ((sdp)->sd_attrs = cpu_to_le16(v))/***************************************************************************//*                      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 SD_UNIQUENESS 0#define DOT_OFFSET 1#define DOT_DOT_OFFSET 2#define DIRENTRY_UNIQUENESS 500/* */#define FIRST_ITEM_OFFSET 1/*   Q: How to get key of object pointed to by entry from entry?     A: 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 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) */} __attribute__ ((__packed__));#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 put_deh_offset(p_deh,v)   ((p_deh)->deh_offset = cpu_to_le32((v)))#define put_deh_dir_id(p_deh,v)   ((p_deh)->deh_dir_id = cpu_to_le32((v)))#define put_deh_objectid(p_deh,v) ((p_deh)->deh_objectid = cpu_to_le32((v)))#define put_deh_location(p_deh,v) ((p_deh)->deh_location = cpu_to_le16((v)))#define put_deh_state(p_deh,v)    ((p_deh)->deh_state = cpu_to_le16((v)))/* empty directory contains two entries "." and ".." and their headers */#define EMPTY_DIR_SIZE \(DEH_SIZE * 2 + ROUND_UP (strlen (".")) + ROUND_UP (strlen ("..")))/* old format directories have this size when empty */#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3)#define DEH_Statdata 0			/* not used now */#define DEH_Visible 2/* 64 bit systems (and the S/390) need to be aligned explicitly -jdm */#if BITS_PER_LONG == 64 || defined(__s390__) || defined(__hppa__)#   define ADDR_UNALIGNED_BITS  (3)#endif/* These are only used to manipulate deh_state. * Because of this, we'll use the ext2_ bit routines, * since they are little endian */#ifdef ADDR_UNALIGNED_BITS#   define aligned_address(addr)           ((void *)((long)(addr) & ~((1UL << ADDR_UNALIGNED_BITS) - 1)))#   define unaligned_offset(addr)          (((int)((long)(addr) & ((1 << ADDR_UNALIGNED_BITS) - 1))) << 3)#   define set_bit_unaligned(nr, addr)     ext2_set_bit((nr) + unaligned_offset(addr), aligned_address(addr))#   define clear_bit_unaligned(nr, addr)   ext2_clear_bit((nr) + unaligned_offset(addr), aligned_address(addr))#   define test_bit_unaligned(nr, addr)    ext2_test_bit((nr) + unaligned_offset(addr), aligned_address(addr))#else#   define set_bit_unaligned(nr, addr)     ext2_set_bit(nr, addr)#   define clear_bit_unaligned(nr, addr)   ext2_clear_bit(nr, addr)#   define test_bit_unaligned(nr, addr)    ext2_test_bit(nr, addr)#endif#define mark_de_with_sd(deh)        set_bit_unaligned (DEH_Statdata, &((deh)->deh_state))#define mark_de_without_sd(deh)     clear_bit_unaligned (DEH_Statdata, &((deh)->deh_state))#define mark_de_visible(deh)	    set_bit_unaligned (DEH_Visible, &((deh)->deh_state))#define mark_de_hidden(deh)	    clear_bit_unaligned (DEH_Visible, &((deh)->deh_state))#define de_with_sd(deh)		    test_bit_unaligned (DEH_Statdata, &((deh)->deh_state))#define de_visible(deh)	    	    test_bit_unaligned (DEH_Visible, &((deh)->deh_state))#define de_hidden(deh)	    	    !test_bit_unaligned (DEH_Visible, &((deh)->deh_state))extern void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid,				    __u32 par_dirid, __u32 par_objid);extern void make_empty_dir_item (char * body, __u32 dirid, __u32 objid,				 __u32 par_dirid, __u32 par_objid);/* array of the entry headers */ /* get item body */#define B_I_PITEM(bh,ih) ( (bh)->b_data + ih_location(ih) )#define B_I_DEH(bh,ih) ((struct reiserfs_de_head *)(B_I_PITEM(bh,ih)))/* length of the directory entry in directory item. This define   calculates length of i-th directory entry using directory entry   locations from dir entry head. When it calculates length of 0-th   directory entry, it uses length of whole item in place of entry   location of the non-existent following entry in the calculation.   See picture above.*//*#define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh))))*/static inline int entry_length (const struct buffer_head * bh, 								const struct item_head * ih, int pos_in_item){    struct reiserfs_de_head * deh;    deh = B_I_DEH (bh, ih) + pos_in_item;    if (pos_in_item)	return deh_location(deh-1) - deh_location(deh);    return ih_item_len(ih) - deh_location(deh);}

⌨️ 快捷键说明

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