📄 reiserfs.h
字号:
#ifndef __RFSD_REISER_FS_H__
#define __RFSD_REISER_FS_H__
#include <linux/types.h>
#ifdef __GCC__
#define __PACKED __PACKED
#else
#define __PACKED
#endif
/***************************************************************************/
/* SUPER BLOCK */
/***************************************************************************/
/*
* Structure of super block on disk, a version of which in RAM is often accessed as REISERFS_SB(s)->s_rs
* the version in RAM is part of a larger structure containing fields never written to disk.
*/
#define UNSET_HASH 0 // read_super will guess about, what hash names
// in directories were sorted with
#define TEA_HASH 1
#define YURA_HASH 2
#define R5_HASH 3
#define DEFAULT_HASH R5_HASH
struct journal_params {
// Block number of the block containing the first journal node.
__u32 jp_journal_1st_block; /* where does journal start from on its device */
// Journal device number (?? for if the journal is on a seperate drive ??)
__u32 jp_journal_dev; /* journal device st_rdev */
// Original journal size. (Needed when using partition on systems w/ different default journal sizes).
__u32 jp_journal_size; /* size of the journal */
__u32 jp_journal_trans_max; /* max number of blocks in a transaction. */
__u32 jp_journal_magic; /* random value made on fs creation (this was sb_journal_block_count) */
__u32 jp_journal_max_batch; /* max number of blocks to batch into a trans */
__u32 jp_journal_max_commit_age; /* in seconds, how old can an async commit be */
__u32 jp_journal_max_trans_age; /* in seconds, how old can a transaction be */
};
/* this is the super from 3.5.X, where X >= 10 */
#ifndef __GCC__
#pragma pack(push, 1)
#endif
struct reiserfs_super_block_v1
{
// The number of blocks in the partition
__u32 s_blocks_count; /* blocks count */ //[mark] was _s_blocks_count
// The number of free blocks in the partition
__u32 s_free_blocks_count; /* free blocks count */ //[mark] was _s_free_blocks
// Block number of the block containing the root node
__u32 s_root_block; /* root block number */
struct journal_params s_journal;
// The size (in bytes) of a block
__u16 s_blocksize; /* block size */
__u16 s_oid_maxsize; /* max size of object id array, see get_objectid() commentary */
__u16 s_oid_cursize; /* current size of object id array */
__u16 s_umount_state; /* this is set to 1 when filesystem was umounted, to 2 - when not */
char s_magic[10]; /* reiserfs magic string indicates that
* file system is reiserfs:
* "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
// State of the partition: valid(1), error (2)
__u16 s_fs_state; /* it is set to used by fsck to mark which phase of rebuilding is done */
__u32 s_hash_function_code; /* indicate, what hash function is being use
* to sort names in a directory*/
__u16 s_tree_height; /* height of disk tree */
__u16 s_bmap_nr; /* amount of bitmap blocks needed to address
* each block of file system */
// The reiserfs version number
__u16 s_version; /* this field is only reliable on filesystem
* with non-standard journal */
__u16 s_reserved_for_journal; /* size in blocks of journal area on main
* device, we need to keep after
* making fs with non-standard journal */
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
#define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1))
/* this is the on disk super block */
#ifndef __GCC__
#pragma pack(push, 1)
#endif
struct reiserfs_super_block
{
struct reiserfs_super_block_v1 s_v1;
// Number of the current inode generation (a counter that is increased every time the tree gets re-balanced).
__u32 s_inode_generation;
__u32 s_flags; /* Right now used only by inode-attributes, if enabled */
unsigned char s_uuid[16]; /* filesystem unique identifier */
unsigned char s_label[16]; /* filesystem volume label */
char s_unused[88] ; /* zero filled by mkreiserfs and
* reiserfs_convert_objectid_map_v1()
* so any additions must be updated
* there as well. */
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
#define SB_SIZE (sizeof(struct reiserfs_super_block))
#define REISERFS_VERSION_1 0
#define REISERFS_VERSION_2 2
// ... [ommissions]
/* used by gcc */
#define REISERFS_SUPER_MAGIC 0x52654973
/* used by file system utilities that
look at the superblock, etc. */
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
/* 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 REISERFS_FIRST_BLOCK unused_define
#define REISERFS_JOURNAL_OFFSET_IN_BYTES REISERFS_DISK_OFFSET_IN_BYTES
/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */
#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
/***************************************************************************/
/* STAT DATA */
/***************************************************************************/
#ifndef __GCC__
#pragma pack(push, 1)
#endif
//
// 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 (in bytes) */
__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 */ //[mark]this is the one filled..
} __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 */
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
/* 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_APPEND_FL EXT2_APPEND_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
#define REISERFS_NOTAIL_FL 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 )
#ifndef __GCC__
#pragma pack(push, 1)
#endif
/* Stat Data on disk (reiserfs version of UFS disk inode minus the
address blocks) */
struct stat_data {
__u16 i_mode; /* file type, permissions */ // The low 9 bits (3 octals) contain world/group/user permissions. The next 3 bits (from lower to higher) are the sticky bit, the set GID bit, and the set UID bit. The high 4 bits are the file type (as defined in stat.h: socket, symlink, regular, block dev, directory, char device, fifo)
__u16 sd_attrs; /* persistent inode flags */
__u32 i_links_count; /* number of hard links */ //[mark] was sd_nlink
__u64 i_size; /* file size */
__u32 i_uid; /* owner */
__u32 i_gid; /* group */
__u32 i_atime; /* time of last access */
__u32 i_mtime; /* time file was last modified */
__u32 i_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
__u32 sd_blocks;
union {
__u32 sd_rdev;
__u32 i_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? */
} __PACKED u;
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
//
// this is 44 bytes long
//
#define SD_SIZE (sizeof(struct stat_data))
#define SD_V2_SIZE SD_SIZE
/*
* values for s_umount_state field
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -