Sun Feb 26 09:49:40 2017 UTC ()
Disks without a disk label happen in normal operation (both as USB
stick or with GPT), so do not cause an error message when opening
them.


(martin)
diff -r1.14 -r1.15 src/sys/dev/sun/disksubr.c

cvs diff -r1.14 -r1.15 src/sys/dev/sun/disksubr.c (expand / switch to unified diff)

--- src/sys/dev/sun/disksubr.c 2010/03/23 20:01:09 1.14
+++ src/sys/dev/sun/disksubr.c 2017/02/26 09:49:40 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: disksubr.c,v 1.14 2010/03/23 20:01:09 martin Exp $ */ 1/* $NetBSD: disksubr.c,v 1.15 2017/02/26 09:49:40 martin 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.
@@ -45,27 +45,27 @@ @@ -45,27 +45,27 @@
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */ 55 */
56 56
57#include <sys/cdefs.h> 57#include <sys/cdefs.h>
58__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.14 2010/03/23 20:01:09 martin Exp $"); 58__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.15 2017/02/26 09:49:40 martin Exp $");
59 59
60#include <sys/param.h> 60#include <sys/param.h>
61#include <sys/systm.h> 61#include <sys/systm.h>
62#include <sys/buf.h> 62#include <sys/buf.h>
63#include <sys/ioccom.h> 63#include <sys/ioccom.h>
64#include <sys/device.h> 64#include <sys/device.h>
65#include <sys/disklabel.h> 65#include <sys/disklabel.h>
66#include <sys/disk.h> 66#include <sys/disk.h>
67#include <sys/dkbad.h> 67#include <sys/dkbad.h>
68 68
69#include <dev/sun/disklabel.h> 69#include <dev/sun/disklabel.h>
70 70
71#if LABELSECTOR != 0 71#if LABELSECTOR != 0
@@ -150,27 +150,27 @@ readdisklabel(dev_t dev, void (*strat)(s @@ -150,27 +150,27 @@ readdisklabel(dev_t dev, void (*strat)(s
150 dlp = (struct disklabel *)((char *)dlp + sizeof(long))) { 150 dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
151 if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { 151 if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
152 continue; 152 continue;
153 } 153 }
154 if (dlp->d_npartitions > MAXPARTITIONS || dkcksum(dlp) != 0) 154 if (dlp->d_npartitions > MAXPARTITIONS || dkcksum(dlp) != 0)
155 return("NetBSD disk label corrupted"); 155 return("NetBSD disk label corrupted");
156 else { 156 else {
157 *lp = *dlp; 157 *lp = *dlp;
158 return(NULL); 158 return(NULL);
159 } 159 }
160 } 160 }
161 161
162 memset(clp->cd_block, 0, sizeof(clp->cd_block)); 162 memset(clp->cd_block, 0, sizeof(clp->cd_block));
163 return ("no disk label"); 163 return NULL;
164} 164}
165 165
166/* 166/*
167 * Check new disk label for sensibility 167 * Check new disk label for sensibility
168 * before setting it. 168 * before setting it.
169 */ 169 */
170int 170int
171setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, struct cpu_disklabel *clp) 171setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, struct cpu_disklabel *clp)
172{ 172{
173 int i; 173 int i;
174 struct partition *opp, *npp; 174 struct partition *opp, *npp;
175 175
176 /* sanity clause */ 176 /* sanity clause */