提交 af8c85bb 编写于 作者: R Roman Zippel 提交者: Linus Torvalds

[PATCH] hfs: set correct create date for links

HFS+ also requires the correct creation date so recent version of OS X
recognize it as link.
Improve link handling:
- if something is wrong with the link, ignore the link attribute and treat
  it as regular file (this also fixes a missing unlock during lookup).
- check for incorrect link counts during unlink.
Signed-off-by: NRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 9a4cad95
...@@ -127,6 +127,7 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i ...@@ -127,6 +127,7 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE); file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE);
file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR); file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR);
file->user_info.fdFlags = cpu_to_be16(0x100); file->user_info.fdFlags = cpu_to_be16(0x100);
file->create_date = HFSPLUS_I(HFSPLUS_SB(inode->i_sb).hidden_dir).create_date;
file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev); file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev);
} }
return sizeof(*file); return sizeof(*file);
......
...@@ -66,21 +66,28 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry, ...@@ -66,21 +66,28 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
} }
cnid = be32_to_cpu(entry.file.id); cnid = be32_to_cpu(entry.file.id);
if (entry.file.user_info.fdType == cpu_to_be32(HFSP_HARDLINK_TYPE) && if (entry.file.user_info.fdType == cpu_to_be32(HFSP_HARDLINK_TYPE) &&
entry.file.user_info.fdCreator == cpu_to_be32(HFSP_HFSPLUS_CREATOR)) { entry.file.user_info.fdCreator == cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
(entry.file.create_date == HFSPLUS_I(HFSPLUS_SB(sb).hidden_dir).create_date ||
entry.file.create_date == HFSPLUS_I(sb->s_root->d_inode).create_date) &&
HFSPLUS_SB(sb).hidden_dir) {
struct qstr str; struct qstr str;
char name[32]; char name[32];
if (dentry->d_fsdata) { if (dentry->d_fsdata) {
err = -ENOENT; /*
inode = NULL; * We found a link pointing to another link,
goto out; * so ignore it and treat it as regular file.
*/
cnid = (unsigned long)dentry->d_fsdata;
linkid = 0;
} else {
dentry->d_fsdata = (void *)(unsigned long)cnid;
linkid = be32_to_cpu(entry.file.permissions.dev);
str.len = sprintf(name, "iNode%d", linkid);
str.name = name;
hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_SB(sb).hidden_dir->i_ino, &str);
goto again;
} }
dentry->d_fsdata = (void *)(unsigned long)cnid;
linkid = be32_to_cpu(entry.file.permissions.dev);
str.len = sprintf(name, "iNode%d", linkid);
str.name = name;
hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_SB(sb).hidden_dir->i_ino, &str);
goto again;
} else if (!dentry->d_fsdata) } else if (!dentry->d_fsdata)
dentry->d_fsdata = (void *)(unsigned long)cnid; dentry->d_fsdata = (void *)(unsigned long)cnid;
} else { } else {
...@@ -330,7 +337,8 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry) ...@@ -330,7 +337,8 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
if (res) if (res)
return res; return res;
inode->i_nlink--; if (inode->i_nlink > 0)
inode->i_nlink--;
hfsplus_delete_inode(inode); hfsplus_delete_inode(inode);
if (inode->i_ino != cnid && !inode->i_nlink) { if (inode->i_ino != cnid && !inode->i_nlink) {
if (!atomic_read(&HFSPLUS_I(inode).opencnt)) { if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
...@@ -339,7 +347,8 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry) ...@@ -339,7 +347,8 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
hfsplus_delete_inode(inode); hfsplus_delete_inode(inode);
} else } else
inode->i_flags |= S_DEAD; inode->i_flags |= S_DEAD;
} } else
inode->i_nlink = 0;
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode); mark_inode_dirty(inode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册