Port-amiga archive

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

Re: ADOSFS reading corrupted data



On Sat Dec 21 2002 at 07:50:56 +0200, Ilpo Ruotsalainen wrote:
> And the attached patch is the fix (works for me, YMMV but please someone
> test it before I commit it ;).

And this time it's really attached, honestly. (Too tired, almost 8am.)

-- 
Ilpo Ruotsalainen - <lonewolf%iki.fi@localhost> - http://www.iki.fi/lonewolf/
Index: advnops.c
===================================================================
RCS file: /cvsroot/src/sys/adosfs/advnops.c,v
retrieving revision 1.62
diff --unified -r1.62 advnops.c
--- advnops.c   2001/11/12 22:59:18     1.62
+++ advnops.c   2002/12/21 05:43:04
@@ -311,8 +311,7 @@
                 * but not much as ados makes little attempt to 
                 * make things contigous
                 */
-               error = bread(sp->a_vp, lbn * amp->bsize / DEV_BSIZE,
-                             amp->bsize, NOCRED, &bp);
+               error = bread(sp->a_vp, lbn, amp->bsize, NOCRED, &bp);
                if (error) {
                        brelse(bp);
                        goto reterr;
@@ -474,14 +473,12 @@
        struct buf *flbp;
        long nb, flblk, flblkoff, fcnt;
        daddr_t *bnp;
-       daddr_t bn;
        int error; 
 
 #ifdef ADOSFS_DIAGNOSTIC
        advopprint(sp);
 #endif
        ap = VTOA(sp->a_vp);
-       bn = sp->a_bn / (ap->amp->bsize / DEV_BSIZE);
        bnp = sp->a_bnp;
        if (sp->a_runp) {
                *sp->a_runp = 0;
@@ -492,7 +489,7 @@
                *sp->a_vpp = ap->amp->devvp;
        if (bnp == NULL)
                goto reterr;
-       if (bn < 0) {
+       if (sp->a_bn < 0) {
                error = EFBIG;
                goto reterr;
        }
@@ -514,7 +511,7 @@
                goto reterr;
        }
 
-       flblk = bn / ANODENDATBLKENT(ap);
+       flblk = sp->a_bn / ANODENDATBLKENT(ap);
        flbp = NULL;
 
        /*
@@ -565,14 +562,14 @@
         * at nwords - 51 and goes to offset 6 or less if indicated by the
         * valid table entries stored at offset ADBI_NBLKTABENT.
         */
-       flblkoff = bn % ANODENDATBLKENT(ap);
+       flblkoff = sp->a_bn % ANODENDATBLKENT(ap);
        if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) {
                flblkoff = (ap->nwords - 51) - flblkoff;
                *bnp = adoswordn(flbp, flblkoff) * ap->amp->bsize / DEV_BSIZE;
        } else {
 #ifdef DIAGNOSTIC
                printf("flblk offset %ld too large in lblk %ld blk %d\n", 
-                   flblkoff, bn / (ap->amp->bsize / DEV_BSIZE), flbp->b_blkno);
+                   flblkoff, sp->a_bn / (ap->amp->bsize / DEV_BSIZE), 
flbp->b_blkno);
 #endif
                error = EINVAL;
        }
@@ -580,8 +577,8 @@
 reterr:
 #ifdef ADOSFS_DIAGNOSTIC
        if (error == 0 && bnp)
-               printf(" %d => %d", bn, *bnp);
-       printf(" %d)", error);
+               printf(" %d => %d", sp->a_bn, *bnp);
+       printf(" %d)\n", error);
 #endif
        return(error);
 }


Home | Main Index | Thread Index | Old Index