summaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/hfsplus_fs.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@tuxera.com>2010-10-14 15:54:28 +0200
committerChristoph Hellwig <hch@lst.de>2010-10-14 15:54:28 +0200
commitf6089ff87d309a8ddb7b0d4dd92a570f1b0f689b (patch)
tree9b2c6b43885899e055e7b64b88e12bf3759e3794 /fs/hfsplus/hfsplus_fs.h
parenthfsplus: validate btree flags (diff)
downloadlinux-f6089ff87d309a8ddb7b0d4dd92a570f1b0f689b.tar.xz
linux-f6089ff87d309a8ddb7b0d4dd92a570f1b0f689b.zip
hfsplus: fix link corruption
HFS implements hardlink by using indirect catalog entries that refer to a hidden directly. The link target is cached in the dev field in the HFS+ specific inode, which is also used for the device number for device files, and inside for passing the nlink value of the indirect node from hfsplus_cat_write_inode to a helper function. Now if we happen to write out the indirect node while hfsplus_link is creating the catalog entry we'll get a link pointing to the linkid of the current nlink value. This can easily be reproduced by a large enough loop of local git-clone operations. Stop abusing the dev field in the HFS+ inode for short term storage by refactoring the way the permission structure in the catalog entry is set up, and rename the dev field to linkid to avoid any confusion. While we're at it also prevent creating hard links to special files, as the HFS+ dev and linkid share the same space in the on-disk structure. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus/hfsplus_fs.h')
-rw-r--r--fs/hfsplus/hfsplus_fs.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 5cda96366acf..d92f590d6633 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -178,7 +178,11 @@ struct hfsplus_inode_info {
*/
struct inode *rsrc_inode;
__be32 create_date;
- u32 dev;
+
+ /*
+ * Protected by sbi->vh_mutex.
+ */
+ u32 linkid;
/*
* Protected by i_mutex.
@@ -427,6 +431,4 @@ static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
#define hfsp_ut2mt(t) __hfsp_ut2mt((t).tv_sec)
#define hfsp_now2mt() __hfsp_ut2mt(get_seconds())
-#define kdev_t_to_nr(x) (x)
-
#endif