Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: fsck_ext2fs coredump



On Fri, Sep 02, 2011 at 08:02:48PM +0900, Izumi Tsutsui wrote:
> > BAD SUPER BLOCK: INCOMPATIBLE FEATURE BITS IN SUPER BLOCK
> 
> IMO fsck_ext2fs(8) should not proceed checks in this case.

The incompatible feature bits make readsb return 0, so

        if (readsb(1) == 0) {
                if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
                        return 0;

calcsb then gets called and coredumps. The bcount calculation is the only
one which could get a division by zero, so maybe the attached would do?

I get:

# fsck /dev/rwd1f
fsck: Cannot open `/etc/fstab': No such file or directory
fsck: Cannot open `/etc/fstab': No such file or directory
** /dev/rwd1f
BAD SUPER BLOCK: INCOMPATIBLE FEATURE BITS IN SUPER BLOCK
/dev/rwd1f: READ ZERO BLOCK SIZE
#

avoiding the coredump with the patch...

> > Should I conclude that all the super blocks just contain zeros and this
> > disk is beyond rescue?
> 
> I think it's much easier to use e2fsprogs from pkgsrc packages binary
> for native Linux fs.

Thanks - I'll try that...

Cheers,

Patrick
diff --git a/setup.c b/setup.c
index 5871a16..ef07467 100644
--- a/setup.c
+++ b/setup.c
@@ -490,6 +490,10 @@ calcsb(const char *dev, int devfd, struct m_ext2fs *fs)
                    fstypenames[pp->p_fstype] : "unknown");
                return 0;
        }
+       if (fs->e2fs_bsize == 0) {
+               pfatal("%s: READ ZERO BLOCK SIZE\n", dev);
+               return 0;
+       }
        memset(fs, 0, sizeof(struct m_ext2fs));
        fs->e2fs_bsize = pp->p_fsize;
        fs->e2fs.e2fs_log_bsize = pp->p_fsize / 1024;


Home | Main Index | Thread Index | Old Index