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_mbr.c 105542 2002-10-20 19:18:07Z phk $
36 */
37
38#include <sys/param.h>
39#ifndef _KERNEL
40#include <stdio.h>
41#include <string.h>
42#include <signal.h>
43#include <sys/param.h>
--- 143 unchanged lines hidden (view full) ---
187 gp->dumpconf = g_mbr_dumpconf;
188 npart = 0;
189 while (1) { /* a trick to allow us to use break */
190 if (gp->rank != 2 && insist == 0)
191 break;
192 error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
193 if (error)
194 fwsectors = 17;
195 error = g_getattr("GEOM::sectorsize", cp, §orsize);
196 if (error)
197 break;
198 if (sectorsize != 512)
199 break;
200 gsp->frontstuff = sectorsize * fwsectors;
201#ifdef GEOM_GPT
202 /*
203 * XXX: GPT hack: Read the second sector as well and back-off
204 * if it has the GPT signature. The ultimate behaviour would
205 * be to back-off if we detect a protective MBR (PMBR).
--- 144 unchanged lines hidden (view full) ---
350 slice = 0;
351 while (1) { /* a trick to allow us to use break */
352 error = g_getattr("MBR::type", cp, &i);
353 if (error || (i != DOSPTYP_EXT && i != DOSPTYP_EXTLBA))
354 break;
355 error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
356 if (error)
357 fwsectors = 17;
358 error = g_getattr("GEOM::sectorsize", cp, §orsize);
359 if (error)
360 break;
361 if (sectorsize != 512)
362 break;
363 gsp->frontstuff = sectorsize * fwsectors;
364 for (;;) {
365 buf = g_read_data(cp, off, sectorsize, &error);
366 if (buf == NULL || error != 0)
367 break;
368 if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa)
--- 56 unchanged lines hidden ---
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_mbr.c 105542 2002-10-20 19:18:07Z phk $
36 */
37
38#include <sys/param.h>
39#ifndef _KERNEL
40#include <stdio.h>
41#include <string.h>
42#include <signal.h>
43#include <sys/param.h>
--- 143 unchanged lines hidden (view full) ---
187 gp->dumpconf = g_mbr_dumpconf;
188 npart = 0;
189 while (1) { /* a trick to allow us to use break */
190 if (gp->rank != 2 && insist == 0)
191 break;
192 error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
193 if (error)
194 fwsectors = 17;
195 error = g_getattr("GEOM::sectorsize", cp, §orsize);
196 if (error)
197 break;
198 if (sectorsize != 512)
199 break;
200 gsp->frontstuff = sectorsize * fwsectors;
201#ifdef GEOM_GPT
202 /*
203 * XXX: GPT hack: Read the second sector as well and back-off
204 * if it has the GPT signature. The ultimate behaviour would
205 * be to back-off if we detect a protective MBR (PMBR).
--- 144 unchanged lines hidden (view full) ---
350 slice = 0;
351 while (1) { /* a trick to allow us to use break */
352 error = g_getattr("MBR::type", cp, &i);
353 if (error || (i != DOSPTYP_EXT && i != DOSPTYP_EXTLBA))
354 break;
355 error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
356 if (error)
357 fwsectors = 17;
358 error = g_getattr("GEOM::sectorsize", cp, §orsize);
359 if (error)
360 break;
361 if (sectorsize != 512)
362 break;
363 gsp->frontstuff = sectorsize * fwsectors;
364 for (;;) {
365 buf = g_read_data(cp, off, sectorsize, &error);
366 if (buf == NULL || error != 0)
367 break;
368 if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa)
--- 56 unchanged lines hidden ---