changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/cmd/disk/prep/edisk.c

revision 6248: 0e18c2fc5fab
parent 6110: cc6256d5a436
     1.1--- a/sys/src/cmd/disk/prep/edisk.c
     1.2+++ b/sys/src/cmd/disk/prep/edisk.c
     1.3@@ -713,6 +713,7 @@ enum {
     1.4 static uchar*
     1.5 readmbr(Disk *disk)
     1.6 {
     1.7+	int dosparts, protected;
     1.8 	uchar *mbr, *magic;
     1.9 	Tentry *t;
    1.10 	int i;
    1.11@@ -722,17 +723,25 @@ readmbr(Disk *disk)
    1.12 	if(magic[0] != 0x55 || magic[1] != 0xAA)
    1.13 		sysfatal("did not find master boot record");
    1.14 
    1.15+	dosparts = protected = 0;
    1.16 	for(i=0; i<NTentry; i++){
    1.17 		t = (Tentry*)&mbr[disk->secsize - 2 - (i+1)*Tentrysiz];
    1.18 		switch(t->type){
    1.19 		case 0xEE:
    1.20+			protected = 1;
    1.21 		case 0xEF:
    1.22 		case 0x00:
    1.23 			continue;
    1.24 		}
    1.25-		sysfatal("dos partition table in use");
    1.26+		dosparts++;
    1.27 	}
    1.28 
    1.29+	if(dosparts && protected && !(printflag || rdonly))
    1.30+		sysfatal("potential hybrid MBR/GPT detected, not editing");
    1.31+
    1.32+	if(dosparts && !protected)
    1.33+		sysfatal("dos partition table in use and no protective partition found");
    1.34+
    1.35 	return mbr;
    1.36 }
    1.37