Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/include/linux/hfsplus_fs.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1999
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Brad Boyer (flar@pants.nu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * (C) 2003 Ardis Technologies <roman@ardistech.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef _LINUX_HFSPLUS_FS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define _LINUX_HFSPLUS_FS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #ifdef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #undef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "hfsplus_raw.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define DBG_BNODE_REFS	0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define DBG_BNODE_MOD	0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define DBG_CAT_MOD	0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define DBG_INODE	0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define DBG_SUPER	0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define DBG_EXTENT	0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define DBG_BITMAP	0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define DBG_ATTR_MOD	0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define DBG_MASK	(DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define DBG_MASK	(DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define DBG_MASK	(DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define DBG_MASK	(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define hfs_dbg(flg, fmt, ...)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	if (DBG_##flg & DBG_MASK)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define hfs_dbg_cont(flg, fmt, ...)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if (DBG_##flg & DBG_MASK)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		pr_cont(fmt, ##__VA_ARGS__);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /* Runtime config options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define HFSPLUS_DEF_CR_TYPE    0x3F3F3F3F  /* '????' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define HFSPLUS_TYPE_DATA 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define HFSPLUS_TYPE_RSRC 0xFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) typedef int (*btree_keycmp)(const hfsplus_btree_key *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		const hfsplus_btree_key *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define NODE_HASH_SIZE	256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /* B-tree mutex nested subclasses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) enum hfsplus_btree_mutex_classes {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	CATALOG_BTREE_MUTEX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	EXTENTS_BTREE_MUTEX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ATTR_BTREE_MUTEX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) /* An HFS+ BTree held in memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct hfs_btree {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	btree_keycmp keycmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	u32 cnid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	u32 root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u32 leaf_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u32 leaf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	u32 leaf_tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	u32 node_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	u32 free_nodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	u32 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	unsigned int node_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	unsigned int node_size_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	unsigned int max_key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	unsigned int depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct mutex tree_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	unsigned int pages_per_bnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	spinlock_t hash_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct hfs_bnode *node_hash[NODE_HASH_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	int node_hash_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /* An HFS+ BTree node in memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct hfs_bnode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct hfs_btree *tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	u32 prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u32 this;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	u32 next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	u32 parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	u16 num_recs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u8 height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct hfs_bnode *next_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	wait_queue_head_t lock_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	atomic_t refcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	unsigned int page_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	struct page *page[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define HFS_BNODE_LOCK		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define HFS_BNODE_ERROR		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define HFS_BNODE_NEW		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define HFS_BNODE_DIRTY		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define HFS_BNODE_DELETED	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * Attributes file states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define HFSPLUS_EMPTY_ATTR_TREE		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define HFSPLUS_CREATING_ATTR_TREE	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define HFSPLUS_VALID_ATTR_TREE		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define HFSPLUS_FAILED_ATTR_TREE	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * HFS+ superblock info (built from Volume Header on disk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct hfsplus_vh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct hfs_btree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct hfsplus_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	void *s_vhdr_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct hfsplus_vh *s_vhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	void *s_backup_vhdr_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	struct hfsplus_vh *s_backup_vhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	struct hfs_btree *ext_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct hfs_btree *cat_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	struct hfs_btree *attr_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	atomic_t attr_tree_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	struct inode *alloc_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct inode *hidden_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct nls_table *nls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	/* Runtime variables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	u32 blockoffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	sector_t part_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	sector_t sect_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	int fs_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	/* immutable data from the volume header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	u32 alloc_blksz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	int alloc_blksz_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	u32 total_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	u32 data_clump_blocks, rsrc_clump_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	/* mutable data from the volume header, protected by alloc_mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	u32 free_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	struct mutex alloc_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	/* mutable data from the volume header, protected by vh_mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	u32 next_cnid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	u32 file_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	u32 folder_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	struct mutex vh_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	/* Config options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	u32 creator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	umode_t umask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	int part, session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	int work_queued;               /* non-zero delayed work is queued */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct delayed_work sync_work; /* FS sync delayed work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	spinlock_t work_lock;          /* protects sync_work and work_queued */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define HFSPLUS_SB_WRITEBACKUP	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #define HFSPLUS_SB_NODECOMPOSE	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #define HFSPLUS_SB_FORCE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define HFSPLUS_SB_HFSX		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define HFSPLUS_SB_CASEFOLD	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define HFSPLUS_SB_NOBARRIER	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct hfsplus_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	atomic_t opencnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	 * Extent allocation information, protected by extents_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	u32 first_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	u32 clump_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	u32 alloc_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	u32 cached_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	u32 cached_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	hfsplus_extent_rec first_extents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	hfsplus_extent_rec cached_extents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	unsigned int extent_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	struct mutex extents_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	 * Immutable data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	struct inode *rsrc_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	__be32 create_date;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	 * Protected by sbi->vh_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	u32 linkid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	 * Accessed using atomic bitops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	 * Protected by i_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	sector_t fs_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	u8 userflags;		/* BSD user file flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	u32 subfolders;		/* Subfolder count (HFSX only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	struct list_head open_dir_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	spinlock_t open_dir_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	loff_t phys_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #define HFSPLUS_EXT_DIRTY	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #define HFSPLUS_EXT_NEW		0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #define HFSPLUS_I_RSRC		0	/* represents a resource fork */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #define HFSPLUS_I_CAT_DIRTY	1	/* has changes in the catalog tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #define HFSPLUS_I_EXT_DIRTY	2	/* has changes in the extent tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #define HFSPLUS_I_ALLOC_DIRTY	3	/* has changes in the allocation file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #define HFSPLUS_I_ATTR_DIRTY	4	/* has changes in the attributes tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) #define HFSPLUS_IS_RSRC(inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	test_bit(HFSPLUS_I_RSRC, &HFSPLUS_I(inode)->flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	return container_of(inode, struct hfsplus_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  * Mark an inode dirty, and also mark the btree in which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  * specific type of metadata is stored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  * For data or metadata that gets written back by into the catalog btree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  * by hfsplus_write_inode a plain mark_inode_dirty call is enough.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) static inline void hfsplus_mark_inode_dirty(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		unsigned int flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	set_bit(flag, &HFSPLUS_I(inode)->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) struct hfs_find_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	/* filled by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	hfsplus_btree_key *search_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	hfsplus_btree_key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	/* filled by find */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	struct hfs_btree *tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	struct hfs_bnode *bnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	/* filled by findrec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	int record;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	int keyoffset, keylength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	int entryoffset, entrylength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) struct hfsplus_readdir_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	struct hfsplus_cat_key key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  * Find minimum acceptible I/O size for an hfsplus sb.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static inline unsigned short hfsplus_min_io_size(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	return max_t(unsigned short, bdev_logical_block_size(sb->s_bdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		     HFSPLUS_SECTOR_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #define hfs_btree_open hfsplus_btree_open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #define hfs_btree_close hfsplus_btree_close
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #define hfs_btree_write hfsplus_btree_write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #define hfs_bmap_reserve hfsplus_bmap_reserve
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define hfs_bmap_alloc hfsplus_bmap_alloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #define hfs_bmap_free hfsplus_bmap_free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #define hfs_bnode_read hfsplus_bnode_read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #define hfs_bnode_read_u16 hfsplus_bnode_read_u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) #define hfs_bnode_read_u8 hfsplus_bnode_read_u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #define hfs_bnode_read_key hfsplus_bnode_read_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) #define hfs_bnode_write hfsplus_bnode_write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #define hfs_bnode_write_u16 hfsplus_bnode_write_u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) #define hfs_bnode_clear hfsplus_bnode_clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) #define hfs_bnode_copy hfsplus_bnode_copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #define hfs_bnode_move hfsplus_bnode_move
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #define hfs_bnode_dump hfsplus_bnode_dump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #define hfs_bnode_unlink hfsplus_bnode_unlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) #define hfs_bnode_findhash hfsplus_bnode_findhash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) #define hfs_bnode_find hfsplus_bnode_find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #define hfs_bnode_unhash hfsplus_bnode_unhash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) #define hfs_bnode_free hfsplus_bnode_free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #define hfs_bnode_create hfsplus_bnode_create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #define hfs_bnode_get hfsplus_bnode_get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) #define hfs_bnode_put hfsplus_bnode_put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) #define hfs_brec_lenoff hfsplus_brec_lenoff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #define hfs_brec_keylen hfsplus_brec_keylen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) #define hfs_brec_insert hfsplus_brec_insert
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) #define hfs_brec_remove hfsplus_brec_remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) #define hfs_find_init hfsplus_find_init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) #define hfs_find_exit hfsplus_find_exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) #define __hfs_brec_find __hfsplus_brec_find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) #define hfs_brec_find hfsplus_brec_find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) #define hfs_brec_read hfsplus_brec_read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) #define hfs_brec_goto hfsplus_brec_goto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #define hfs_part_find hfsplus_part_find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  * definitions for ext2 flag ioctls (linux really needs a generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  * interface for this).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * chattr/lsattr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) #define HFSPLUS_IOC_EXT2_GETFLAGS	FS_IOC_GETFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) #define HFSPLUS_IOC_EXT2_SETFLAGS	FS_IOC_SETFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  * hfs+-specific ioctl for making the filesystem bootable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) #define HFSPLUS_IOC_BLESS _IO('h', 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) typedef int (*search_strategy_t)(struct hfs_bnode *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 				struct hfs_find_data *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 				int *, int *, int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  * Functions in any *.c used in other files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /* attributes.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) int __init hfsplus_create_attr_tree_cache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) void hfsplus_destroy_attr_tree_cache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) int hfsplus_attr_bin_cmp_key(const hfsplus_btree_key *k1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 			     const hfsplus_btree_key *k2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 			   u32 cnid, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) hfsplus_attr_entry *hfsplus_alloc_attr_entry(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) void hfsplus_destroy_attr_entry(hfsplus_attr_entry *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) int hfsplus_find_attr(struct super_block *sb, u32 cnid, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		      struct hfs_find_data *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) int hfsplus_attr_exists(struct inode *inode, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) int hfsplus_create_attr(struct inode *inode, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 			const void *value, size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) int hfsplus_delete_attr(struct inode *inode, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) /* bitmap.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			   u32 *max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) /* btree.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) u32 hfsplus_calc_btree_clump_size(u32 block_size, u32 node_size, u64 sectors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 				  int file_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) void hfs_btree_close(struct hfs_btree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) int hfs_btree_write(struct hfs_btree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) void hfs_bmap_free(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) /* bnode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) u8 hfs_bnode_read_u8(struct hfs_bnode *node, int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) void hfs_bnode_read_key(struct hfs_bnode *node, void *key, int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) void hfs_bnode_write_u16(struct hfs_bnode *node, int off, u16 data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) void hfs_bnode_clear(struct hfs_bnode *node, int off, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		    struct hfs_bnode *src_node, int src, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) void hfs_bnode_dump(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) void hfs_bnode_unlink(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) void hfs_bnode_unhash(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree, u32 num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) void hfs_bnode_free(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) void hfs_bnode_get(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) void hfs_bnode_put(struct hfs_bnode *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) bool hfs_bnode_need_zeroout(struct hfs_btree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /* brec.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) int hfs_brec_remove(struct hfs_find_data *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /* bfind.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) void hfs_find_exit(struct hfs_find_data *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) int hfs_find_1st_rec_by_cnid(struct hfs_bnode *bnode, struct hfs_find_data *fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 			     int *begin, int *end, int *cur_rec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) int hfs_find_rec_by_key(struct hfs_bnode *bnode, struct hfs_find_data *fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 			int *begin, int *end, int *cur_rec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		    search_strategy_t rec_found);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) int hfs_brec_read(struct hfs_find_data *fd, void *rec, int rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) int hfs_brec_goto(struct hfs_find_data *fd, int cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /* catalog.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			     const hfsplus_btree_key *k2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 			    const hfsplus_btree_key *k2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) int hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 			   u32 parent, const struct qstr *str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) void hfsplus_cat_build_key_with_cnid(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 				     hfsplus_btree_key *key, u32 parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) int hfsplus_find_cat(struct super_block *sb, u32 cnid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		     struct hfs_find_data *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) int hfsplus_create_cat(u32 cnid, struct inode *dir, const struct qstr *str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		       struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) int hfsplus_rename_cat(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		       struct inode *dst_dir, const struct qstr *dst_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) extern const struct inode_operations hfsplus_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) extern const struct file_operations hfsplus_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) /* extents.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) int hfsplus_ext_cmp_key(const hfsplus_btree_key *k1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			const hfsplus_btree_key *k2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) int hfsplus_ext_write_extent(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) int hfsplus_get_block(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		      struct buffer_head *bh_result, int create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) int hfsplus_free_fork(struct super_block *sb, u32 cnid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		      struct hfsplus_fork_raw *fork, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) int hfsplus_file_extend(struct inode *inode, bool zeroout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) void hfsplus_file_truncate(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) /* inode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) extern const struct address_space_operations hfsplus_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) extern const struct address_space_operations hfsplus_btree_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) extern const struct dentry_operations hfsplus_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 				umode_t mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) void hfsplus_delete_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) void hfsplus_inode_read_fork(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 			     struct hfsplus_fork_raw *fork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) void hfsplus_inode_write_fork(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 			      struct hfsplus_fork_raw *fork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) int hfsplus_cat_write_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) int hfsplus_getattr(const struct path *path, struct kstat *stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		    u32 request_mask, unsigned int query_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		       int datasync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) /* ioctl.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /* options.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) void hfsplus_fill_defaults(struct hfsplus_sb_info *opts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) int hfsplus_parse_options_remount(char *input, int *force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) int hfsplus_show_options(struct seq_file *seq, struct dentry *root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /* part_tbl.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) int hfs_part_find(struct super_block *sb, sector_t *part_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		  sector_t *part_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) void hfsplus_mark_mdb_dirty(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) /* tables.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) extern u16 hfsplus_case_fold_table[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) extern u16 hfsplus_decompose_table[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) extern u16 hfsplus_compose_table[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) /* unicode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) int hfsplus_strcasecmp(const struct hfsplus_unistr *s1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		       const struct hfsplus_unistr *s2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) int hfsplus_strcmp(const struct hfsplus_unistr *s1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		   const struct hfsplus_unistr *s2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		    char *astr, int *len_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) int hfsplus_asc2uni(struct super_block *sb, struct hfsplus_unistr *ustr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		    int max_unistr_len, const char *astr, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) int hfsplus_compare_dentry(const struct dentry *dentry, unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 			   const char *str, const struct qstr *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) /* wrapper.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) int hfsplus_submit_bio(struct super_block *sb, sector_t sector, void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 		       void **data, int op, int op_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) int hfsplus_read_wrapper(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)  * time helpers: convert between 1904-base and 1970-base timestamps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)  * HFS+ implementations are highly inconsistent, this one matches the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)  * traditional behavior of 64-bit Linux, giving the most useful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)  * time range between 1970 and 2106, by treating any on-disk timestamp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)  * under HFSPLUS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) #define HFSPLUS_UTC_OFFSET 2082844800U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) static inline time64_t __hfsp_mt2ut(__be32 mt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	time64_t ut = (u32)(be32_to_cpu(mt) - HFSPLUS_UTC_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	return ut;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) static inline __be32 __hfsp_ut2mt(time64_t ut)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	return cpu_to_be32(lower_32_bits(ut) + HFSPLUS_UTC_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) /* compatibility */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) #define hfsp_mt2ut(t)		(struct timespec64){ .tv_sec = __hfsp_mt2ut(t) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) #define hfsp_ut2mt(t)		__hfsp_ut2mt((t).tv_sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) #define hfsp_now2mt()		__hfsp_ut2mt(ktime_get_real_seconds())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) #endif