mtd/fs/jffs2 dir.c,1.45.2.6,1.45.2.7
David Woodhouse
dwmw2 at infradead.org
Mon Aug 26 11:30:20 EDT 2002
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv31187
Modified Files:
Tag: jffs2-2_4-branch
dir.c
Log Message:
Don't oops on link/unlink/rename of bad inodes
Index: dir.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/dir.c,v
retrieving revision 1.45.2.6
retrieving revision 1.45.2.7
diff -u -r1.45.2.6 -r1.45.2.7
--- dir.c 20 Jun 2002 23:54:48 -0000 1.45.2.6
+++ dir.c 26 Aug 2002 15:30:18 -0000 1.45.2.7
@@ -404,8 +404,9 @@
jffs2_mark_node_obsolete(c, fd->raw);
jffs2_free_full_dirent(fd);
}
-
- f->inocache->nlink--;
+ /* Don't oops on unlinking a bad inode */
+ if (f->inocache)
+ f->inocache->nlink--;
dentry->d_inode->i_nlink--;
up(&f->sem);
}
@@ -489,6 +490,10 @@
{
int ret;
+ /* Can't link a bad inode. */
+ if (!JFFS2_INODE_INFO(old_dentry->d_inode)->inocache)
+ return -EIO;
+
if (S_ISDIR(old_dentry->d_inode->i_mode))
return -EPERM;
@@ -991,7 +996,8 @@
/* Oh shit. We really ought to make a single node which can do both atomically */
struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode);
down(&f->sem);
- old_dentry->d_inode->i_nlink = f->inocache->nlink++;
+ if (f->inocache)
+ old_dentry->d_inode->i_nlink = f->inocache->nlink++;
up(&f->sem);
printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret);
More information about the linux-mtd-cvs
mailing list