1 /* 2 * Copyright (c) 2003-2007 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Matthew Dillon <dillon@backplane.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 3. Neither the name of The DragonFly Project nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific, prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * ---------------------------------------------------------------------------- 35 * "THE BEER-WARE LICENSE" (Revision 42): 36 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 37 * can do whatever you want with this stuff. If we meet some day, and you think 38 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 39 * ---------------------------------------------------------------------------- 40 * 41 * Copyright (c) 1982, 1986, 1988, 1993 42 * The Regents of the University of California. All rights reserved. 43 * (c) UNIX System Laboratories, Inc. 44 * All or some portions of this file are derived from material licensed 45 * to the University of California by American Telephone and Telegraph 46 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 47 * the permission of UNIX System Laboratories, Inc. 48 * 49 * Copyright (c) 1994 Bruce D. Evans. 50 * All rights reserved. 51 * 52 * Copyright (c) 1990 The Regents of the University of California. 53 * All rights reserved. 54 * 55 * This code is derived from software contributed to Berkeley by 56 * William Jolitz. 57 * 58 * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 59 * All rights reserved. 60 * 61 * Redistribution and use in source and binary forms, with or without 62 * modification, are permitted provided that the following conditions 63 * are met: 64 * 1. Redistributions of source code must retain the above copyright 65 * notice, this list of conditions and the following disclaimer. 66 * 2. Redistributions in binary form must reproduce the above copyright 67 * notice, this list of conditions and the following disclaimer in the 68 * documentation and/or other materials provided with the distribution. 69 * 3. All advertising materials mentioning features or use of this software 70 * must display the following acknowledgement: 71 * This product includes software developed by the University of 72 * California, Berkeley and its contributors. 73 * 4. Neither the name of the University nor the names of its contributors 74 * may be used to endorse or promote products derived from this software 75 * without specific prior written permission. 76 * 77 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 78 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 79 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 80 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 81 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 82 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 83 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 84 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 85 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 86 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 87 * SUCH DAMAGE. 88 * 89 * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 90 * $FreeBSD: src/sys/kern/subr_disk.c,v 1.20.2.6 2001/10/05 07:14:57 peter Exp $ 91 * $FreeBSD: src/sys/ufs/ufs/ufs_disksubr.c,v 1.44.2.3 2001/03/05 05:42:19 obrien Exp $ 92 */ 93 94 #include <sys/param.h> 95 #include <sys/systm.h> 96 #include <sys/kernel.h> 97 #include <sys/proc.h> 98 #include <sys/sysctl.h> 99 #include <sys/buf.h> 100 #include <sys/conf.h> 101 #include <sys/disklabel.h> 102 #include <sys/disklabel32.h> 103 #include <sys/diskslice.h> 104 #include <sys/disk.h> 105 #include <sys/dtype.h> /* DTYPE_* constants */ 106 #include <machine/md_var.h> 107 #include <sys/ctype.h> 108 #include <sys/syslog.h> 109 #include <sys/device.h> 110 #include <sys/msgport.h> 111 #include <sys/msgport2.h> 112 #include <sys/buf2.h> 113 114 #include <vfs/ufs/dinode.h> /* XXX used only for fs.h */ 115 #include <vfs/ufs/fs.h> /* XXX used only to get BBSIZE/SBSIZE */ 116 117 static void partition_info(const char *sname, int part, struct partition32 *pp); 118 static void slice_info(const char *sname, struct diskslice *sp); 119 static const char *l32_fixlabel(const char *sname, struct diskslice *sp, 120 disklabel_t lpx, int writeflag); 121 122 /* 123 * Retrieve the partition start and extent, in blocks. Return 0 on success, 124 * EINVAL on error. 125 */ 126 static int 127 l32_getpartbounds(struct diskslices *ssp, disklabel_t lp, u_int32_t part, 128 u_int64_t *start, u_int64_t *blocks) 129 { 130 struct partition32 *pp; 131 132 if (part >= lp.lab32->d_npartitions) 133 return (EINVAL); 134 pp = &lp.lab32->d_partitions[part]; 135 *start = pp->p_offset; 136 *blocks = pp->p_size; 137 return(0); 138 } 139 140 static void 141 l32_loadpartinfo(disklabel_t lp, u_int32_t part, struct partinfo *dpart) 142 { 143 struct partition32 *pp; 144 const size_t uuid_size = sizeof(struct uuid); 145 146 bzero(&dpart->fstype_uuid, uuid_size); 147 bzero(&dpart->storage_uuid, uuid_size); 148 if (part < lp.lab32->d_npartitions) { 149 pp = &lp.lab32->d_partitions[part]; 150 dpart->fstype = pp->p_fstype; 151 } else { 152 dpart->fstype = 0; 153 } 154 } 155 156 static u_int32_t 157 l32_getnumparts(disklabel_t lp) 158 { 159 return(lp.lab32->d_npartitions); 160 } 161 162 static void 163 l32_freedisklabel(disklabel_t *lpp) 164 { 165 kfree((*lpp).lab32, M_DEVBUF); 166 (*lpp).lab32 = NULL; 167 } 168 169 /* 170 * Attempt to read a disk label from a device. 171 * 172 * Returns NULL on sucess, and an error string on failure 173 */ 174 static const char * 175 l32_readdisklabel(cdev_t dev, struct diskslice *sp, disklabel_t *lpp, 176 struct disk_info *info) 177 { 178 disklabel_t lpx; 179 struct buf *bp; 180 struct disklabel32 *dlp; 181 const char *msg = NULL; 182 int secsize = info->d_media_blksize; 183 184 bp = geteblk(secsize); 185 bp->b_bio1.bio_offset = (off_t)LABELSECTOR32 * secsize; 186 bp->b_bio1.bio_done = biodone_sync; 187 bp->b_bio1.bio_flags |= BIO_SYNC; 188 bp->b_bcount = secsize; 189 bp->b_flags &= ~B_INVAL; 190 bp->b_cmd = BUF_CMD_READ; 191 dev_dstrategy(dev, &bp->b_bio1); 192 if (biowait(&bp->b_bio1, "labrd")) 193 msg = "I/O error"; 194 else for (dlp = (struct disklabel32 *)bp->b_data; 195 dlp <= (struct disklabel32 *)((char *)bp->b_data + 196 secsize - sizeof(*dlp)); 197 dlp = (struct disklabel32 *)((char *)dlp + sizeof(long))) { 198 if (dlp->d_magic != DISKMAGIC32 || 199 dlp->d_magic2 != DISKMAGIC32) { 200 /* 201 * NOTE! dsreadandsetlabel() does a strcmp() on 202 * this string. 203 */ 204 if (msg == NULL) 205 msg = "no disk label"; 206 } else if (dlp->d_npartitions > MAXPARTITIONS32 || 207 dkcksum32(dlp) != 0) { 208 msg = "disk label corrupted"; 209 } else { 210 lpx.lab32 = dlp; 211 msg = l32_fixlabel(NULL, sp, lpx, FALSE); 212 if (msg == NULL) { 213 (*lpp).lab32 = kmalloc(sizeof(*dlp), 214 M_DEVBUF, M_WAITOK|M_ZERO); 215 *(*lpp).lab32 = *dlp; 216 } 217 break; 218 } 219 } 220 bp->b_flags |= B_INVAL | B_AGE; 221 brelse(bp); 222 return (msg); 223 } 224 225 /* 226 * Check new disk label for sensibility before setting it. 227 */ 228 static int 229 l32_setdisklabel(disklabel_t olpx, disklabel_t nlpx, struct diskslices *ssp, 230 struct diskslice *sp, u_int32_t *openmask) 231 { 232 struct disklabel32 *olp, *nlp; 233 struct partition32 *opp, *npp; 234 int part; 235 int i; 236 237 olp = olpx.lab32; 238 nlp = nlpx.lab32; 239 240 /* 241 * Check it is actually a disklabel we are looking at. 242 */ 243 if (nlp->d_magic != DISKMAGIC32 || nlp->d_magic2 != DISKMAGIC32 || 244 dkcksum32(nlp) != 0) 245 return (EINVAL); 246 247 /* 248 * For each partition that we think is open, check the new disklabel 249 * for compatibility. Ignore special partitions (>= 128). 250 */ 251 i = 0; 252 while (i < 128) { 253 if (openmask[i >> 5] == 0) { 254 i += 32; 255 continue; 256 } 257 if ((openmask[i >> 5] & (1 << (i & 31))) == 0) { 258 ++i; 259 continue; 260 } 261 if (nlp->d_npartitions <= i) 262 return (EBUSY); 263 opp = &olp->d_partitions[i]; 264 npp = &nlp->d_partitions[i]; 265 if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size) 266 return (EBUSY); 267 /* 268 * Copy internally-set partition information 269 * if new label doesn't include it. XXX 270 * (If we are using it then we had better stay the same type) 271 * This is possibly dubious, as someone else noted (XXX) 272 */ 273 if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { 274 npp->p_fstype = opp->p_fstype; 275 npp->p_fsize = opp->p_fsize; 276 npp->p_frag = opp->p_frag; 277 npp->p_cpg = opp->p_cpg; 278 } 279 ++i; 280 } 281 nlp->d_checksum = 0; 282 nlp->d_checksum = dkcksum32(nlp); 283 *olp = *nlp; 284 285 if (olp->d_partitions[RAW_PART].p_offset) 286 return (EXDEV); 287 if (olp->d_secperunit > sp->ds_size) 288 return (ENOSPC); 289 for (part = 0; part < olp->d_npartitions; ++part) { 290 if (olp->d_partitions[part].p_size > sp->ds_size) 291 return(ENOSPC); 292 } 293 return (0); 294 } 295 296 /* 297 * Write disk label back to device after modification. 298 */ 299 static int 300 l32_writedisklabel(cdev_t dev, struct diskslices *ssp, struct diskslice *sp, 301 disklabel_t lpx) 302 { 303 struct disklabel32 *lp; 304 struct disklabel32 *dlp; 305 struct buf *bp; 306 const char *msg; 307 int error = 0; 308 309 lp = lpx.lab32; 310 311 if (lp->d_partitions[RAW_PART].p_offset != 0) 312 return (EXDEV); /* not quite right */ 313 314 bp = geteblk((int)lp->d_secsize); 315 bp->b_bio1.bio_offset = (off_t)LABELSECTOR32 * lp->d_secsize; 316 bp->b_bio1.bio_done = biodone_sync; 317 bp->b_bio1.bio_flags |= BIO_SYNC; 318 bp->b_bcount = lp->d_secsize; 319 320 #if 1 321 /* 322 * We read the label first to see if it's there, 323 * in which case we will put ours at the same offset into the block.. 324 * (I think this is stupid [Julian]) 325 * Note that you can't write a label out over a corrupted label! 326 * (also stupid.. how do you write the first one? by raw writes?) 327 */ 328 bp->b_flags &= ~B_INVAL; 329 bp->b_cmd = BUF_CMD_READ; 330 KKASSERT(dkpart(dev) == WHOLE_SLICE_PART); 331 dev_dstrategy(dev, &bp->b_bio1); 332 error = biowait(&bp->b_bio1, "labrd"); 333 if (error) 334 goto done; 335 for (dlp = (struct disklabel32 *)bp->b_data; 336 dlp <= (struct disklabel32 *) 337 ((char *)bp->b_data + lp->d_secsize - sizeof(*dlp)); 338 dlp = (struct disklabel32 *)((char *)dlp + sizeof(long))) { 339 if (dlp->d_magic == DISKMAGIC32 && 340 dlp->d_magic2 == DISKMAGIC32 && dkcksum32(dlp) == 0) { 341 *dlp = *lp; 342 lpx.lab32 = dlp; 343 msg = l32_fixlabel(NULL, sp, lpx, TRUE); 344 if (msg) { 345 error = EINVAL; 346 } else { 347 bp->b_cmd = BUF_CMD_WRITE; 348 bp->b_bio1.bio_done = biodone_sync; 349 bp->b_bio1.bio_flags |= BIO_SYNC; 350 KKASSERT(dkpart(dev) == WHOLE_SLICE_PART); 351 dev_dstrategy(dev, &bp->b_bio1); 352 error = biowait(&bp->b_bio1, "labwr"); 353 } 354 goto done; 355 } 356 } 357 error = ESRCH; 358 done: 359 #else 360 bzero(bp->b_data, lp->d_secsize); 361 dlp = (struct disklabel32 *)bp->b_data; 362 *dlp = *lp; 363 bp->b_flags &= ~B_INVAL; 364 bp->b_cmd = BUF_CMD_WRITE; 365 bp->b_bio1.bio_done = biodone_sync; 366 bp->b_bio1.bio_flags |= BIO_SYNC; 367 BUF_STRATEGY(bp, 1); 368 error = biowait(&bp->b_bio1, "labwr"); 369 #endif 370 bp->b_flags |= B_INVAL | B_AGE; 371 brelse(bp); 372 return (error); 373 } 374 375 /* 376 * Create a disklabel based on a disk_info structure, initializing 377 * the appropriate fields and creating a raw partition that covers the 378 * whole disk. 379 * 380 * If a diskslice is passed, the label is truncated to the slice 381 */ 382 static disklabel_t 383 l32_clone_label(struct disk_info *info, struct diskslice *sp) 384 { 385 struct disklabel32 *lp; 386 disklabel_t res; 387 388 lp = kmalloc(sizeof *lp, M_DEVBUF, M_WAITOK | M_ZERO); 389 lp->d_nsectors = info->d_secpertrack; 390 lp->d_ntracks = info->d_nheads; 391 lp->d_secpercyl = info->d_secpercyl; 392 lp->d_secsize = info->d_media_blksize; 393 394 if (sp) 395 lp->d_secperunit = (u_int)sp->ds_size; 396 else 397 lp->d_secperunit = (u_int)info->d_media_blocks; 398 399 if (lp->d_typename[0] == '\0') 400 strncpy(lp->d_typename, "amnesiac", sizeof(lp->d_typename)); 401 if (lp->d_packname[0] == '\0') 402 strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname)); 403 if (lp->d_nsectors == 0) 404 lp->d_nsectors = 32; 405 if (lp->d_ntracks == 0) 406 lp->d_ntracks = 64; 407 lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; 408 lp->d_ncylinders = lp->d_secperunit / lp->d_secpercyl; 409 if (lp->d_rpm == 0) 410 lp->d_rpm = 3600; 411 if (lp->d_interleave == 0) 412 lp->d_interleave = 1; 413 if (lp->d_npartitions < RAW_PART + 1) 414 lp->d_npartitions = MAXPARTITIONS32; 415 if (lp->d_bbsize == 0) 416 lp->d_bbsize = BBSIZE; 417 if (lp->d_sbsize == 0) 418 lp->d_sbsize = SBSIZE; 419 420 /* 421 * Used by various devices to create a compatibility slice which 422 * allows us to mount root from devices which do not have a 423 * disklabel. Particularly: CDs. 424 */ 425 lp->d_partitions[RAW_PART].p_size = lp->d_secperunit; 426 if (info->d_dsflags & DSO_COMPATPARTA) { 427 lp->d_partitions[0].p_size = lp->d_secperunit; 428 lp->d_partitions[0].p_fstype = FS_OTHER; 429 } 430 lp->d_magic = DISKMAGIC32; 431 lp->d_magic2 = DISKMAGIC32; 432 lp->d_checksum = dkcksum32(lp); 433 res.lab32 = lp; 434 return (res); 435 } 436 437 static void 438 l32_makevirginlabel(disklabel_t lpx, struct diskslices *ssp, 439 struct diskslice *sp, struct disk_info *info) 440 { 441 struct disklabel32 *lp = lpx.lab32; 442 struct partition32 *pp; 443 disklabel_t template; 444 445 template = l32_clone_label(info, NULL); 446 bcopy(template.opaque, lp, sizeof(struct disklabel32)); 447 448 lp->d_magic = DISKMAGIC32; 449 lp->d_magic2 = DISKMAGIC32; 450 451 lp->d_npartitions = MAXPARTITIONS32; 452 if (lp->d_interleave == 0) 453 lp->d_interleave = 1; 454 if (lp->d_rpm == 0) 455 lp->d_rpm = 3600; 456 if (lp->d_nsectors == 0) /* sectors per track */ 457 lp->d_nsectors = 32; 458 if (lp->d_ntracks == 0) /* heads */ 459 lp->d_ntracks = 64; 460 lp->d_ncylinders = 0; 461 lp->d_bbsize = BBSIZE; 462 lp->d_sbsize = SBSIZE; 463 464 /* 465 * If the slice or GPT partition is really small we could 466 * wind up with an absurd calculation for ncylinders. 467 */ 468 while (lp->d_ncylinders < 4) { 469 if (lp->d_ntracks > 1) 470 lp->d_ntracks >>= 1; 471 else if (lp->d_nsectors > 1) 472 lp->d_nsectors >>= 1; 473 else 474 break; 475 lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; 476 lp->d_ncylinders = sp->ds_size / lp->d_secpercyl; 477 } 478 479 /* 480 * Set or Modify the partition sizes to accomodate the slice, 481 * since we started with a copy of the virgin label stored 482 * in the whole-disk-slice and we are probably not a 483 * whole-disk slice. 484 */ 485 lp->d_secperunit = sp->ds_size; 486 pp = &lp->d_partitions[RAW_PART]; 487 pp->p_offset = 0; 488 pp->p_size = lp->d_secperunit; 489 if (info->d_dsflags & DSO_COMPATPARTA) { 490 pp = &lp->d_partitions[0]; 491 pp->p_offset = 0; 492 pp->p_size = lp->d_secperunit; 493 pp->p_fstype = FS_OTHER; 494 } 495 lp->d_checksum = 0; 496 lp->d_checksum = dkcksum32(lp); 497 498 kfree(template.opaque, M_DEVBUF); 499 } 500 501 static const char * 502 l32_fixlabel(const char *sname, struct diskslice *sp, 503 disklabel_t lpx, int writeflag) 504 { 505 struct disklabel32 *lp; 506 struct partition32 *pp; 507 u_int64_t start; 508 u_int64_t end; 509 u_int64_t offset; 510 int part; 511 int warned; 512 513 lp = lpx.lab32; 514 515 /* These errors "can't happen" so don't bother reporting details. */ 516 if (lp->d_magic != DISKMAGIC32 || lp->d_magic2 != DISKMAGIC32) 517 return ("fixlabel: invalid magic"); 518 if (dkcksum32(lp) != 0) 519 return ("fixlabel: invalid checksum"); 520 521 pp = &lp->d_partitions[RAW_PART]; 522 523 /* 524 * What a mess. For ages old backwards compatibility the disklabel 525 * on-disk stores absolute offsets instead of slice-relative offsets. 526 * So fix it up when reading, writing, or snooping. 527 * 528 * The in-core label is always slice-relative. 529 */ 530 if (writeflag) { 531 start = 0; 532 offset = sp->ds_offset; 533 } else { 534 start = sp->ds_offset; 535 offset = -sp->ds_offset; 536 } 537 if (pp->p_offset != start) { 538 if (sname != NULL) { 539 kprintf( 540 "%s: rejecting BSD label: raw partition offset != slice offset\n", 541 sname); 542 slice_info(sname, sp); 543 partition_info(sname, RAW_PART, pp); 544 } 545 return ("fixlabel: raw partition offset != slice offset"); 546 } 547 if (pp->p_size != sp->ds_size) { 548 if (sname != NULL) { 549 kprintf("%s: raw partition size != slice size\n", sname); 550 slice_info(sname, sp); 551 partition_info(sname, RAW_PART, pp); 552 } 553 if (pp->p_size > sp->ds_size) { 554 if (sname == NULL) 555 return ("fixlabel: raw partition size > slice size"); 556 kprintf("%s: truncating raw partition\n", sname); 557 pp->p_size = sp->ds_size; 558 } 559 } 560 end = start + sp->ds_size; 561 if (start > end) 562 return ("fixlabel: slice wraps"); 563 if (lp->d_secpercyl <= 0) 564 return ("fixlabel: d_secpercyl <= 0"); 565 pp -= RAW_PART; 566 warned = FALSE; 567 for (part = 0; part < lp->d_npartitions; part++, pp++) { 568 if (pp->p_offset != 0 || pp->p_size != 0) { 569 if (pp->p_offset < start 570 || pp->p_offset + pp->p_size > end 571 || pp->p_offset + pp->p_size < pp->p_offset) { 572 if (sname != NULL) { 573 kprintf( 574 "%s: rejecting partition in BSD label: it isn't entirely within the slice\n", 575 sname); 576 if (!warned) { 577 slice_info(sname, sp); 578 warned = TRUE; 579 } 580 partition_info(sname, part, pp); 581 } 582 /* XXX else silently discard junk. */ 583 bzero(pp, sizeof *pp); 584 } else { 585 pp->p_offset += offset; 586 } 587 } 588 } 589 lp->d_ncylinders = sp->ds_size / lp->d_secpercyl; 590 lp->d_secperunit = sp->ds_size; 591 lp->d_checksum = 0; 592 lp->d_checksum = dkcksum32(lp); 593 return (NULL); 594 } 595 596 /* 597 * Set the number of blocks at the beginning of the slice which have 598 * been reserved for label operations. This area will be write-protected 599 * when accessed via the slice. 600 */ 601 static void 602 l32_adjust_label_reserved(struct diskslices *ssp, int slice, 603 struct diskslice *sp) 604 { 605 /*struct disklabel32 *lp = sp->ds_label.lab32;*/ 606 sp->ds_reserved = SBSIZE / ssp->dss_secsize; 607 } 608 609 static void 610 partition_info(const char *sname, int part, struct partition32 *pp) 611 { 612 kprintf("%s%c: start %lu, end %lu, size %lu\n", sname, 'a' + part, 613 (u_long)pp->p_offset, (u_long)(pp->p_offset + pp->p_size - 1), 614 (u_long)pp->p_size); 615 } 616 617 static void 618 slice_info(const char *sname, struct diskslice *sp) 619 { 620 kprintf("%s: start %llu, end %llu, size %llu\n", sname, 621 (long long)sp->ds_offset, 622 (long long)sp->ds_offset + sp->ds_size - 1, 623 (long long)sp->ds_size); 624 } 625 626 struct disklabel_ops disklabel32_ops = { 627 .labelsize = sizeof(struct disklabel32), 628 .op_readdisklabel = l32_readdisklabel, 629 .op_setdisklabel = l32_setdisklabel, 630 .op_writedisklabel = l32_writedisklabel, 631 .op_clone_label = l32_clone_label, 632 .op_adjust_label_reserved = l32_adjust_label_reserved, 633 .op_getpartbounds = l32_getpartbounds, 634 .op_loadpartinfo = l32_loadpartinfo, 635 .op_getnumparts = l32_getnumparts, 636 .op_makevirginlabel = l32_makevirginlabel, 637 .op_freedisklabel = l32_freedisklabel 638 }; 639 640