Commit 8fc4dec5 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] hfsplus: completely remove half inserted catalog entry

From: Roman Zippel <zippel@linux-m68k.org>

If the inserting of the file or dir record failed, remove the previously
inserted thread record.
parent d58fc33e
......@@ -101,11 +101,11 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
if (err != -ENOENT) {
if (!err)
err = -EEXIST;
goto out;
goto err2;
}
err = hfs_brec_insert(&fd, &entry, entry_size);
if (err)
goto out;
goto err2;
hfs_cat_build_key(fd.search_key, dir->i_ino, str);
entry_size = hfs_cat_build_record(&entry, cnid, inode);
......@@ -114,16 +114,23 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
/* panic? */
if (!err)
err = -EEXIST;
goto out;
goto err1;
}
err = hfs_brec_insert(&fd, &entry, entry_size);
if (!err) {
if (err)
goto err1;
dir->i_size++;
mark_inode_dirty(dir);
}
out:
hfs_find_exit(&fd);
return 0;
err1:
hfs_cat_build_key(fd.search_key, cnid, NULL);
if (!hfs_brec_find(&fd))
hfs_brec_remove(&fd);
err2:
hfs_find_exit(&fd);
return err;
}
......
......@@ -165,11 +165,11 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino
if (err != -ENOENT) {
if (!err)
err = -EEXIST;
goto out;
goto err2;
}
err = hfs_brec_insert(&fd, &entry, entry_size);
if (err)
goto out;
goto err2;
hfsplus_cat_build_key(fd.search_key, dir->i_ino, str);
entry_size = hfsplus_cat_build_record(&entry, cnid, inode);
......@@ -178,16 +178,23 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino
/* panic? */
if (!err)
err = -EEXIST;
goto out;
goto err1;
}
err = hfs_brec_insert(&fd, &entry, entry_size);
if (!err) {
if (err)
goto err1;
dir->i_size++;
mark_inode_dirty(dir);
}
out:
hfs_find_exit(&fd);
return 0;
err1:
hfsplus_cat_build_key(fd.search_key, cnid, NULL);
if (!hfs_brec_find(&fd))
hfs_brec_remove(&fd);
err2:
hfs_find_exit(&fd);
return err;
}
......
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