Skip to contentSkip to conversation

hfsplus: implement attributes file creation functionality

PATCH In review Vyacheslav Dubeyko 2 participants 2 messages Sep 30, 2013

Subsystems (2)
lore
Share & tools
lore

Vyacheslav Dubeyko

author maintainer
#0 lore raw

PATCH v2 3/3 hfsplus: implement attributes file creation functionality

From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH v2 3/3] hfsplus: implement attributes file creation functionality

This patch implements functionality of creation AttributesFile metadata file on HFS+ volume in the case of absence of it.

It makes trying to open AttributesFile's B-tree during mount of HFS+ volume. If HFS+ volume hasn't AttributesFile then a pointer on AttributesFile's B-tree keeps as NULL. Thereby, when it is discovered absence of AttributesFile on HFS+ volume in the begin of xattr creation operation then AttributesFile will be created.

The creation of AttributesFile will have success in the case of availability (2 * clump) free blocks on HFS+ volume. Otherwise, creation operation is ended with error (-ENOSPC).

CC Al Viro <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Hin-Tak Leung <[email protected]>
---
 fs/hfsplus/hfsplus_fs.h |    9 +++
 fs/hfsplus/super.c      |    2 +
 fs/hfsplus/xattr.c      |  142 ++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 151 insertions(+), 2 deletions(-)
fs/hfsplus/hfsplus_fs.h +9 -0
index 1e36f18..08846425b 100644
@@ -127,6 +127,14 @@ struct hfs_bnode {
 #define HFS_BNODE_DELETED	4
 
 /*
+ * Attributes file states
+ */
+#define HFSPLUS_EMPTY_ATTR_TREE		0
+#define HFSPLUS_CREATING_ATTR_TREE	1
+#define HFSPLUS_VALID_ATTR_TREE		2
+#define HFSPLUS_FAILED_ATTR_TREE	3
+
+/*
  * HFS+ superblock info (built from Volume Header on disk)
  */
 
@@ -141,6 +149,7 @@ struct hfsplus_sb_info {
 	struct hfs_btree *ext_tree;
 	struct hfs_btree *cat_tree;
 	struct hfs_btree *attr_tree;
+	atomic_t attr_tree_state;
 	struct inode *alloc_file;
 	struct inode *hidden_dir;
 	struct nls_table *nls;
fs/hfsplus/super.c +2 -0
index 4c4d142..80875aa 100644
@@ -474,12 +474,14 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 		pr_err("failed to load catalog file\n");
 		goto out_close_ext_tree;
 	}
+	atomic_set(&sbi->attr_tree_state, HFSPLUS_EMPTY_ATTR_TREE);
 	if (vhdr->attr_file.total_blocks != 0) {
 		sbi->attr_tree = hfs_btree_open(sb, HFSPLUS_ATTR_CNID);
 		if (!sbi->attr_tree) {
 			pr_err("failed to load attributes file\n");
 			goto out_close_cat_tree;
 		}
+		atomic_set(&sbi->attr_tree_state, HFSPLUS_VALID_ATTR_TREE);
 	}
 	sb->s_xattr = hfsplus_xattr_handlers;
 
fs/hfsplus/xattr.c +140 -2

154 lines not on this page · raw message

Signature · 1 line
1.7.9.5
Acked-by on v2 3/3
#1 lore raw

--------------------------------------------
On Mon, 30/9/13, Vyacheslav Dubeyko <[email protected]> wrote:

Subject: [PATCH v2 3/3] hfsplus: implement attributes file creation functionality
To: "Linux FS devel list" <[email protected]>
Cc: "Al Viro" <[email protected]>, "Christoph Hellwig" <[email protected]>, "Hin-Tak Leung" <[email protected]>, "Andrew Morton" <[email protected]>, "Fengguang Wu" <[email protected]>
Date: Monday, 30 September, 2013, 9:05

From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH v2 3/3] hfsplus: implement attributes file creation functionality

This patch implements functionality of creation AttributesFile
metadata file on HFS+ volume in the case of absence of it.

It makes trying to open AttributesFile's B-tree during mount of
HFS+ volume. If HFS+ volume hasn't AttributesFile then a pointer
on AttributesFile's B-tree keeps as NULL. Thereby, when it is
discovered absence of AttributesFile on HFS+ volume in the begin
of xattr creation operation then AttributesFile will be created.

The creation of AttributesFile will have success in the case of
availability (2 * clump) free blocks on HFS+ volume. Otherwise,
creation operation is ended with error (-ENOSPC).

CC Al Viro <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Hin-Tak Leung <[email protected]>