Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/newsmips/newsmips Sync with news68k:



details:   https://anonhg.NetBSD.org/src/rev/5450a0255d19
branches:  trunk
changeset: 581115:5450a0255d19
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed May 25 12:47:24 2005 +0000

description:
Sync with news68k:
- use MAKEDISKDEV() macro
- make readdisklabel(9) return more usable default label
- some cosmetics

diffstat:

 sys/arch/newsmips/newsmips/disksubr.c |  48 ++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diffs (132 lines):

diff -r 694d12e682e3 -r 5450a0255d19 sys/arch/newsmips/newsmips/disksubr.c
--- a/sys/arch/newsmips/newsmips/disksubr.c     Wed May 25 11:07:13 2005 +0000
+++ b/sys/arch/newsmips/newsmips/disksubr.c     Wed May 25 12:47:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.17 2005/02/06 02:18:02 tsutsui Exp $    */
+/*     $NetBSD: disksubr.c,v 1.18 2005/05/25 12:47:24 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.17 2005/02/06 02:18:02 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.18 2005/05/25 12:47:24 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,19 +50,30 @@
  * Returns null on success and an error string on failure.
  */
 const char *
-readdisklabel(dev_t dev, void (*strat)(struct buf *bp), struct disklabel *lp,
+readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
     struct cpu_disklabel *osdep)
 {
        struct buf *bp;
        struct disklabel *dlp;
        char *msg = NULL;
+       int i;
 
+       if (lp->d_secsize == 0)
+               lp->d_secsize = DEV_BSIZE;
        if (lp->d_secperunit == 0)
                lp->d_secperunit = 0x1fffffff;
-       lp->d_npartitions = 1;
-       if (lp->d_partitions[0].p_size == 0)
-               lp->d_partitions[0].p_size = 0x1fffffff;
-       lp->d_partitions[0].p_offset = 0;
+       if (lp->d_npartitions < RAW_PART + 1)
+               lp->d_npartitions = RAW_PART + 1;
+       for (i = 0; i < RAW_PART; i++) {
+               lp->d_partitions[i].p_size = 0;
+               lp->d_partitions[i].p_offset = 0;
+       }
+       if (lp->d_partitions[RAW_PART].p_size == 0)
+               lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
+       lp->d_partitions[RAW_PART].p_offset = 0;
+
+       lp->d_partitions[0].p_size = lp->d_partitions[RAW_PART].p_size;
+       lp->d_partitions[0].p_fstype = FS_BSDFFS;
 
        bp = geteblk((int)lp->d_secsize);
        bp->b_dev = dev;
@@ -71,10 +82,10 @@
        bp->b_flags |= B_READ;
        bp->b_cylinder = LABELSECTOR / lp->d_secpercyl;
        (*strat)(bp);
-       if (biowait(bp)) {
+       if (biowait(bp))
                msg = "I/O error";
-       } else for (dlp = (struct disklabel *)bp->b_data;
-           dlp <= (struct disklabel *)(bp->b_data+DEV_BSIZE-sizeof(*dlp));
+       else for (dlp = (struct disklabel *)bp->b_data;
+           dlp <= (struct disklabel *)(bp->b_data + DEV_BSIZE - sizeof(*dlp));
            dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
                if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
                        if (msg == NULL)
@@ -93,8 +104,7 @@
 }
 
 /*
- * Check new disk label for sensibility
- * before setting it.
+ * Check new disk label for sensibility before setting it.
  */
 int
 setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
@@ -126,8 +136,8 @@
                        npp->p_cpg = opp->p_cpg;
                }
        }
-       nlp->d_checksum = 0;
-       nlp->d_checksum = dkcksum(nlp);
+       nlp->d_checksum = 0;
+       nlp->d_checksum = dkcksum(nlp);
        *olp = *nlp;
        return 0;
 }
@@ -136,7 +146,7 @@
  * Write disk label back to device after modification.
  */
 int
-writedisklabel(dev_t dev, void (*strat)(struct buf *bp), struct disklabel *lp,
+writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
     struct cpu_disklabel *osdep)
 {
        struct buf *bp;
@@ -151,7 +161,7 @@
                labelpart = 0;
        }
        bp = geteblk((int)lp->d_secsize);
-       bp->b_dev = makedev(major(dev), DISKMINOR(DISKUNIT(dev), labelpart));
+       bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), labelpart);
        bp->b_blkno = LABELSECTOR;
        bp->b_bcount = lp->d_secsize;
        bp->b_flags |= B_READ;
@@ -173,14 +183,12 @@
                }
        }
        error = ESRCH;
-done:
+ done:
        brelse(bp);
        return error;
 }
 
 /*
- * UNTESTED !!
- *
  * Determine the size of the transfer, and make sure it is
  * within the boundaries of the partition. Adjust transfer
  * if needed, and signal errors or early completion.
@@ -222,7 +230,7 @@
        /* calculate cylinder for disksort to order transfers with */
        bp->b_resid = (bp->b_blkno + p->p_offset) / lp->d_secpercyl;
        return 1;
-bad:
+ bad:
        bp->b_flags |= B_ERROR;
        return -1;
 }



Home | Main Index | Thread Index | Old Index