From 2cd282a1bc6b9d111b8beee63bea0af735a8a1aa Mon Sep 17 00:00:00 2001 From: Sergei Antonov Date: Fri, 6 Jun 2014 14:36:28 -0700 Subject: hfsplus: fix "unused node is not erased" error Zero newly allocated extents in the catalog tree if volume attributes tell us to. Not doing so we risk getting the "unused node is not erased" error. See kHFSUnusedNodeFix flag in Apple's source code for reference. There was a previous commit clearing the node when it is freed: commit 899bed05e9f6 ("hfsplus: fix issue with unzeroed unused b-tree nodes"). But it did not handle newly allocated extents (this patch fixes it). And it zeroed nodes in all trees unconditionally which is an overkill. This patch adds a condition and also switches to 'tree->node_size' as a simpler method of getting the length to zero. Signed-off-by: Sergei Antonov Cc: Anton Altaparmakov Cc: Al Viro Cc: Christoph Hellwig Cc: Vyacheslav Dubeyko Cc: Hin-Tak Leung Cc: Kyle Laracey Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/hfsplus/hfsplus_raw.h | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/hfsplus/hfsplus_raw.h') diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h index 5a126828d85e..8298d0985f81 100644 --- a/fs/hfsplus/hfsplus_raw.h +++ b/fs/hfsplus/hfsplus_raw.h @@ -144,6 +144,7 @@ struct hfsplus_vh { #define HFSPLUS_VOL_NODEID_REUSED (1 << 12) #define HFSPLUS_VOL_JOURNALED (1 << 13) #define HFSPLUS_VOL_SOFTLOCK (1 << 15) +#define HFSPLUS_VOL_UNUSED_NODE_FIX (1 << 31) /* HFS+ BTree node descriptor */ struct hfs_bnode_desc { -- cgit v1.2.3