hfs/hfsplus: move on-disk layout declarations into hfs_common.h
Subsystems (3)
Viacheslav Dubeyko
maintainerPATCH 1/1 hfs/hfsplus: move on-disk layout declarations into hfs_common.h
Currently, HFS declares on-disk layout's metadata structures in fs/hfs/hfs.h and HFS+ declares it in fs/hfsplus/hfsplus_raw.h. However, HFS and HFS+ on-disk layouts have some similarity and overlapping in declarations. As a result, fs/hfs/hfs.h and fs/hfsplus/hfsplus_raw.h contain multiple duplicated declarations. Moreover, both HFS and HFS+ drivers contain completely similar implemented functionality in multiple places.
This patch is moving the on-disk layout declarations from fs/hfs/hfs.h and fs/hfsplus/hfsplus_raw.h into include/linux/hfs_common.h with the goal to exclude the duplication in declarations. Also, this patch prepares the basis for creating a hfslib that can aggregate common functionality without necessity to duplicate the same code in HFS and HFS+ drivers.
--- fs/hfs/btree.h | 42 --- fs/hfs/hfs.h | 269 +--------------- fs/hfs/hfs_fs.h | 1 - fs/hfsplus/hfsplus_fs.h | 1 - fs/hfsplus/hfsplus_raw.h | 394 +---------------------- fs/hfsplus/xattr.c | 22 +- include/linux/hfs_common.h | 633 +++++++++++++++++++++++++++++++++++++ 7 files changed, 645 insertions(+), 717 deletions(-)
fs/hfs/btree.h +0 -42
@@ -128,45 +128,3 @@ extern int __hfs_brec_find(struct hfs_bnode *, struct hfs_find_data *);extern int hfs_brec_find (struct hfs_find_data *);extern int hfs_brec_read (struct hfs_find_data *,void *,int );extern int hfs_brec_goto (struct hfs_find_data *,int ); - - -struct hfs_bnode_desc { -__be32 next;/* (V) Number of the next node at this level */ -__be32 prev;/* (V) Number of the prev node at this level */ -u8 type;/* (F) The type of node */ -u8 height;/* (F) The level of this node (leaves=1) */ -__be16 num_recs;/* (V) The number of records in this node */ -u16 reserved; -} __packed; - -#define HFS_NODE_INDEX 0x00/* An internal (index) node */ -#define HFS_NODE_HEADER 0x01/* The tree header node (node 0) */ -#define HFS_NODE_MAP 0x02/* Holds part of the bitmap of used nodes */ -#define HFS_NODE_LEAF 0xFF/* A leaf (ndNHeight==1) node */ - -struct hfs_btree_header_rec { -__be16 depth;/* (V) The number of levels in this B-tree */ -__be32 root;/* (V) The node number of the root node */ -__be32 leaf_count;/* (V) The number of leaf records */ -__be32 leaf_head;/* (V) The number of the first leaf node */ -__be32 leaf_tail;/* (V) The number of the last leaf node */ -__be16 node_size;/* (F) The number of bytes in a node (=512) */ -__be16 max_key_len;/* (F) The length of a key in an index node */ -__be32 node_count;/* (V) The total number of nodes */ -__be32 free_nodes;/* (V) The number of unused nodes */ -u16 reserved1; -__be32 clump_size;/* (F) clump size. not usually used. */ -u8 btree_type;/* (F) BTree type */ -u8 reserved2; -__be32 attributes;/* (F) attributes */ -u32 reserved3[16 ]; -} __packed; - -#define BTREE_ATTR_BADCLOSE 0x00000001/* b-tree not closed properly. not -used by hfsplus. */ -#define HFS_TREE_BIGKEYS 0x00000002/* key length is u16 instead of u8. -used by hfsplus. */ -#define HFS_TREE_VARIDXKEYS 0x00000004/* variable key length instead of -max key length. use din catalog -b-tree but not in extents -b-tree (hfsplus). */
fs/hfs/hfs.h +1 -268
275 lines not on this page · raw message
fs/hfs/hfs_fs.h +0 -1
@@ -18,7 +18,6 @@#include <asm/byteorder.h> #include <linux/uaccess.h> -#include <linux/hfs_common.h> #include "hfs.h"
fs/hfsplus/hfsplus_fs.h +0 -1
@@ -16,7 +16,6 @@#include <linux/buffer_head.h> #include <linux/blkdev.h> #include <linux/fs_context.h> -#include <linux/hfs_common.h> #include "hfsplus_raw.h" /* Runtime config options */
fs/hfsplus/hfsplus_raw.h +1 -393
399 lines not on this page · raw message
fs/hfsplus/xattr.c +10 -12
@@ -265,10 +265,8 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,struct hfs_find_data cat_fd;hfsplus_cat_entry entry;u16 cat_entry_flags, cat_entry_type; -u16 folder_finderinfo_len =sizeof (struct DInfo ) + -sizeof (struct DXInfo ); -u16 file_finderinfo_len =sizeof (struct FInfo ) + -sizeof (struct FXInfo ); +u16 folder_finderinfo_len =sizeof (DInfo) +sizeof (DXInfo); +u16 file_finderinfo_len =sizeof (FInfo) +sizeof (FXInfo); if ((!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) ||
@@ -444,11 +442,11 @@ static ssize_t hfsplus_getxattr_finder_info(struct inode *inode,ssize_t res =0 ;struct hfs_find_data fd;u16 entry_type; -u16 folder_rec_len =sizeof (struct DInfo ) +sizeof (struct DXInfo ); -u16 file_rec_len =sizeof (struct FInfo ) +sizeof (struct FXInfo ); +u16 folder_rec_len =sizeof (DInfo) +sizeof (DXInfo); +u16 file_rec_len =sizeof (FInfo) +sizeof (FXInfo);u16 record_len =max (folder_rec_len, file_rec_len); -u8 folder_finder_info[sizeof (struct DInfo ) +sizeof (struct DXInfo )]; -u8 file_finder_info[sizeof (struct FInfo ) +sizeof (struct FXInfo )]; +u8 folder_finder_info[sizeof (DInfo) +sizeof (DXInfo)]; +u8 file_finder_info[sizeof (FInfo) +sizeof (FXInfo)];if (size >= record_len) { res =hfs_find_init (HFSPLUS_SB (inode->i_sb)->cat_tree, &fd);
@@ -612,8 +610,8 @@ static ssize_t hfsplus_listxattr_finder_info(struct dentry *dentry,struct inode *inode =d_inode (dentry);struct hfs_find_data fd;u16 entry_type; -u8 folder_finder_info[sizeof (struct DInfo ) +sizeof (struct DXInfo )]; -u8 file_finder_info[sizeof (struct FInfo ) +sizeof (struct FXInfo )]; +u8 folder_finder_info[sizeof (DInfo) +sizeof (DXInfo)]; +u8 file_finder_info[sizeof (FInfo) +sizeof (FXInfo)];unsigned long len, found_bit;int xattr_name_len, symbols_count;
@@ -629,14 +627,14 @@ static ssize_t hfsplus_listxattr_finder_info(struct dentry *dentry, entry_type =hfs_bnode_read_u16 (fd.bnode, fd.entryoffset);if (entry_type ==HFSPLUS_FOLDER ) { - len =sizeof (struct DInfo ) +sizeof (struct DXInfo ); + len =sizeof (DInfo) +sizeof (DXInfo);hfs_bnode_read (fd.bnode, folder_finder_info, fd.entryoffset + offsetof(struct hfsplus_cat_folder , user_info), len); found_bit =find_first_bit ((void *)folder_finder_info, len*8 ); }else if (entry_type ==HFSPLUS_FILE ) { - len =sizeof (struct FInfo ) +sizeof (struct FXInfo ); + len =sizeof (FInfo) +sizeof (FXInfo); hfs_bnode_read(fd.bnode, file_finder_info, fd.entryoffset + offsetof(struct hfsplus_cat_file, user_info),
include/linux/hfs_common.h +633 -0
637 lines not on this page · raw message
Signature · 1 line
2.43.0