Commit a0003bd2 authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] hfs: write back resource info directly

Write back the information for a dirty resource inode directly and not via the
main inode, as at the time the latter is written the former might already be
gone.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0e7fc0b7
......@@ -386,6 +386,7 @@ void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext,
int hfs_write_inode(struct inode *inode, int unused)
{
struct inode *main_inode = inode;
struct hfs_find_data fd;
hfs_cat_rec rec;
......@@ -408,24 +409,22 @@ int hfs_write_inode(struct inode *inode, int unused)
}
}
if (HFS_IS_RSRC(inode)) {
mark_inode_dirty(HFS_I(inode)->rsrc_inode);
return 0;
}
if (HFS_IS_RSRC(inode))
main_inode = HFS_I(inode)->rsrc_inode;
if (!inode->i_nlink)
if (!main_inode->i_nlink)
return 0;
if (hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd))
if (hfs_find_init(HFS_SB(main_inode->i_sb)->cat_tree, &fd))
/* panic? */
return -EIO;
fd.search_key->cat = HFS_I(inode)->cat_key;
fd.search_key->cat = HFS_I(main_inode)->cat_key;
if (hfs_brec_find(&fd))
/* panic? */
goto out;
if (S_ISDIR(inode->i_mode)) {
if (S_ISDIR(main_inode->i_mode)) {
if (fd.entrylength < sizeof(struct hfs_cat_dir))
/* panic? */;
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
......@@ -439,6 +438,13 @@ int hfs_write_inode(struct inode *inode, int unused)
hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
sizeof(struct hfs_cat_dir));
} else if (HFS_IS_RSRC(inode)) {
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
sizeof(struct hfs_cat_file));
hfs_inode_write_fork(inode, rec.file.RExtRec,
&rec.file.RLgLen, &rec.file.RPyLen);
hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
sizeof(struct hfs_cat_file));
} else {
if (fd.entrylength < sizeof(struct hfs_cat_file))
/* panic? */;
......@@ -453,9 +459,6 @@ int hfs_write_inode(struct inode *inode, int unused)
else
rec.file.Flags |= HFS_FIL_LOCK;
hfs_inode_write_fork(inode, rec.file.ExtRec, &rec.file.LgLen, &rec.file.PyLen);
if (HFS_I(inode)->rsrc_inode)
hfs_inode_write_fork(HFS_I(inode)->rsrc_inode, rec.file.RExtRec,
&rec.file.RLgLen, &rec.file.RPyLen);
rec.file.MdDat = hfs_u_to_mtime(inode->i_mtime);
hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
......
......@@ -489,26 +489,25 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
int hfsplus_cat_write_inode(struct inode *inode)
{
struct inode *main_inode = inode;
struct hfs_find_data fd;
hfsplus_cat_entry entry;
if (HFSPLUS_IS_RSRC(inode)) {
mark_inode_dirty(HFSPLUS_I(inode).rsrc_inode);
return 0;
}
if (HFSPLUS_IS_RSRC(inode))
main_inode = HFSPLUS_I(inode).rsrc_inode;
if (!inode->i_nlink)
if (!main_inode->i_nlink)
return 0;
if (hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd))
if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb).cat_tree, &fd))
/* panic? */
return -EIO;
if (hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd))
if (hfsplus_find_cat(main_inode->i_sb, main_inode->i_ino, &fd))
/* panic? */
goto out;
if (S_ISDIR(inode->i_mode)) {
if (S_ISDIR(main_inode->i_mode)) {
struct hfsplus_cat_folder *folder = &entry.folder;
if (fd.entrylength < sizeof(struct hfsplus_cat_folder))
......@@ -523,6 +522,13 @@ int hfsplus_cat_write_inode(struct inode *inode)
folder->valence = cpu_to_be32(inode->i_size - 2);
hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
sizeof(struct hfsplus_cat_folder));
} else if (HFSPLUS_IS_RSRC(inode)) {
struct hfsplus_cat_file *file = &entry.file;
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
sizeof(struct hfsplus_cat_file));
hfsplus_inode_write_fork(inode, &file->rsrc_fork);
hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
sizeof(struct hfsplus_cat_file));
} else {
struct hfsplus_cat_file *file = &entry.file;
......@@ -531,8 +537,6 @@ int hfsplus_cat_write_inode(struct inode *inode)
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
sizeof(struct hfsplus_cat_file));
hfsplus_inode_write_fork(inode, &file->data_fork);
if (HFSPLUS_I(inode).rsrc_inode)
hfsplus_inode_write_fork(HFSPLUS_I(inode).rsrc_inode, &file->rsrc_fork);
if (S_ISREG(inode->i_mode))
HFSPLUS_I(inode).dev = inode->i_nlink;
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment