Sun Jan 12 12:12:58 2014 UTC ()
Pull up following revision(s) (requested by tsutsui in ticket #1002):
	sys/arch/luna68k/luna68k/disksubr.c: revision 1.30
Make the default disklabel (for disks without label) have saner value.
I.e. use d_secperunit for RAW_PART rather than 0x1fffffff for part a.


(bouyer)
diff -r1.29 -r1.29.18.1 src/sys/arch/luna68k/luna68k/disksubr.c

cvs diff -r1.29 -r1.29.18.1 src/sys/arch/luna68k/luna68k/disksubr.c (expand / switch to unified diff)

--- src/sys/arch/luna68k/luna68k/disksubr.c 2009/10/26 19:16:56 1.29
+++ src/sys/arch/luna68k/luna68k/disksubr.c 2014/01/12 12:12:58 1.29.18.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: disksubr.c,v 1.29 2009/10/26 19:16:56 cegger Exp $ */ 1/* $NetBSD: disksubr.c,v 1.29.18.1 2014/01/12 12:12:58 bouyer Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 4 * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -93,27 +93,27 @@ @@ -93,27 +93,27 @@
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE. 94 * SUCH DAMAGE.
95 * 95 *
96 * Credits: 96 * Credits:
97 * This file was based mostly on the i386/disksubr.c file: 97 * This file was based mostly on the i386/disksubr.c file:
98 * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 98 * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
99 * The functions: disklabel_sun_to_bsd, disklabel_bsd_to_sun 99 * The functions: disklabel_sun_to_bsd, disklabel_bsd_to_sun
100 * were originally taken from arch/sparc/scsi/sun_disklabel.c 100 * were originally taken from arch/sparc/scsi/sun_disklabel.c
101 * (which was written by Theo de Raadt) and then substantially 101 * (which was written by Theo de Raadt) and then substantially
102 * rewritten by Gordon W. Ross. 102 * rewritten by Gordon W. Ross.
103 */ 103 */
104 104
105#include <sys/cdefs.h> 105#include <sys/cdefs.h>
106__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.29 2009/10/26 19:16:56 cegger Exp $"); 106__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.29.18.1 2014/01/12 12:12:58 bouyer Exp $");
107 107
108#include <sys/param.h> 108#include <sys/param.h>
109#include <sys/systm.h> 109#include <sys/systm.h>
110#include <sys/buf.h> 110#include <sys/buf.h>
111#include <sys/device.h> 111#include <sys/device.h>
112#include <sys/disklabel.h> 112#include <sys/disklabel.h>
113#include <sys/disk.h> 113#include <sys/disk.h>
114#include <sys/dkbad.h> 114#include <sys/dkbad.h>
115 115
116#include <dev/sun/disklabel.h> 116#include <dev/sun/disklabel.h>
117 117
118/* 118/*
119 * UniOS disklabel (== ISI disklabel) is very similar to SunOS. 119 * UniOS disklabel (== ISI disklabel) is very similar to SunOS.
@@ -170,34 +170,40 @@ static int disklabel_bsd_to_om(struct di @@ -170,34 +170,40 @@ static int disklabel_bsd_to_om(struct di
170 * must be filled in before calling us. 170 * must be filled in before calling us.
171 * 171 *
172 * Return buffer for use in signalling errors if requested. 172 * Return buffer for use in signalling errors if requested.
173 * 173 *
174 * Returns null on success and an error string on failure. 174 * Returns null on success and an error string on failure.
175 */ 175 */
176const char * 176const char *
177readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp) 177readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
178{ 178{
179 struct buf *bp; 179 struct buf *bp;
180 struct disklabel *dlp; 180 struct disklabel *dlp;
181 struct sun_disklabel *slp; 181 struct sun_disklabel *slp;
182 int error; 182 int error;
 183 int i;
183 184
184 /* minimal requirements for archtypal disk label */ 185 /* minimal requirements for archtypal disk label */
185 if (lp->d_secperunit == 0) 186 if (lp->d_secperunit == 0)
186 lp->d_secperunit = 0x1fffffff; 187 lp->d_secperunit = 0x1fffffff;
187 lp->d_npartitions = 1; 188 if (lp->d_npartitions < RAW_PART + 1)
188 if (lp->d_partitions[0].p_size == 0) 189 lp->d_npartitions = RAW_PART + 1;
189 lp->d_partitions[0].p_size = 0x1fffffff; 190 for (i = 0; i < RAW_PART; i++) {
190 lp->d_partitions[0].p_offset = 0; 191 lp->d_partitions[i].p_size = 0;
 192 lp->d_partitions[i].p_offset = 0;
 193 }
 194 if (lp->d_partitions[RAW_PART].p_size == 0)
 195 lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
 196 lp->d_partitions[RAW_PART].p_offset = 0;
191 197
192 /* obtain buffer to probe drive with */ 198 /* obtain buffer to probe drive with */
193 bp = geteblk((int)lp->d_secsize); 199 bp = geteblk((int)lp->d_secsize);
194 200
195 /* next, dig out disk label */ 201 /* next, dig out disk label */
196 bp->b_dev = dev; 202 bp->b_dev = dev;
197 bp->b_blkno = LABELSECTOR; 203 bp->b_blkno = LABELSECTOR;
198 bp->b_cylinder = 0; 204 bp->b_cylinder = 0;
199 bp->b_bcount = lp->d_secsize; 205 bp->b_bcount = lp->d_secsize;
200 bp->b_flags |= B_READ; 206 bp->b_flags |= B_READ;
201 (*strat)(bp); 207 (*strat)(bp);
202 208
203 /* if successful, locate disk label within block and validate */ 209 /* if successful, locate disk label within block and validate */