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 * ...@@ -101,11 +101,11 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
if (err != -ENOENT) { if (err != -ENOENT) {
if (!err) if (!err)
err = -EEXIST; err = -EEXIST;
goto out; goto err2;
} }
err = hfs_brec_insert(&fd, &entry, entry_size); err = hfs_brec_insert(&fd, &entry, entry_size);
if (err) if (err)
goto out; goto err2;
hfs_cat_build_key(fd.search_key, dir->i_ino, str); hfs_cat_build_key(fd.search_key, dir->i_ino, str);
entry_size = hfs_cat_build_record(&entry, cnid, inode); 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 * ...@@ -114,16 +114,23 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
/* panic? */ /* panic? */
if (!err) if (!err)
err = -EEXIST; err = -EEXIST;
goto out; goto err1;
} }
err = hfs_brec_insert(&fd, &entry, entry_size); err = hfs_brec_insert(&fd, &entry, entry_size);
if (!err) { if (err)
dir->i_size++; goto err1;
mark_inode_dirty(dir);
} dir->i_size++;
out: mark_inode_dirty(dir);
hfs_find_exit(&fd); 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; return err;
} }
......
...@@ -165,11 +165,11 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino ...@@ -165,11 +165,11 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino
if (err != -ENOENT) { if (err != -ENOENT) {
if (!err) if (!err)
err = -EEXIST; err = -EEXIST;
goto out; goto err2;
} }
err = hfs_brec_insert(&fd, &entry, entry_size); err = hfs_brec_insert(&fd, &entry, entry_size);
if (err) if (err)
goto out; goto err2;
hfsplus_cat_build_key(fd.search_key, dir->i_ino, str); hfsplus_cat_build_key(fd.search_key, dir->i_ino, str);
entry_size = hfsplus_cat_build_record(&entry, cnid, inode); 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 ...@@ -178,16 +178,23 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct ino
/* panic? */ /* panic? */
if (!err) if (!err)
err = -EEXIST; err = -EEXIST;
goto out; goto err1;
} }
err = hfs_brec_insert(&fd, &entry, entry_size); err = hfs_brec_insert(&fd, &entry, entry_size);
if (!err) { if (err)
dir->i_size++; goto err1;
mark_inode_dirty(dir);
} dir->i_size++;
out: mark_inode_dirty(dir);
hfs_find_exit(&fd); 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; 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