📄 reiserfs_fs.h
字号:
#define set_sd_v1_first_direct_byte(sd,n) \ ((sd)->sd_first_direct_byte = cpu_to_le32((n)))/* v2 */#define sd_v2_mode(sd) (le16_to_cpu((sd)->sd_mode))#define set_sd_v2_mode(sd,n) ((sd)->sd_mode = cpu_to_le16((n)))#define sd_v2_sd_attrs(sd) (le16_to_cpu((sd)->sd_attrs))#define set_sd_v2_sd_attrs(sd,n) ((sd)->sd_attrs = cpu_to_le16((n)))#define sd_v2_nlink(sd) (le32_to_cpu((sd)->sd_nlink))#define set_sd_v2_nlink(sd,n) ((sd)->sd_nlink = cpu_to_le32((n))) #define sd_v2_size(sd) (le64_to_cpu((sd)->sd_size))#define set_sd_v2_size(sd,n) ((sd)->sd_size = cpu_to_le64((n)))#define sd_v2_uid(sd) (le32_to_cpu((sd)->sd_uid))#define set_sd_v2_uid(sd,n) ((sd)->sd_uid = cpu_to_le32((n)))#define sd_v2_gid(sd) (le32_to_cpu((sd)->sd_gid))#define set_sd_v2_gid(sd,n) ((sd)->sd_gid = cpu_to_le32((n)))#define sd_v2_atime(sd) (le32_to_cpu((sd)->sd_atime))#define set_sd_v2_atime(sd,n) ((sd)->sd_atime = cpu_to_le32((n)))#define sd_v2_mtime(sd) (le32_to_cpu((sd)->sd_mtime))#define set_sd_v2_mtime(sd,n) ((sd)->sd_mtime = cpu_to_le32((n)))#define sd_v2_ctime(sd) (le32_to_cpu((sd)->sd_ctime))#define set_sd_v2_ctime(sd,n) ((sd)->sd_ctime = cpu_to_le32((n)))#define sd_v2_blocks(sd) (le32_to_cpu((sd)->sd_blocks))#define set_sd_v2_blocks(sd,n) ((sd)->sd_blocks = cpu_to_le32((n)))#define sd_v2_rdev(sd) (le32_to_cpu((sd)->u.sd_rdev))#define set_sd_v2_rdev(sd,n) ((sd)->u.sd_rdev = cpu_to_le32((n)))/* ReiserFS leaves the first 64k unused, so that partition labels have enough space. If someone wants to write a fancy bootloader that needs more than 64k, let us know, and this will be increased in size. This number must be larger than than the largest block size on any platform, or code will break. -Hans */#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)/*#define MD_RAID_SUPERBLOCKS_IN_BYTES (128 * 1024)*//* the spot for the super in versions 3.5 - 3.5.11 (inclusive) */#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)/* prejournalled reiserfs had signature in the other place in super block */#define REISERFS_SUPER_MAGIC_STRING_OFFSET_NJ 20/* f_type of struct statfs will be set at this value by statfs(2) */#define REISERFS_SUPER_MAGIC 0x52654973/* various reiserfs signatures. We have 3 so far. ReIsErFs for 3.5 format with standard journal, ReIsEr2Fs for 3.6 (or converted 3.5) and ReIsEr3Fs for filesystem with non-standard journal (formats are distinguished by sb_version in that case). Those signatures should be looked for at the 64-th and at the 8-th 1k block of the device */#define REISERFS_3_5_SUPER_MAGIC_STRING "ReIsErFs"#define REISERFS_3_6_SUPER_MAGIC_STRING "ReIsEr2Fs"#define REISERFS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" /* JR stands for Journal Relocation */#define get_reiserfs_ondisk_offset(block_of_super_block, block_size) \ (block_of_super_block * block_size)#define is_new_sb_location(block_of_super_block, block_size) \ ((get_reiserfs_ondisk_offset(block_of_super_block, block_size) == REISERFS_DISK_OFFSET_IN_BYTES) \ ? 1 : 0) /*only 4k blocks for old location*/#define is_old_sb_location(block_of_super_block, block_size) \ ((get_reiserfs_ondisk_offset(block_of_super_block, 4096) == REISERFS_OLD_DISK_OFFSET_IN_BYTES) \ ? 1 : 0)/***************************************************************************//* JOURNAL *//***************************************************************************/#define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal *//* journal.c see journal.c for all the comments here *///#define JOURNAL_TRANS_HALF 1018 /* must be correct to keep the desc and commit structs at 4k *//* first block written in a commit. BUG, not 64bit safe */struct reiserfs_journal_desc { __u32 j2_trans_id ; /* id of commit */ __u32 j2_len ; /* length of commit. len +1 is the commit block */ __u32 j2_mount_id ; /* mount id of this trans*/ __u32 j2_realblock[1] ; /* real locations for each block */ };#define get_jd_magic(bh) (bh->b_data + bh->b_size - 12)#define journal_trans_half(blocksize) \((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__u32) - 12) / sizeof (__u32))#define jdesc_header(bh) ((struct reiserfs_journal_desc *)bh->b_data)#define get_desc_trans_id(bh) get_le32 (jdesc_header (bh), j2_trans_id)#define set_desc_trans_id(bh,val) set_le32 (jdesc_header (bh), j2_trans_id, val)#define get_desc_trans_len(bh) get_le32 (jdesc_header (bh), j2_len)#define set_desc_trans_len(bh,val) set_le32 (jdesc_header (bh), j2_len, val)#define get_desc_mount_id(bh) get_le32 (jdesc_header (bh), j2_mount_id)#define set_desc_mount_id(bh,val) set_le32 (jdesc_header (bh), j2_mount_id, val) /* last block written in a commit BUG, not 64bit safe */struct reiserfs_journal_commit { __u32 j3_trans_id ; /* must match j_trans_id from the desc block */ __u32 j3_len ; /* ditto */ __u32 j3_realblock[1] ; /* real locations for each block */} ;#define jcommit_header(bh) ((struct reiserfs_journal_commit *)bh->b_data)#define get_commit_trans_id(bh) get_le32 (jcommit_header(bh), j3_trans_id)#define set_commit_trans_id(bh,val) set_le32 (jcommit_header(bh), j3_trans_id, val)#define get_commit_trans_len(bh) get_le32 (jcommit_header(bh), j3_len)#define set_comm_trans_len(bh,val) set_le32 (jcommit_header(bh), j3_len, val)/* this header block gets written whenever a transaction is considered fully** flushed, and is more recent than the last fully flushed transaction. fully** flushed means all the log blocks and all the real blocks are on disk, and** this transaction does not need to be replayed. */struct reiserfs_journal_header { __u32 jh_last_flush_trans_id ; /* id of last fully flushed transaction */ __u32 jh_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */ __u32 jh_mount_id ; struct journal_params jh_journal; __u32 jh_last_check_mount_id; /* the mount id of the fs during the last reiserfsck --check. */};/* set/get fields of journal header with these defines */#define get_jh_mount_id(jh) get_le32 (jh, jh_mount_id)#define set_jh_mount_id(jh,val) set_le32 (jh, jh_mount_id, val)#define get_jh_last_flushed(jh) get_le32 (jh, jh_last_flush_trans_id)#define set_jh_last_flushed(jh,val) set_le32 (jh, jh_last_flush_trans_id, val)#define get_jh_replay_start_offset(jh) get_le32 (jh, jh_first_unflushed_offset)#define set_jh_replay_start_offset(jh,val) set_le32 (jh, jh_first_unflushed_offset, val)/* journal default settings */#define JOURNAL_MIN_SIZE 512#define JOURNAL_TRANS_MAX 1024 /* biggest possible single transaction, don't change for now (8/3/99) */#define JOURNAL_TRANS_MIN 256 /* need to check whether it works */#define JOURNAL_DEFAULT_RATIO 8 /* default journal size / max trans length */#define JOURNAL_MIN_RATIO 2#define JOURNAL_MAX_BATCH 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */#define JOURNAL_MAX_COMMIT_AGE 30#define JOURNAL_MAX_TRANS_AGE 30/* journal max size is a maximum number of blocks pointed by first bitmap - REISERFS_DISK_OFFSET - superblock - first bitmap - journal herader */#define journal_max_size(block_of_super_block,blocksize) \ blocksize * 8 - (block_of_super_block + 1 + 1 + 1)#define journal_default_size(block_of_super_block,blocksize) \ (unsigned long long)((8192 > journal_max_size (block_of_super_block,blocksize)) ? \ journal_max_size (block_of_super_block,blocksize) : 8192)//#define JOURNAL_DEFAULT_SIZE 8192 number of blocks in the journal//#define JOURNAL_DEFAULT_SIZE_FOR_BS_1024 8125 number of blocks in the journal for block size 1KB#define bh_desc(bh) ((struct reiserfs_journal_desc *)((bh)->b_data))#define bh_commit(bh) ((struct reiserfs_journal_commit *)((bh)->b_data))/***************************************************************************//* KEY & ITEM HEAD *//***************************************************************************/struct offset_v1 { __u32 k_offset; __u32 k_uniqueness;} __attribute__ ((__packed__));struct offset_v2 {#if __BYTE_ORDER == __LITTLE_ENDIAN __u64 k_offset:60; __u64 k_type: 4; // TYPE_STAT_DATA | TYPE_INDIRECT | TYPE_DIRECT | TYPE_DIRENTRY#elif __BYTE_ORDER == __BIG_ENDIAN __u64 k_type: 4; // TYPE_STAT_DATA | TYPE_INDIRECT | TYPE_DIRECT | TYPE_DIRENTRY __u64 k_offset:60;#else# error "nuxi/pdp-endian archs are not supported"#endif} __attribute__ ((__packed__));/* Key of the object determines object's location in the tree, composed of 4 components */struct key { __u32 k2_dir_id; /* packing locality: by default parent directory object id */ __u32 k2_objectid; /* object identifier */ union { struct offset_v1 k2_offset_v1; struct offset_v2 k2_offset_v2; } __attribute__ ((__packed__)) u;} __attribute__ ((__packed__));/* set/get fields of keys on disk with these defines */#define get_key_dirid(k) get_le32 (k, k2_dir_id)#define set_key_dirid(k,val) set_le32 (k, k2_dir_id, val)#define get_key_objectid(k) get_le32 (k, k2_objectid)#define set_key_objectid(k,val) set_le32 (k, k2_objectid, val)#define get_key_offset_v1(k) get_le32 (k, u.k2_offset_v1.k_offset)#define set_key_offset_v1(k,val) set_le32 (k, u.k2_offset_v1.k_offset, val)#define get_key_uniqueness(k) get_le32 (k, u.k2_offset_v1.k_uniqueness)#define set_key_uniqueness(k,val) set_le32 (k, u.k2_offset_v1.k_uniqueness, val)/*#define get_key_offset_v2(k) get_le64 (k, u.k2_offset_v2.k_offset)#define set_key_offset_v2(k,val) set_le64 (k, u.k2_offset_v2.k_offset, val)*//* ??? *//*#define get_key_type(k) get_le16 (k, u.k2_offset_v2.k_type)#define set_key_type(k,val) set_le16 (k, u.k2_offset_v2.k_type, val)*//*#define key_dir_id(key) (le32_to_cpu((key)->k_dir_id))#define set_key_dir_id(key,n) ((key)->k_dir_id = cpu_to_le32((n)))#define key_objectid(key) (le32_to_cpu((key)->k_objectid))#define set_key_objectid(key,n) ((key)->k_objectid = cpu_to_le32((n)))*/#define KEY_SIZE (sizeof(struct key))#define SHORT_KEY_SIZE 8// values for k_uniqueness field of the struct key#define V1_SD_UNIQUENESS 0#define V1_DIRENTRY_UNIQUENESS 500#define DIRENTRY_UNIQUENESS 500#define V1_DIRECT_UNIQUENESS 0xffffffff#define V1_INDIRECT_UNIQUENESS 0xfffffffe#define V1_UNKNOWN_UNIQUENESS 555// values for k_type field of the struct key#define TYPE_STAT_DATA 0#define TYPE_INDIRECT 1#define TYPE_DIRECT 2#define TYPE_DIRENTRY 3 #define TYPE_UNKNOWN 15/* special type for symlink not conflicting to any of item types. */#define TYPE_SYMLINK 4#define KEY_FORMAT_1 0#define KEY_FORMAT_2 1#define KEY_FORMAT_UNDEFINED 15 /* Our function for comparing keys can compare keys of different lengths. It takes as a parameter the length of the keys it is to compare. These defines are used in determining what is to be passed to it as that parameter. */#define REISERFS_FULL_KEY_LEN 4#define REISERFS_SHORT_KEY_LEN 2/* Everything in the filesystem is stored as a set of items. The item head contains the key of the item, its free space (for indirect items) and specifies the location of the item itself within the block. */struct item_head{ struct key ih_key; /* Everything in the tree is found by searching for it based on its key.*/ union { __u16 ih2_free_space; /* The free space in the last unformatted node of an indirect item if this is an indirect item. This equals 0xFFFF iff this is a direct item or stat data item. Note that the key, not this field, is used to determine the item type, and thus which field this union contains. */ __u16 ih2_entry_count; /* Iff this is a directory item, this field equals the number of directory entries in the directory item. */ } __attribute__ ((__packed__)) u; __u16 ih2_item_len; /* total size of the item body */ __u16 ih2_item_location; /* an offset to the item body within the block */ __u16 ih_format; /* key format is stored in bits 0-11 of this item flags are stored in bits 12-15 */#if 0 struct { __u16 key_format : 12; /* KEY_FORMAT_1 or KEY_FORMAT_2. This is not necessary, but we have space, let use it */ __u16 flags : 4; /* fsck set here its flag (reachable/unreachable) */ } __attribute__ ((__packed__)) ih2_format;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -