| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: disksubr.c,v 1.20 2008/01/02 11:48:25 ad Exp $ */ | | 1 | /* $NetBSD: disksubr.c,v 1.21 2013/05/13 15:40:31 christos 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. |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | * | | 30 | * |
31 | * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 | | 31 | * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.20 2008/01/02 11:48:25 ad Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.21 2013/05/13 15:40:31 christos Exp $"); |
36 | | | 36 | |
37 | #include <sys/param.h> | | 37 | #include <sys/param.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | #include <sys/buf.h> | | 39 | #include <sys/buf.h> |
40 | #include <sys/disklabel.h> | | 40 | #include <sys/disklabel.h> |
41 | #include <sys/disk.h> | | 41 | #include <sys/disk.h> |
42 | #include <sys/syslog.h> | | 42 | #include <sys/syslog.h> |
43 | | | 43 | |
44 | #include "opt_mbr.h" | | 44 | #include "opt_mbr.h" |
45 | | | 45 | |
46 | int fat_types[] = { MBR_PTYPE_FAT12, MBR_PTYPE_FAT16S, | | 46 | int fat_types[] = { MBR_PTYPE_FAT12, MBR_PTYPE_FAT16S, |
47 | MBR_PTYPE_FAT16B, MBR_PTYPE_FAT32, | | 47 | MBR_PTYPE_FAT16B, MBR_PTYPE_FAT32, |
48 | MBR_PTYPE_FAT32L, MBR_PTYPE_FAT16L, | | 48 | MBR_PTYPE_FAT32L, MBR_PTYPE_FAT16L, |
| @@ -155,27 +155,27 @@ readdisklabel(dev_t dev, void (*strat)(s | | | @@ -155,27 +155,27 @@ readdisklabel(dev_t dev, void (*strat)(s |
155 | if (lp->d_partitions[i].p_size == 0) | | 155 | if (lp->d_partitions[i].p_size == 0) |
156 | lp->d_partitions[i].p_size = 0x1fffffff; | | 156 | lp->d_partitions[i].p_size = 0x1fffffff; |
157 | lp->d_partitions[i].p_offset = 0; | | 157 | lp->d_partitions[i].p_offset = 0; |
158 | | | 158 | |
159 | /* get a buffer and initialize it */ | | 159 | /* get a buffer and initialize it */ |
160 | bp = geteblk((int)lp->d_secsize); | | 160 | bp = geteblk((int)lp->d_secsize); |
161 | bp->b_dev = dev; | | 161 | bp->b_dev = dev; |
162 | | | 162 | |
163 | /* do dos partitions in the process of getting disklabel? */ | | 163 | /* do dos partitions in the process of getting disklabel? */ |
164 | dospartoff = 0; | | 164 | dospartoff = 0; |
165 | cyl = LABELSECTOR / lp->d_secpercyl; | | 165 | cyl = LABELSECTOR / lp->d_secpercyl; |
166 | if (!osdep) | | 166 | if (!osdep) |
167 | goto nombrpart; | | 167 | goto nombrpart; |
168 | dp = osdep->dosparts; | | 168 | dp = osdep->mbrparts; |
169 | | | 169 | |
170 | /* read master boot record */ | | 170 | /* read master boot record */ |
171 | bp->b_blkno = MBR_BBSECTOR; | | 171 | bp->b_blkno = MBR_BBSECTOR; |
172 | bp->b_bcount = lp->d_secsize; | | 172 | bp->b_bcount = lp->d_secsize; |
173 | bp->b_flags |= B_READ; | | 173 | bp->b_flags |= B_READ; |
174 | bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl; | | 174 | bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl; |
175 | (*strat)(bp); | | 175 | (*strat)(bp); |
176 | | | 176 | |
177 | /* if successful, wander through dos partition table */ | | 177 | /* if successful, wander through dos partition table */ |
178 | if (biowait(bp)) { | | 178 | if (biowait(bp)) { |
179 | msg = "dos partition I/O error"; | | 179 | msg = "dos partition I/O error"; |
180 | goto done; | | 180 | goto done; |
181 | } else { | | 181 | } else { |
| @@ -376,27 +376,27 @@ writedisklabel(dev_t dev, void (*strat)( | | | @@ -376,27 +376,27 @@ writedisklabel(dev_t dev, void (*strat)( |
376 | struct buf *bp; | | 376 | struct buf *bp; |
377 | struct disklabel *dlp; | | 377 | struct disklabel *dlp; |
378 | int error, dospartoff, cyl; | | 378 | int error, dospartoff, cyl; |
379 | | | 379 | |
380 | /* get a buffer and initialize it */ | | 380 | /* get a buffer and initialize it */ |
381 | bp = geteblk((int)lp->d_secsize); | | 381 | bp = geteblk((int)lp->d_secsize); |
382 | bp->b_dev = dev; | | 382 | bp->b_dev = dev; |
383 | | | 383 | |
384 | /* do dos partitions in the process of getting disklabel? */ | | 384 | /* do dos partitions in the process of getting disklabel? */ |
385 | dospartoff = 0; | | 385 | dospartoff = 0; |
386 | cyl = LABELSECTOR / lp->d_secpercyl; | | 386 | cyl = LABELSECTOR / lp->d_secpercyl; |
387 | if (!osdep) | | 387 | if (!osdep) |
388 | goto nombrpart; | | 388 | goto nombrpart; |
389 | dp = osdep->dosparts; | | 389 | dp = osdep->mbrparts; |
390 | | | 390 | |
391 | /* read master boot record */ | | 391 | /* read master boot record */ |
392 | bp->b_blkno = MBR_BBSECTOR; | | 392 | bp->b_blkno = MBR_BBSECTOR; |
393 | bp->b_bcount = lp->d_secsize; | | 393 | bp->b_bcount = lp->d_secsize; |
394 | bp->b_flags |= B_READ; | | 394 | bp->b_flags |= B_READ; |
395 | bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl; | | 395 | bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl; |
396 | (*strat)(bp); | | 396 | (*strat)(bp); |
397 | | | 397 | |
398 | if ((error = biowait(bp)) == 0) { | | 398 | if ((error = biowait(bp)) == 0) { |
399 | struct mbr_partition *ourdp = NULL; | | 399 | struct mbr_partition *ourdp = NULL; |
400 | | | 400 | |
401 | ourdp = mbr_findslice(dp, bp); | | 401 | ourdp = mbr_findslice(dp, bp); |
402 | if (ourdp == NO_MBR_SIGNATURE) | | 402 | if (ourdp == NO_MBR_SIGNATURE) |