Project

General

Profile

Bug #310 » diskmbr-dd.diff

TGEN, 11/25/2006 08:09 PM

View differences:

sys/kern/subr_diskmbr.c Sat Nov 25 17:07:06 2006 +0000 → sys/kern/subr_diskmbr.c Sat Nov 25 20:02:05 2006 +0000
35 35
 *
36 36
 *	from: @(#)ufs_disksubr.c	7.16 (Berkeley) 5/4/91
37 37
 *	from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
38
 * $FreeBSD: src/sys/kern/subr_diskmbr.c,v 1.45 2000/01/28 10:22:07 bde Exp $
38
 * $FreeBSD: src/sys/kern/subr_diskmbr.c,v 1.54 2001/12/11 05:35:43 peter Exp $
39 39
 * $DragonFly: src/sys/kern/subr_diskmbr.c,v 1.13 2006/04/30 17:22:17 dillon Exp $
40 40
 */
41 41

  
......
57 57

  
58 58
static volatile u_char dsi_debug;
59 59

  
60
/*
61
 * This is what we have embedded in every boot1 for supporting the bogus
62
 * "Dangerously Dedicated" mode. However, the old table is broken because
63
 * it has an illegal geometry in it - it specifies 256 heads (heads = end
64
 * head + 1) which causes nasty stuff when that wraps to zero in bios code.
65
 * eg: divide by zero etc. This caused the dead-thinkpad problem, numerous
66
 * SCSI bios crashes, EFI to crash, etc.
67
 *
68
 * We still have to recognize the old table though, even though we stopped
69
 * inflicting it upon the world.
70
 */
60 71
static struct dos_partition historical_bogus_partition_table[NDOSPART] = {
61 72
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
62 73
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
63 74
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
64 75
	{ 0x80, 0, 1, 0, DOSPTYP_386BSD, 255, 255, 255, 0, 50000, },
76
};
77
static struct dos_partition historical_bogus_partition_table_fixed[NDOSPART] = {
78
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
79
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
80
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
81
	{ 0x80, 0, 1, 0, DOSPTYP_386BSD, 254, 255, 255, 0, 50000, },
65 82
};
66 83

  
67 84
static int check_part (char *sname, struct dos_partition *dp,
......
102 119
	 * If ssector1 is on a cylinder >= 1024, then ssector can't be right.
103 120
	 * Allow the C/H/S for it to be 1023/ntracks-1/nsectors, or correct
104 121
	 * apart from the cylinder being reduced modulo 1024.  Always allow
105
	 * 1023/255/63.
122
	 * 1023/255/63, because this is the official way to represent
123
	 * pure-LBA for the starting position.
106 124
	 */
107 125
	if ((ssector < ssector1
108 126
	     && ((chs_ssect == nsectors && dp->dp_shd == ntracks - 1
......
122 140
		  + mbr_offset;
123 141
	esector1 = ssector1 + dp->dp_size - 1;
124 142

  
125
	/* Allow certain bogus C/H/S values for esector, as above. */
143
	/*
144
	 * Allow certain bogus C/H/S values for esector, as above. However,
145
	 * heads == 255 isn't really legal and causes some BIOS crashes. The
146
	 * correct value to indicate a pure-LBA end is 1023/heads-1/sectors -
147
	 * usually 1023/254/63. "heads" is base 0, "sectors" is base 1.
148
	 */
126 149
	if ((esector < esector1
127 150
	     && ((chs_esect == nsectors && dp->dp_ehd == ntracks - 1
128 151
		  && chs_ecyl == 1023)
......
220 243
	}
221 244

  
222 245
	if (bcmp(dp0, historical_bogus_partition_table,
223
		 sizeof historical_bogus_partition_table) == 0) {
246
		 sizeof historical_bogus_partition_table) == 0 ||
247
	    bcmp(dp0, historical_bogus_partition_table_fixed,
248
		 sizeof historical_bogus_partition_table_fixed) == 0) {
249
#if 0
224 250
		TRACE(("%s: invalid primary partition table: historical\n",
225 251
		       sname));
252
#endif /* 0 */
253
		if (bootverbose)
254
			printf(
255
     "%s: invalid primary partition table: Dangerously Dedicated (ignored)\n",
256
			       sname);
226 257
		error = EINVAL;
227 258
		goto done;
228 259
	}
    (1-1/1)