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 105551 2002-10-20 20:28:24Z 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 sectorsize = cp->provider->sectorsize;
196 if (sectorsize != 512)
197 break;
198 gsp->frontstuff = sectorsize * fwsectors;
199#ifdef GEOM_GPT
200 /*
201 * XXX: GPT hack: Read the second sector as well and back-off
202 * if it has the GPT signature. The ultimate behaviour would
203 * be to back-off if we detect a protective MBR (PMBR).
--- 144 unchanged lines hidden (view full) ---
348 slice = 0;
349 while (1) { /* a trick to allow us to use break */
350 error = g_getattr("MBR::type", cp, &i);
351 if (error || (i != DOSPTYP_EXT && i != DOSPTYP_EXTLBA))
352 break;
353 error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
354 if (error)
355 fwsectors = 17;
356 sectorsize = cp->provider->sectorsize;
357 if (sectorsize != 512)
358 break;
359 gsp->frontstuff = sectorsize * fwsectors;
360 for (;;) {
361 buf = g_read_data(cp, off, sectorsize, &error);
362 if (buf == NULL || error != 0)
363 break;
364 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 105551 2002-10-20 20:28:24Z 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 sectorsize = cp->provider->sectorsize;
196 if (sectorsize != 512)
197 break;
198 gsp->frontstuff = sectorsize * fwsectors;
199#ifdef GEOM_GPT
200 /*
201 * XXX: GPT hack: Read the second sector as well and back-off
202 * if it has the GPT signature. The ultimate behaviour would
203 * be to back-off if we detect a protective MBR (PMBR).
--- 144 unchanged lines hidden (view full) ---
348 slice = 0;
349 while (1) { /* a trick to allow us to use break */
350 error = g_getattr("MBR::type", cp, &i);
351 if (error || (i != DOSPTYP_EXT && i != DOSPTYP_EXTLBA))
352 break;
353 error = g_getattr("GEOM::fwsectors", cp, &fwsectors);
354 if (error)
355 fwsectors = 17;
356 sectorsize = cp->provider->sectorsize;
357 if (sectorsize != 512)
358 break;
359 gsp->frontstuff = sectorsize * fwsectors;
360 for (;;) {
361 buf = g_read_data(cp, off, sectorsize, &error);
362 if (buf == NULL || error != 0)
363 break;
364 if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa)
--- 56 unchanged lines hidden ---