Page MenuHomeFreeBSD

D19323.diff
No OneTemporary

D19323.diff

Index: head/sys/fs/ext2fs/ext2_csum.c
===================================================================
--- head/sys/fs/ext2fs/ext2_csum.c
+++ head/sys/fs/ext2fs/ext2_csum.c
@@ -629,6 +629,8 @@
if (!memcmp(ei, &ei_zero, sizeof(struct ext2fs_dinode)))
return (0);
+ printf("WARNING: Bad inode %ju csum - run fsck\n", ip->i_number);
+
return (EIO);
}
Index: head/sys/fs/ext2fs/ext2_inode_cnv.c
===================================================================
--- head/sys/fs/ext2fs/ext2_inode_cnv.c
+++ head/sys/fs/ext2fs/ext2_inode_cnv.c
@@ -34,7 +34,6 @@
#include <sys/stat.h>
#include <sys/vnode.h>
-#include <fs/ext2fs/ext2fs.h>
#include <fs/ext2fs/fs.h>
#include <fs/ext2fs/inode.h>
#include <fs/ext2fs/ext2fs.h>
@@ -92,8 +91,31 @@
int
ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip)
{
+ struct m_ext2fs *fs = ip->i_e2fs;
+ if ((ip->i_number < EXT2_FIRST_INO(fs) && ip->i_number != EXT2_ROOTINO) ||
+ (ip->i_number < EXT2_ROOTINO) ||
+ (ip->i_number > fs->e2fs->e2fs_icount)) {
+ printf("ext2fs: bad inode number %ju\n", ip->i_number);
+ return (EINVAL);
+ }
+
+ if (ip->i_number == EXT2_ROOTINO && ei->e2di_nlink == 0) {
+ printf("ext2fs: root inode unallocated\n");
+ return (EINVAL);
+ }
ip->i_nlink = ei->e2di_nlink;
+
+ /* Check extra inode size */
+ if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) {
+ if (E2FS_REV0_INODE_SIZE + ei->e2di_extra_isize >
+ EXT2_INODE_SIZE(fs) || (ei->e2di_extra_isize & 3)) {
+ printf("ext2fs: bad extra inode size %u, inode size=%u\n",
+ ei->e2di_extra_isize, EXT2_INODE_SIZE(fs));
+ return (EINVAL);
+ }
+ }
+
/*
* Godmar thinks - if the link count is zero, then the inode is
* unused - according to ext2 standards. Ufs marks this fact by
Index: head/sys/fs/ext2fs/ext2_vfsops.c
===================================================================
--- head/sys/fs/ext2fs/ext2_vfsops.c
+++ head/sys/fs/ext2fs/ext2_vfsops.c
@@ -773,11 +773,18 @@
MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);
return (error);
}
- ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data +
+
+ error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data +
EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip);
+
brelse(bp);
VOP_UNLOCK(vp, 0);
vrele(vp);
+
+ if (error) {
+ MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);
+ return (error);
+ }
}
return (0);
}
@@ -1208,8 +1215,6 @@
error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data +
EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ino)), ip);
if (error) {
- printf("ext2fs: Bad inode %lu csum - run fsck\n",
- (unsigned long)ino);
brelse(bp);
vput(vp);
*vpp = NULL;
Index: head/sys/fs/ext2fs/ext2fs.h
===================================================================
--- head/sys/fs/ext2fs/ext2fs.h
+++ head/sys/fs/ext2fs/ext2fs.h
@@ -422,4 +422,11 @@
EXT2F_INCOMPAT_64BIT) ? ((s)->e2fs_bsize / sizeof(struct ext2_gd)) : \
((s)->e2fs_bsize / E2FS_REV0_GD_SIZE))
+/*
+ * Macro-instructions used to manage inodes
+ */
+#define EXT2_FIRST_INO(s) ((EXT2_SB(s)->e2fs->e2fs_rev == E2FS_REV0) ? \
+ EXT2_FIRSTINO : \
+ EXT2_SB(s)->e2fs->e2fs_first_ino)
+
#endif /* !_FS_EXT2FS_EXT2FS_H_ */

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 5:20 AM (12 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16355029
Default Alt Text
D19323.diff (3 KB)

Event Timeline