Subject: Re: mount failure on small NetBSD
To: Jachym Holecek <freza@liberouter.org>
From: fab <fab@gnux.info>
List: tech-embed
Date: 08/10/2005 20:39:59
> Weird. The manpage seems to suggest that EINVAL is specific
> to UFS

:(

> > I'll try to rm all the objs and recompile, maybe it's a compilation
> > mistake.
> > The kernel is ~2 weeks newer than the userland, can it come from this ?
> 
> It shouldn't, but it's worth the try. If this doesn't fix the problem,
> you can try adding printf's into msdos mount function (one could also
> use ddb to trace this -- though I don't know the exact commands).

I don't know if ddb is small enough for the memory (I only have 13kB
free...)
I'm not used to hack netbsd code, I found some interesting functions in
msdosfs_vfsops.c, must I printf() both to see what's happening ?
Here is a sample of interesting (I hope) parts:

int msdosfs_mount(mp, path, data, ndp, p):
[...]
        vrele(devvp);
        if (devvp != pmp->pm_devvp)
            return (EINVAL);    /* needs translation */
[...]

and

int msdosfs_mountfs(devvp, mp, p, argp):
        if (bsize != 512 || (dtype!=DTYPE_FLOPPY && tmp!=FS_MSDOS)) {
            error = EINVAL;
            goto error_exit;
        }
[...]
    if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
        if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
            || bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
            error = EINVAL;
            goto error_exit;
        }
    }
[...]
    if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
        /* XXX - We should probably check more values here */
            if (!pmp->pm_BytesPerSec || !SecPerClust
                || pmp->pm_Heads > 255 || pmp->pm_SecPerTrack > 63) {
            error = EINVAL;
            goto error_exit;
        }
    }
[...]
    if (pmp->pm_HugeSectors > 0xffffffff / dirsperblk + 1) {
        /*
         * We cannot deal currently with this size of disk
         * due to fileid limitations (see msdosfs_getattr and
         * msdosfs_readdir)
         */
        error = EINVAL;
        goto error_exit;
    }
    if (pmp->pm_RootDirEnts == 0) {
        if (bsp->bs710.bsBootSectSig2 != BOOTSIG2
            || bsp->bs710.bsBootSectSig3 != BOOTSIG3
            || pmp->pm_Sectors
            || pmp->pm_FATsecs
            || getushort(b710->bpbFSVers)) {
            error = EINVAL;
            goto error_exit;
        }
[...]
    if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
        if (FAT32(pmp)) {
            /*
             * GEMDOS doesn't know fat32.
             */
            error = EINVAL;
            goto error_exit;
        }
[...]
        if ( (SecPerClust == 0)
          || (SecPerClust & (SecPerClust - 1))
          || (pmp->pm_BytesPerSec < bsize)
          || (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1))
          || (pmp->pm_HugeSectors == 0)
          || (pmp->pm_HugeSectors * (pmp->pm_BytesPerSec / bsize)
                            > dpart.part->p_size)
           ) {
            error = EINVAL;
            goto error_exit;
        }
[...]
    if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) {
        error = EINVAL;
        goto error_exit;
    }


Best Regards.

-- 
Fabien Devaux

     Personal page: http://fab.gnux.info
 Free Software Art: http://art.gnux.info
     Server's home: http://gnux.info