fs/hfs/btree.h
Source file repositories/reference/linux-study-clean/fs/hfs/btree.h
File Facts
- System
- Linux kernel
- Corpus path
fs/hfs/btree.h- Extension
.h- Size
- 3999 bytes
- Lines
- 132
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
hfs_fs.h
Detected Declarations
struct hfs_btreestruct hfs_bnodestruct hfs_find_dataenum hfs_btree_mutex_classes
Annotated Snippet
struct hfs_btree {
struct super_block *sb;
struct inode *inode;
btree_keycmp keycmp;
u32 cnid;
u32 root;
u32 leaf_count;
u32 leaf_head;
u32 leaf_tail;
u32 node_count;
u32 free_nodes;
u32 attributes;
unsigned int node_size;
unsigned int node_size_shift;
unsigned int max_key_len;
unsigned int depth;
//unsigned int map1_size, map_size;
struct mutex tree_lock;
unsigned int pages_per_bnode;
spinlock_t hash_lock;
struct hfs_bnode *node_hash[NODE_HASH_SIZE];
int node_hash_cnt;
};
/* A HFS BTree node in memory */
struct hfs_bnode {
struct hfs_btree *tree;
u32 prev;
u32 this;
u32 next;
u32 parent;
u16 num_recs;
u8 type;
u8 height;
struct hfs_bnode *next_hash;
unsigned long flags;
wait_queue_head_t lock_wq;
atomic_t refcnt;
unsigned int page_offset;
struct page *page[];
};
#define HFS_BNODE_ERROR 0
#define HFS_BNODE_NEW 1
#define HFS_BNODE_DELETED 2
struct hfs_find_data {
btree_key *key;
btree_key *search_key;
struct hfs_btree *tree;
struct hfs_bnode *bnode;
int record;
int keyoffset, keylength;
int entryoffset, entrylength;
};
/* btree.c */
extern struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id,
btree_keycmp keycmp);
extern void hfs_btree_close(struct hfs_btree *tree);
extern void hfs_btree_write(struct hfs_btree *tree);
extern int hfs_bmap_reserve(struct hfs_btree *tree, u32 rsvd_nodes);
extern struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree);
extern void hfs_bmap_free(struct hfs_bnode *node);
/* bnode.c */
extern void hfs_bnode_read(struct hfs_bnode *node, void *buf, u32 off, u32 len);
extern u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off);
extern u8 hfs_bnode_read_u8(struct hfs_bnode *node, u32 off);
extern void hfs_bnode_read_key(struct hfs_bnode *node, void *key, u32 off);
extern void hfs_bnode_write(struct hfs_bnode *node, void *buf, u32 off, u32 len);
extern void hfs_bnode_write_u16(struct hfs_bnode *node, u32 off, u16 data);
extern void hfs_bnode_write_u8(struct hfs_bnode *node, u32 off, u8 data);
extern void hfs_bnode_clear(struct hfs_bnode *node, u32 off, u32 len);
extern void hfs_bnode_copy(struct hfs_bnode *dst_node, u32 dst,
struct hfs_bnode *src_node, u32 src, u32 len);
extern void hfs_bnode_move(struct hfs_bnode *node, u32 dst, u32 src, u32 len);
extern void hfs_bnode_dump(struct hfs_bnode *node);
extern void hfs_bnode_unlink(struct hfs_bnode *node);
extern struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid);
extern struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree, u32 num);
extern void hfs_bnode_unhash(struct hfs_bnode *node);
Annotation
- Immediate include surface: `hfs_fs.h`.
- Detected declarations: `struct hfs_btree`, `struct hfs_bnode`, `struct hfs_find_data`, `enum hfs_btree_mutex_classes`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.