Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amiga/amiga Handle RDB ( Amiga native ) partition t...



details:   https://anonhg.NetBSD.org/src/rev/46f7aa445667
branches:  trunk
changeset: 473418:46f7aa445667
user:      is <is%NetBSD.org@localhost>
date:      Wed Jun 02 21:09:03 1999 +0000

description:
Handle RDB ( Amiga native ) partition tables on media with more than 512
bytes/sector correctly.
Submitted by Detlev W?rkner in PR 7653.
Non-trivial merge with the 1.30 change (handle old AmigaDOS fs partitions
with simulated sectorsperblock > 1) by myself, so don't blame Detlev if it
doesn't work (but I checked!).
XXX We still need changes to the file systems to handle this fully.

diffstat:

 sys/arch/amiga/amiga/disksubr.c |  60 +++++++++++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 17 deletions(-)

diffs (118 lines):

diff -r 9f0f381bb9f5 -r 46f7aa445667 sys/arch/amiga/amiga/disksubr.c
--- a/sys/arch/amiga/amiga/disksubr.c   Wed Jun 02 18:47:11 1999 +0000
+++ b/sys/arch/amiga/amiga/disksubr.c   Wed Jun 02 21:09:03 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.30 1999/05/30 21:21:36 is Exp $ */
+/*     $NetBSD: disksubr.c,v 1.31 1999/06/02 21:09:03 is Exp $ */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -43,6 +43,18 @@
 #include <amiga/amiga/adosglue.h>
 
 /*
+ * In /usr/src/sys/dev/scsipi/sd.c, routine sdstart() adjusts the
+ * block numbers, it changes from DEV_BSIZE units to physical units:
+ * blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
+ * As long as media with sector sizes of 512 bytes are used, this
+ * doesn't matter (divide by 1), but for successfull usage of media with
+ * greater sector sizes (e.g. 640MB MO-media with 2048 bytes/sector)
+ * we must multiply block numbers with (lp->d_secsize / DEV_BSIZE)
+ * to keep "unchanged" physical block numbers.
+ */
+#define SD_C_ADJUSTS_NR
+
+/*
  * bitmap id's
  */
 #define RDBLOCK_BID    1
@@ -153,6 +165,9 @@
                bp->b_cylin = bp->b_blkno / lp->d_secpercyl;
                bp->b_bcount = lp->d_secsize;
                bp->b_flags = B_BUSY | B_READ;
+#ifdef SD_C_ADJUSTS_NR
+               bp->b_blkno *= (lp->d_secsize / DEV_BSIZE);
+#endif
                strat(bp);
 
                if (biowait(bp)) {
@@ -244,6 +259,9 @@
                bp->b_cylin = bp->b_blkno / lp->d_secpercyl;
                bp->b_bcount = lp->d_secsize;
                bp->b_flags = B_BUSY | B_READ;
+#ifdef SD_C_ADJUSTS_NR
+               bp->b_blkno *= (lp->d_secsize / DEV_BSIZE);
+#endif
                strat(bp);
                
                if (biowait(bp)) {
@@ -362,30 +380,35 @@
 
                pp->p_size = (pbp->e.highcyl - pbp->e.lowcyl + 1)
                    * pbp->e.secpertrk * pbp->e.numheads
-                   * (pbp->e.sizeblock >> 7);
+                   * ((pbp->e.sizeblock << 2) / lp->d_secsize);
                pp->p_offset = pbp->e.lowcyl * pbp->e.secpertrk
                    * pbp->e.numheads
-                   * (pbp->e.sizeblock >> 7);
+                   * ((pbp->e.sizeblock << 2) / lp->d_secsize);
                pp->p_fstype = adt.fstype;
                if (adt.archtype == ADT_AMIGADOS) {
                        /*
                         * Save reserved blocks at begin in cpg and
                         *  adjust size by reserved blocks at end
                         */
-                       int bsize,secperblk;
+                       int bsize, secperblk, minbsize, prefac;
+
+                       minbsize = max(512, lp->d_secsize);
 
-                       bsize = pbp->e.sizeblock << 2;
+                       bsize     = pbp->e.sizeblock << 2;
                        secperblk = pbp->e.secperblk;
-                       while (bsize > 512) {
+                       prefac    = pbp->e.prefac;
+
+                       while (bsize > minbsize) {
                                bsize >>= 1;
                                secperblk <<= 1;
+                               prefac <<= 1;
                        }
-                       if (bsize == 512) {
+
+                       if (bsize == minbsize) {
                                pp->p_fsize = bsize;
                                pp->p_frag = secperblk;
                                pp->p_cpg = pbp->e.resvblocks;
-                               pp->p_size -= pbp->e.prefac
-                                             * (pbp->e.sizeblock >> 7);
+                               pp->p_size -= prefac;
                        } else {
                                adt.archtype = ADT_UNKNOWN;
                                adt.fstype = FS_UNUSED;
@@ -501,14 +524,17 @@
        long maxsz, sz;
 
        pp = &lp->d_partitions[DISKPART(bp->b_dev)];
-       if (bp->b_flags & B_RAW) {
-               maxsz = pp->p_size * (lp->d_secsize / DEV_BSIZE);
-               sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-       } else {
-               maxsz = pp->p_size;
-               sz = (bp->b_bcount + lp->d_secsize - 1) / lp->d_secsize;
-       }
-
+       /*
+        * This routine is called before sd.c adjusts block numbers
+        * and must take this into account
+        */
+#ifdef SD_C_ADJUSTS_NR
+       maxsz = pp->p_size * (lp->d_secsize / DEV_BSIZE);
+       sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
+#else
+       maxsz = pp->p_size;
+       sz = (bp->b_bcount + lp->d_secsize - 1) / lp->d_secsize;
+#endif
        if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
                if (bp->b_blkno == maxsz) {
                        /* 



Home | Main Index | Thread Index | Old Index