geom_bsd.c (105542) | geom_bsd.c (105551) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/geom/geom_bsd.c 105542 2002-10-20 19:18:07Z phk $ | 35 * $FreeBSD: head/sys/geom/geom_bsd.c 105551 2002-10-20 20:28:24Z phk $ |
36 * 37 * This is the method for dealing with BSD disklabels. It has been 38 * extensively (by my standards at least) commented, in the vain hope that 39 * it will server as the source in future copy&paste operations. 40 */ 41 42#include <sys/param.h> 43#ifndef _KERNEL --- 270 unchanged lines hidden (view full) --- 314 return (error); 315 316 /* Make sure the checksum is OK. */ 317 if (dkcksum(dl) != 0) 318 return (EINVAL); 319 320 /* Get dimensions of our device. */ 321 cp = LIST_FIRST(&gp->consumer); | 36 * 37 * This is the method for dealing with BSD disklabels. It has been 38 * extensively (by my standards at least) commented, in the vain hope that 39 * it will server as the source in future copy&paste operations. 40 */ 41 42#include <sys/param.h> 43#ifndef _KERNEL --- 270 unchanged lines hidden (view full) --- 314 return (error); 315 316 /* Make sure the checksum is OK. */ 317 if (dkcksum(dl) != 0) 318 return (EINVAL); 319 320 /* Get dimensions of our device. */ 321 cp = LIST_FIRST(&gp->consumer); |
322 error = g_getattr("GEOM::sectorsize", cp, &secsize); 323 if (error) 324 return (error); 325 error = g_getattr("GEOM::mediasize", cp, &mediasize); 326 if (error) 327 return (error); | 322 secsize = cp->provider->sectorsize; 323 mediasize = cp->provider->mediasize; |
328 329#ifdef nolonger 330 /* 331 * The raw-partition must start at zero. We do not check that the 332 * size == mediasize because this is overly restrictive. We have 333 * already tested in g_bsd_checklabel() that it is not longer. 334 * XXX: RAW_PART is archaic anyway, and we should drop it. 335 */ --- 172 unchanged lines hidden (view full) --- 508 509 if (gio->cmd == DIOCSDINFO) { 510 g_io_deliver(bp, 0); 511 return; 512 } 513 KASSERT(gio->cmd == DIOCWDINFO, ("Unknown ioctl in g_bsd_ioctl")); 514 cp = LIST_FIRST(&gp->consumer); 515 /* Get sector size, we need it to read data. */ | 324 325#ifdef nolonger 326 /* 327 * The raw-partition must start at zero. We do not check that the 328 * size == mediasize because this is overly restrictive. We have 329 * already tested in g_bsd_checklabel() that it is not longer. 330 * XXX: RAW_PART is archaic anyway, and we should drop it. 331 */ --- 172 unchanged lines hidden (view full) --- 504 505 if (gio->cmd == DIOCSDINFO) { 506 g_io_deliver(bp, 0); 507 return; 508 } 509 KASSERT(gio->cmd == DIOCWDINFO, ("Unknown ioctl in g_bsd_ioctl")); 510 cp = LIST_FIRST(&gp->consumer); 511 /* Get sector size, we need it to read data. */ |
516 error = g_getattr("GEOM::sectorsize", cp, &secsize); 517 if (error || secsize < 512) { 518 g_io_deliver(bp, error); 519 return; 520 } | 512 secsize = cp->provider->sectorsize; |
521 secoff = ms->labeloffset % secsize; 522 buf = g_read_data(cp, ms->labeloffset - secoff, secsize, &error); 523 if (buf == NULL || error != 0) { 524 g_io_deliver(bp, error); 525 return; 526 } 527 dl = &ms->ondisk; 528 g_bsd_leenc_disklabel(buf + secoff, dl); --- 169 unchanged lines hidden (view full) --- 698 * to type 165 slices in the G_TF_NORMAL case. We will 699 * attach to any other type (BSD was handles above) 700 */ 701 error = g_getattr("MBR::type", cp, &i); 702 if (!error && i != 165 && flags == G_TF_NORMAL) 703 break; 704 705 /* Get sector size, we need it to read data. */ | 513 secoff = ms->labeloffset % secsize; 514 buf = g_read_data(cp, ms->labeloffset - secoff, secsize, &error); 515 if (buf == NULL || error != 0) { 516 g_io_deliver(bp, error); 517 return; 518 } 519 dl = &ms->ondisk; 520 g_bsd_leenc_disklabel(buf + secoff, dl); --- 169 unchanged lines hidden (view full) --- 690 * to type 165 slices in the G_TF_NORMAL case. We will 691 * attach to any other type (BSD was handles above) 692 */ 693 error = g_getattr("MBR::type", cp, &i); 694 if (!error && i != 165 && flags == G_TF_NORMAL) 695 break; 696 697 /* Get sector size, we need it to read data. */ |
706 error = g_getattr("GEOM::sectorsize", cp, &secsize); 707 if (error || secsize < 512) | 698 secsize = cp->provider->sectorsize; 699 if (secsize < 512) |
708 break; 709 710 /* First look for a label at the start of the second sector. */ 711 error = g_bsd_try(gsp, cp, secsize, ms, secsize); 712 713 /* Next, look for it 64 bytes into the first sector. */ 714 if (error) 715 error = g_bsd_try(gsp, cp, secsize, ms, 64); --- 41 unchanged lines hidden --- | 700 break; 701 702 /* First look for a label at the start of the second sector. */ 703 error = g_bsd_try(gsp, cp, secsize, ms, secsize); 704 705 /* Next, look for it 64 bytes into the first sector. */ 706 if (error) 707 error = g_bsd_try(gsp, cp, secsize, ms, 64); --- 41 unchanged lines hidden --- |