📄 reiserfs.h
字号:
*/
#define REISERFS_VALID_FS 1
#define REISERFS_ERROR_FS 2
//
// there are 5 item types currently
//
#define RFSD_KEY_TYPE_v1_STAT_DATA 0
#define RFSD_KEY_TYPE_v1_INDIRECT 0xFFFFFFFe
#define RFSD_KEY_TYPE_v1_DIRECT 0xFFFFFFFF
#define RFSD_KEY_TYPE_v1_DIRENTRY 500
#define RFSD_KEY_TYPE_v2_STAT_DATA 0
#define RFSD_KEY_TYPE_v2_INDIRECT 1
#define RFSD_KEY_TYPE_v2_DIRECT 2
#define RFSD_KEY_TYPE_v2_DIRENTRY 3
/***************************************************************************/
/* KEY & ITEM HEAD */
/***************************************************************************/
typedef struct reiserfs_cpu_key
{
__u32 k_dir_id;
__u32 k_objectid;
__u64 k_offset;
__u32 k_type;
};
//
// directories use this key as well as old files
//
#ifndef __GCC__
#pragma pack(push, 1)
#endif
struct offset_v1 {
__u32 k_offset;
__u32 k_uniqueness;
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
#ifndef __GCC__
#pragma pack(push, 1)
#endif
struct offset_v2 {
#ifdef __LITTLE_ENDIAN
/* little endian version */
__u64 k_offset:60;
__u64 k_type: 4;
#else
/* big endian version */
__u64 k_type: 4;
__u64 k_offset:60;
#endif
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
// ...
#ifndef __GCC__
#pragma pack(push, 1)
#endif
/* Key of an item determines its location in the S+tree, and
is composed of 4 components */
struct reiserfs_key {
__u32 k_dir_id; /* packing locality: by default parent directory object id */
__u32 k_objectid; /* object identifier */
union {
struct offset_v1 k_offset_v1;
struct offset_v2 k_offset_v2;
} u;
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
/// ...
#ifndef __GCC__
#pragma pack(push, 1)
#endif
/* 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
{
/* Everything in the tree is found by searching for it based on
* its key.*/
struct reiserfs_key ih_key;
union {
/* 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 ih_free_space_reserved;
/* Iff this is a directory item, this field equals the
number of directory entries in the directory item. */
__u16 ih_entry_count;
} u;
__u16 ih_item_len; /* total size of the item body */
__u16 ih_item_location; /* an offset to the item body within the block */
__u16 ih_version; /* 0 for all old items, 2 for new
ones. Highest bit is set by fsck
temporary, cleaned after all
done */
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
/// ...
/* object identifier for root dir */
#define REISERFS_ROOT_OBJECTID 2
#define REISERFS_ROOT_PARENT_OBJECTID 1
/// ...
/*
* Picture represents a leaf of the S+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. */
#ifndef __GCC__
#pragma pack(push, 1)
#endif
struct block_head {
__u16 blk_level; /* Level of a block in the tree. */
__u16 blk_nr_item; /* Number of keys/items in a block. */
__u16 blk_free_space; /* Block free space in bytes. */
__u16 blk_reserved;
/* dump this in v4/planA */
struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */
};
#ifndef __GCC__
#pragma pack(pop)
#endif
/***************************************************************************/
/* 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. */
// ...
/*
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 */
#ifndef __GCC__
#pragma pack(push, 1)
#endif
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) */
} __PACKED;
#ifndef __GCC__
#pragma pack(pop)
#endif
/*
* Picture represents an internal node of the reiserfs tree
* ______________________________________________________
* | | Array of | Array of | Free |
* |block | keys | pointers | space |
* | head | N | N+1 | |
* |______|_______________|___________________|___________|
*/
/***************************************************************************/
/* DISK CHILD */
/***************************************************************************/
/* Disk child pointer: The pointer from an internal node of the tree
to a node that is on disk. */
#ifndef __GCC__
#pragma pack(push, 1)
#endif
struct disk_child {
__u32 dc_block_number; /* Disk child's block number. */
__u16 dc_size; /* Disk child's used space. */
__u16 dc_reserved;
};
#ifndef __GCC__
#pragma pack(pop)
#endif
#endif // header
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -