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 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); |
322 secsize = cp->provider->sectorsize; 323 mediasize = cp->provider->mediasize; |
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. */ |
512 secsize = cp->provider->sectorsize; |
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. */ |
698 secsize = cp->provider->sectorsize; 699 if (secsize < 512) |
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 --- |