Sun Jan 29 16:01:37 2012 UTC ()
Add support for RDB-partitioned disks.
When an RDB block was found on the disk we cannot change the disk layout,
and everything which has to do with MBR partitioning will be skipped.


(phx)
diff -r1.10 -r1.11 src/distrib/utils/sysinst/arch/ofppc/md.c
diff -r1.6 -r1.7 src/distrib/utils/sysinst/arch/ofppc/md.h

cvs diff -r1.10 -r1.11 src/distrib/utils/sysinst/arch/ofppc/Attic/md.c (switch to unified diff)

--- src/distrib/utils/sysinst/arch/ofppc/Attic/md.c 2011/11/04 11:27:04 1.10
+++ src/distrib/utils/sysinst/arch/ofppc/Attic/md.c 2012/01/29 16:01:36 1.11
@@ -1,550 +1,655 @@ @@ -1,550 +1,655 @@
1/* $NetBSD: md.c,v 1.10 2011/11/04 11:27:04 martin Exp $ */ 1/* $NetBSD: md.c,v 1.11 2012/01/29 16:01:36 phx Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Piermont Information Systems Inc. 4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Based on code written by Philip A. Nelson for Piermont Information 7 * Based on code written by Philip A. Nelson for Piermont Information
8 * Systems Inc. 8 * Systems Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of Piermont Information Systems Inc. may not be used to endorse 18 * 3. The name of Piermont Information Systems Inc. may not be used to endorse
19 * or promote products derived from this software without specific prior 19 * or promote products derived from this software without specific prior
20 * written permission. 20 * written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' 22 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 25 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE. 32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35/* md.c -- ofppc machine specific routines */ 35/* md.c -- ofppc machine specific routines */
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/sysctl.h> 38#include <sys/sysctl.h>
 39#include <sys/disklabel_rdb.h>
39#include <stdio.h> 40#include <stdio.h>
40#include <util.h> 41#include <util.h>
41#include <machine/cpu.h> 42#include <machine/cpu.h>
42 43
43#include "defs.h" 44#include "defs.h"
44#include "md.h" 45#include "md.h"
45#include "msg_defs.h" 46#include "msg_defs.h"
46#include "menu_defs.h" 47#include "menu_defs.h"
47#include "endian.h" 48#include "endian.h"
48 49
 50static int check_rdb(void);
 51static uint32_t rdbchksum(void *);
 52
49/* We use MBR_PTYPE_PREP like port-prep does. */ 53/* We use MBR_PTYPE_PREP like port-prep does. */
50static int nonewfsmsdos = 0, nobootfix = 0, noprepfix=0; 54static int nonewfsmsdos = 0, nobootfix = 0, noprepfix=0;
51static int bootpart_fat12 = PART_BOOT_FAT12; 55static int bootpart_fat12 = PART_BOOT_FAT12;
52static int bootpart_binfo = PART_BOOT_BINFO; 56static int bootpart_binfo = PART_BOOT_BINFO;
53static int bootpart_prep = PART_BOOT_PREP; 57static int bootpart_prep = PART_BOOT_PREP;
54static int bootinfo_mbr = 1; 58static int bootinfo_mbr = 1;
 59static int rdb_found = 0;
55 60
56/* bootstart/bootsize are for the fat */ 61/* bootstart/bootsize are for the fat */
57int binfostart, binfosize, bprepstart, bprepsize; 62int binfostart, binfosize, bprepstart, bprepsize;
58 63
59void 64void
60md_init(void) 65md_init(void)
61{ 66{
62} 67}
63 68
64void 69void
65md_init_set_status(int flags) 70md_init_set_status(int flags)
66{ 71{
 72
67 (void)flags; 73 (void)flags;
68} 74}
69 75
70int 76int
71md_get_info(void) 77md_get_info(void)
72{ 78{
 79
 80 if (check_rdb())
 81 return 1;
 82
73 return set_bios_geom_with_mbr_guess(); 83 return set_bios_geom_with_mbr_guess();
74} 84}
75 85
76/* 86/*
77 * md back-end code for menu-driven BSD disklabel editor. 87 * md back-end code for menu-driven BSD disklabel editor.
78 */ 88 */
79int 89int
80md_make_bsd_partitions(void) 90md_make_bsd_partitions(void)
81{ 91{
82 int i; 92 int i;
83 int part; 93 int part;
84 int maxpart = getmaxpartitions(); 94 int maxpart = getmaxpartitions();
85 int partstart; 95 int partstart;
86 int part_raw, part_bsd; 96 int part_raw, part_bsd;
87 int ptend; 97 int ptend;
88 int no_swap = 0; 98 int no_swap = 0;
89 partinfo *p; 99 partinfo *p;
90 100
 101 if (rdb_found) {
 102 /*
 103 * We found RDB partitions on the disk, which cannot be
 104 * modified by rewriting the disklabel.
 105 * So just use what we have got.
 106 */
 107 for (part = 0; part < maxpart; part++) {
 108 if (PI_ISBSDFS(&bsdlabel[part])) {
 109 bsdlabel[part].pi_flags |=
 110 PIF_NEWFS | PIF_MOUNT;
 111
 112 if (part == PART_A)
 113 strcpy(bsdlabel[part].pi_mount, "/");
 114 }
 115 }
 116
 117 part_bsd = part_raw = getrawpartition();
 118 if (part_raw == -1)
 119 part_raw = PART_C; /* for sanity... */
 120 bsdlabel[part_raw].pi_offset = 0;
 121 bsdlabel[part_raw].pi_size = dlsize;
 122
 123 set_sizemultname_meg();
 124rdb_edit_check:
 125 if (edit_and_check_label(bsdlabel, maxpart, part_raw,
 126 part_bsd) == 0) {
 127 msg_display(MSG_abort);
 128 return 0;
 129 }
 130 if (md_check_partitions() == 0)
 131 goto rdb_edit_check;
 132
 133 return 1;
 134 }
 135
91 /* 136 /*
92 * Initialize global variables that track space used on this disk. 137 * Initialize global variables that track space used on this disk.
93 * Standard 4.4BSD 8-partition labels always cover whole disk. 138 * Standard 4.4BSD 8-partition labels always cover whole disk.
94 */ 139 */
95 if (ptsize == 0) 140 if (ptsize == 0)
96 ptsize = dlsize - ptstart; 141 ptsize = dlsize - ptstart;
97 if (dlsize == 0) 142 if (dlsize == 0)
98 dlsize = ptstart + ptsize; 143 dlsize = ptstart + ptsize;
99 144
100 partstart = ptstart; 145 partstart = ptstart;
101 ptend = ptstart + ptsize; 146 ptend = ptstart + ptsize;
102 147
103 /* Ask for layout type -- standard or special */ 148 /* Ask for layout type -- standard or special */
104 msg_display(MSG_layout, 149 msg_display(MSG_layout,
105 ptsize / (MEG / sectorsize), 150 ptsize / (MEG / sectorsize),
106 DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE, 151 DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE,
107 DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB); 152 DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB);
108 153
109 process_menu(MENU_layout, NULL); 154 process_menu(MENU_layout, NULL);
110 155
111 /* Set so we use the 'real' geometry for rounding, input in MB */ 156 /* Set so we use the 'real' geometry for rounding, input in MB */
112 current_cylsize = dlcylsize; 157 current_cylsize = dlcylsize;
113 set_sizemultname_meg(); 158 set_sizemultname_meg();
114 159
115 /* Build standard partitions */ 160 /* Build standard partitions */
116 memset(&bsdlabel, 0, sizeof bsdlabel); 161 memset(&bsdlabel, 0, sizeof bsdlabel);
117 162
118 /* Set initial partition types to unused */ 163 /* Set initial partition types to unused */
119 for (part = 0 ; part < maxpart ; ++part) 164 for (part = 0 ; part < maxpart ; ++part)
120 bsdlabel[part].pi_fstype = FS_UNUSED; 165 bsdlabel[part].pi_fstype = FS_UNUSED;
121 166
122 /* Whole disk partition */ 167 /* Whole disk partition */
123 part_raw = getrawpartition(); 168 part_raw = getrawpartition();
124 if (part_raw == -1) 169 if (part_raw == -1)
125 part_raw = PART_C; /* for sanity... */ 170 part_raw = PART_C; /* for sanity... */
126 bsdlabel[part_raw].pi_offset = 0; 171 bsdlabel[part_raw].pi_offset = 0;
127 bsdlabel[part_raw].pi_size = dlsize; 172 bsdlabel[part_raw].pi_size = dlsize;
128 173
129 if (part_raw == PART_D) { 174 if (part_raw == PART_D) {
130 /* Probably a system that expects an i386 style mbr */ 175 /* Probably a system that expects an i386 style mbr */
131 part_bsd = PART_C; 176 part_bsd = PART_C;
132 bsdlabel[PART_C].pi_offset = ptstart; 177 bsdlabel[PART_C].pi_offset = ptstart;
133 bsdlabel[PART_C].pi_size = ptsize; 178 bsdlabel[PART_C].pi_size = ptsize;
134 } else { 179 } else {
135 part_bsd = part_raw; 180 part_bsd = part_raw;
136 } 181 }
137 182
138 if (bootsize != 0) { 183 if (bootsize != 0) {
139 bsdlabel[PART_BOOT_FAT12].pi_fstype = FS_MSDOS; 184 bsdlabel[PART_BOOT_FAT12].pi_fstype = FS_MSDOS;
140 bsdlabel[PART_BOOT_FAT12].pi_size = bootsize; 185 bsdlabel[PART_BOOT_FAT12].pi_size = bootsize;
141 bsdlabel[PART_BOOT_FAT12].pi_offset = bootstart; 186 bsdlabel[PART_BOOT_FAT12].pi_offset = bootstart;
142 bsdlabel[PART_BOOT_FAT12].pi_flags |= PART_BOOT_FAT12_PI_FLAGS; 187 bsdlabel[PART_BOOT_FAT12].pi_flags |= PART_BOOT_FAT12_PI_FLAGS;
143 strlcpy(bsdlabel[PART_BOOT_FAT12].pi_mount, 188 strlcpy(bsdlabel[PART_BOOT_FAT12].pi_mount,
144 PART_BOOT_FAT12_PI_MOUNT, 189 PART_BOOT_FAT12_PI_MOUNT,
145 sizeof bsdlabel[PART_BOOT_FAT12].pi_mount); 190 sizeof bsdlabel[PART_BOOT_FAT12].pi_mount);
146 } 191 }
147 if (binfosize != 0) { 192 if (binfosize != 0) {
148 bsdlabel[PART_BOOT_BINFO].pi_fstype = FS_OTHER; 193 bsdlabel[PART_BOOT_BINFO].pi_fstype = FS_OTHER;
149 bsdlabel[PART_BOOT_BINFO].pi_size = binfosize; 194 bsdlabel[PART_BOOT_BINFO].pi_size = binfosize;
150 bsdlabel[PART_BOOT_BINFO].pi_offset = binfostart; 195 bsdlabel[PART_BOOT_BINFO].pi_offset = binfostart;
151 } 196 }
152 if (bprepsize != 0) { 197 if (bprepsize != 0) {
153 bsdlabel[PART_BOOT_PREP].pi_fstype = FS_BOOT; 198 bsdlabel[PART_BOOT_PREP].pi_fstype = FS_BOOT;
154 bsdlabel[PART_BOOT_PREP].pi_size = bprepsize; 199 bsdlabel[PART_BOOT_PREP].pi_size = bprepsize;
155 bsdlabel[PART_BOOT_PREP].pi_offset = bprepstart; 200 bsdlabel[PART_BOOT_PREP].pi_offset = bprepstart;
156 } 201 }
157 202
158#ifdef PART_REST 203#ifdef PART_REST
159 bsdlabel[PART_REST].pi_offset = 0; 204 bsdlabel[PART_REST].pi_offset = 0;
160 bsdlabel[PART_REST].pi_size = ptstart; 205 bsdlabel[PART_REST].pi_size = ptstart;
161#endif 206#endif
162 207
163 /* 208 /*
164 * Save any partitions that are outside the area we are 209 * Save any partitions that are outside the area we are
165 * going to use. 210 * going to use.
166 * In particular this saves details of the other MBR 211 * In particular this saves details of the other MBR
167 * partitions on a multiboot i386 system. 212 * partitions on a multiboot i386 system.
168 */ 213 */
169 for (i = maxpart; i--;) { 214 for (i = maxpart; i--;) {
170 if (bsdlabel[i].pi_size != 0) 215 if (bsdlabel[i].pi_size != 0)
171 /* Don't overwrite special partitions */ 216 /* Don't overwrite special partitions */
172 continue; 217 continue;
173 p = &oldlabel[i]; 218 p = &oldlabel[i];
174 if (p->pi_fstype == FS_UNUSED || p->pi_size == 0) 219 if (p->pi_fstype == FS_UNUSED || p->pi_size == 0)
175 continue; 220 continue;
176 if (layoutkind == 4) { 221 if (layoutkind == 4) {
177 if (PI_ISBSDFS(p)) 222 if (PI_ISBSDFS(p))
178 p->pi_flags |= PIF_MOUNT; 223 p->pi_flags |= PIF_MOUNT;
179 } else { 224 } else {
180 if (p->pi_offset < ptstart + ptsize && 225 if (p->pi_offset < ptstart + ptsize &&
181 p->pi_offset + p->pi_size > ptstart) 226 p->pi_offset + p->pi_size > ptstart)
182 /* Not outside area we are allocating */ 227 /* Not outside area we are allocating */
183 continue; 228 continue;
184 if (p->pi_fstype == FS_SWAP) 229 if (p->pi_fstype == FS_SWAP)
185 no_swap = 1; 230 no_swap = 1;
186 } 231 }
187 bsdlabel[i] = oldlabel[i]; 232 bsdlabel[i] = oldlabel[i];
188 } 233 }
189 234
190 if (layoutkind == 4) { 235 if (layoutkind == 4) {
191 /* XXX Check we have a sensible layout */ 236 /* XXX Check we have a sensible layout */
192 ; 237 ;
193 } else 238 } else
194 get_ptn_sizes(partstart, ptend - partstart, no_swap); 239 get_ptn_sizes(partstart, ptend - partstart, no_swap);
195 240
196 /* 241 /*
197 * OK, we have a partition table. Give the user the chance to 242 * OK, we have a partition table. Give the user the chance to
198 * edit it and verify it's OK, or abort altogether. 243 * edit it and verify it's OK, or abort altogether.
199 */ 244 */
200 edit_check: 245 edit_check:
201 if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) { 246 if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) {
202 msg_display(MSG_abort); 247 msg_display(MSG_abort);
203 return 0; 248 return 0;
204 } 249 }
205 if (md_check_partitions() == 0) 250 if (md_check_partitions() == 0)
206 goto edit_check; 251 goto edit_check;
207 252
208 /* Disk name */ 253 /* Disk name */
209 msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname); 254 msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname);
210 255
211 /* save label to disk for MI code to update. */ 256 /* save label to disk for MI code to update. */
212 (void) savenewlabel(bsdlabel, maxpart); 257 (void) savenewlabel(bsdlabel, maxpart);
213 258
214 /* Everything looks OK. */ 259 /* Everything looks OK. */
215 return 1; 260 return 1;
216} 261}
217 262
218/* 263/*
219 * any additional partition validation 264 * any additional partition validation
220 */ 265 */
221int 266int
222md_check_partitions(void) 267md_check_partitions(void)
223{ 268{
224 int part, fprep=0, ffat=0; 269 int part, fprep=0, ffat=0;
225 270
 271 if (rdb_found)
 272 return 1;
 273
226 /* we need to find a boot partition, otherwise we can't create 274 /* we need to find a boot partition, otherwise we can't create
227 * our msdos fs boot partition. We make the assumption that 275 * our msdos fs boot partition. We make the assumption that
228 * the user hasn't done something stupid, like move it away 276 * the user hasn't done something stupid, like move it away
229 * from the MBR partition. 277 * from the MBR partition.
230 */ 278 */
231 for (part = PART_A; part < MAXPARTITIONS; part++) { 279 for (part = PART_A; part < MAXPARTITIONS; part++) {
232 if (bsdlabel[part].pi_fstype == FS_MSDOS) { 280 if (bsdlabel[part].pi_fstype == FS_MSDOS) {
233 bootpart_fat12 = part; 281 bootpart_fat12 = part;
234 ffat++; 282 ffat++;
235 } else if (bsdlabel[part].pi_fstype == FS_BOOT) { 283 } else if (bsdlabel[part].pi_fstype == FS_BOOT) {
236 bootpart_prep = part; 284 bootpart_prep = part;
237 fprep++; 285 fprep++;
238 } else if (bsdlabel[part].pi_fstype == FS_OTHER) { 286 } else if (bsdlabel[part].pi_fstype == FS_OTHER) {
239 bootpart_binfo = part; 287 bootpart_binfo = part;
240 fprep++; 288 fprep++;
241 } 289 }
242 } 290 }
243 /* oh, the confusion */ 291 /* oh, the confusion */
244 if (ffat >= 1 && fprep < 2) 292 if (ffat >= 1 && fprep < 2)
245 return 1; 293 return 1;
246 if (ffat < 1 && fprep >= 2) 294 if (ffat < 1 && fprep >= 2)
247 return 2; 295 return 2;
248 if (ffat >=1 && fprep >= 2) 296 if (ffat >=1 && fprep >= 2)
249 return 3; 297 return 3;
250 298
251 msg_display(MSG_nobootpartdisklabel); 299 msg_display(MSG_nobootpartdisklabel);
252 process_menu(MENU_ok, NULL); 300 process_menu(MENU_ok, NULL);
253 return 0; 301 return 0;
254} 302}
255 303
256/* 304/*
257 * hook called before writing new disklabel. 305 * hook called before writing new disklabel.
258 */ 306 */
259int 307int
260md_pre_disklabel(void) 308md_pre_disklabel(void)
261{ 309{
 310
 311 if (rdb_found)
 312 return 0;
 313
262 msg_display(MSG_dofdisk); 314 msg_display(MSG_dofdisk);
263 315
264 /* write edited MBR onto disk. */ 316 /* write edited MBR onto disk. */
265 if (write_mbr(diskdev, &mbr, 1) != 0) { 317 if (write_mbr(diskdev, &mbr, 1) != 0) {
266 msg_display(MSG_wmbrfail); 318 msg_display(MSG_wmbrfail);
267 process_menu(MENU_ok, NULL); 319 process_menu(MENU_ok, NULL);
268 return 1; 320 return 1;
269 } 321 }
270 return 0; 322 return 0;
271} 323}
272 324
273/* 325/*
274 * hook called after writing disklabel to new target disk. 326 * hook called after writing disklabel to new target disk.
275 */ 327 */
276int 328int
277md_post_disklabel(void) 329md_post_disklabel(void)
278{ 330{
279 char bootdev[100]; 331 char bootdev[100];
280 332
281 if (bootstart == 0 || bootsize == 0) 333 if (bootstart == 0 || bootsize == 0 || rdb_found)
282 return 0; 334 return 0;
283 335
284 snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev, 336 snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev,
285 'a'+bootpart_fat12); 337 'a'+bootpart_fat12);
286 run_program(RUN_DISPLAY, "/sbin/newfs_msdos %s", bootdev); 338 run_program(RUN_DISPLAY, "/sbin/newfs_msdos %s", bootdev);
287 339
288 return 0; 340 return 0;
289} 341}
290 342
291/* 343/*
292 * hook called after upgrade() or install() has finished setting 344 * hook called after upgrade() or install() has finished setting
293 * up the target disk but immediately before the user is given the 345 * up the target disk but immediately before the user is given the
294 * ``disks are now set up'' message. 346 * ``disks are now set up'' message.
295 */ 347 */
296int 348int
297md_post_newfs(void) 349md_post_newfs(void)
298{ 350{
299 351
300 /* No bootblock. We use ofwboot from a partition visiable by OFW. */ 352 /* No bootblock. We use ofwboot from a partition visiable by OFW. */
301 return 0; 353 return 0;
302} 354}
303 355
304int 356int
305md_post_extract(void) 357md_post_extract(void)
306{ 358{
307 char bootdev[100], bootbdev[100], version[64]; 359 char bootdev[100], bootbdev[100], version[64];
308 360
309 /* if we can't make it bootable, just punt */ 361 /* if we can't make it bootable, just punt */
310 if (nobootfix && noprepfix) 362 if ((nobootfix && noprepfix) || rdb_found)
311 return 0; 363 return 0;
312 364
313 snprintf(version, sizeof version, "NetBSD/%s %s", MACH, REL); 365 snprintf(version, sizeof version, "NetBSD/%s %s", MACH, REL);
314 run_program(RUN_DISPLAY, "/usr/mdec/mkbootinfo '%s' %d " 366 run_program(RUN_DISPLAY, "/usr/mdec/mkbootinfo '%s' %d "
315 "/tmp/bootinfo.txt", version, bootinfo_mbr); 367 "/tmp/bootinfo.txt", version, bootinfo_mbr);
316 368
317 if (!nobootfix) { 369 if (!nobootfix) {
318 run_program(RUN_DISPLAY, "/bin/mkdir -p /%s/boot/ppc", 370 run_program(RUN_DISPLAY, "/bin/mkdir -p /%s/boot/ppc",
319 target_prefix()); 371 target_prefix());
320 run_program(RUN_DISPLAY, "/bin/mkdir -p /%s/boot/netbsd", 372 run_program(RUN_DISPLAY, "/bin/mkdir -p /%s/boot/netbsd",
321 target_prefix()); 373 target_prefix());
322 run_program(RUN_DISPLAY, "/bin/cp /usr/mdec/ofwboot " 374 run_program(RUN_DISPLAY, "/bin/cp /usr/mdec/ofwboot "
323 "/%s/boot/netbsd", target_prefix()); 375 "/%s/boot/netbsd", target_prefix());
324 run_program(RUN_DISPLAY, "/bin/cp /tmp/bootinfo.txt " 376 run_program(RUN_DISPLAY, "/bin/cp /tmp/bootinfo.txt "
325 "/%s/boot/ppc", target_prefix()); 377 "/%s/boot/ppc", target_prefix());
326 run_program(RUN_DISPLAY, "/bin/cp /usr/mdec/ofwboot " 378 run_program(RUN_DISPLAY, "/bin/cp /usr/mdec/ofwboot "
327 "/%s/boot/ofwboot", target_prefix()); 379 "/%s/boot/ofwboot", target_prefix());
328 } 380 }
329 381
330 if (!noprepfix) { 382 if (!noprepfix) {
331 snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev, 383 snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev,
332 'a'+bootpart_prep); 384 'a'+bootpart_prep);
333 snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", diskdev, 385 snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", diskdev,
334 'a'+bootpart_prep); 386 'a'+bootpart_prep);
335 run_program(RUN_DISPLAY, "/bin/dd if=/dev/zero of=%s bs=512", 387 run_program(RUN_DISPLAY, "/bin/dd if=/dev/zero of=%s bs=512",
336 bootdev); 388 bootdev);
337 run_program(RUN_DISPLAY, "/bin/dd if=/usr/mdec/ofwboot " 389 run_program(RUN_DISPLAY, "/bin/dd if=/usr/mdec/ofwboot "
338 "of=%s bs=512", bootbdev); 390 "of=%s bs=512", bootbdev);
339 391
340 snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev, 392 snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev,
341 'a'+bootpart_binfo); 393 'a'+bootpart_binfo);
342 snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", diskdev, 394 snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", diskdev,
343 'a'+bootpart_binfo); 395 'a'+bootpart_binfo);
344 run_program(RUN_DISPLAY, "/bin/dd if=/dev/zero of=%s bs=512", 396 run_program(RUN_DISPLAY, "/bin/dd if=/dev/zero of=%s bs=512",
345 bootdev); 397 bootdev);
346 run_program(RUN_DISPLAY, "/bin/dd if=/tmp/bootinfo.txt " 398 run_program(RUN_DISPLAY, "/bin/dd if=/tmp/bootinfo.txt "
347 "of=%s bs=512", bootbdev); 399 "of=%s bs=512", bootbdev);
348 } 400 }
349 401
350 return 0; 402 return 0;
351} 403}
352 404
353void 405void
354md_cleanup_install(void) 406md_cleanup_install(void)
355{ 407{
 408
356#ifndef DEBUG 409#ifndef DEBUG
357 enable_rc_conf(); 410 enable_rc_conf();
358#endif 411#endif
359} 412}
360 413
361int 414int
362md_pre_update(void) 415md_pre_update(void)
363{ 416{
364 struct mbr_partition *part; 417 struct mbr_partition *part;
365 mbr_info_t *ext; 418 mbr_info_t *ext;
366 int i; 419 int i;
367 420
 421 if (check_rdb())
 422 return 1;
 423
368 read_mbr(diskdev, &mbr); 424 read_mbr(diskdev, &mbr);
369 /* do a sanity check of the partition table */ 425 /* do a sanity check of the partition table */
370 for (ext = &mbr; ext; ext = ext->extended) { 426 for (ext = &mbr; ext; ext = ext->extended) {
371 part = ext->mbr.mbr_parts; 427 part = ext->mbr.mbr_parts;
372 for (i = 0; i < MBR_PART_COUNT; part++, i++) { 428 for (i = 0; i < MBR_PART_COUNT; part++, i++) {
373 if (part->mbrp_type == MBR_PTYPE_PREP && 429 if (part->mbrp_type == MBR_PTYPE_PREP &&
374 part->mbrp_size > 50) 430 part->mbrp_size > 50)
375 bootinfo_mbr = i+1; 431 bootinfo_mbr = i+1;
376 if (part->mbrp_type == MBR_PTYPE_RESERVED_x21 && 432 if (part->mbrp_type == MBR_PTYPE_RESERVED_x21 &&
377 part->mbrp_size < (MIN_FAT12_BOOT/512)) { 433 part->mbrp_size < (MIN_FAT12_BOOT/512)) {
378 msg_display(MSG_boottoosmall); 434 msg_display(MSG_boottoosmall);
379 msg_display_add(MSG_nobootpartdisklabel, 0); 435 msg_display_add(MSG_nobootpartdisklabel, 0);
380 process_menu(MENU_yesno, NULL); 436 process_menu(MENU_yesno, NULL);
381 if (!yesno) 437 if (!yesno)
382 return 0; 438 return 0;
383 nobootfix = 1; 439 nobootfix = 1;
384 } 440 }
385 } 441 }
386 } 442 }
387 443
388 i = md_check_partitions(); 444 i = md_check_partitions();
389 switch (i) { 445 switch (i) {
390 case 0: nobootfix=1; noprepfix=1; break; 446 case 0: nobootfix=1; noprepfix=1; break;
391 case 1: noprepfix=1; break; 447 case 1: noprepfix=1; break;
392 case 2: nobootfix=1; break; 448 case 2: nobootfix=1; break;
393 default: break; 449 default: break;
394 } 450 }
395 451
396 return 1; 452 return 1;
397} 453}
398 454
399/* Upgrade support */ 455/* Upgrade support */
400int 456int
401md_update(void) 457md_update(void)
402{ 458{
 459
403 nonewfsmsdos = 1; 460 nonewfsmsdos = 1;
404 md_post_newfs(); 461 md_post_newfs();
405 return 1; 462 return 1;
406} 463}
407 464
408 465
409int 466int
410md_check_mbr(mbr_info_t *mbri) 467md_check_mbr(mbr_info_t *mbri)
411{ 468{
412 mbr_info_t *ext; 469 mbr_info_t *ext;
413 struct mbr_partition *part; 470 struct mbr_partition *part;
414 int i; 471 int i;
415 472
416 for (ext = mbri; ext; ext = ext->extended) { 473 for (ext = mbri; ext; ext = ext->extended) {
417 part = ext->mbr.mbr_parts; 474 part = ext->mbr.mbr_parts;
418 for (i = 0; i < MBR_PART_COUNT; part++, i++) { 475 for (i = 0; i < MBR_PART_COUNT; part++, i++) {
419 if (part->mbrp_type == MBR_PTYPE_FAT12) { 476 if (part->mbrp_type == MBR_PTYPE_FAT12) {
420 bootstart = part->mbrp_start; 477 bootstart = part->mbrp_start;
421 bootsize = part->mbrp_size; 478 bootsize = part->mbrp_size;
422 } else if (part->mbrp_type == MBR_PTYPE_PREP && 479 } else if (part->mbrp_type == MBR_PTYPE_PREP &&
423 part->mbrp_size < 50) { 480 part->mbrp_size < 50) {
424 /* this is the bootinfo partition */ 481 /* this is the bootinfo partition */
425 binfostart = part->mbrp_start; 482 binfostart = part->mbrp_start;
426 binfosize = part->mbrp_size; 483 binfosize = part->mbrp_size;
427 bootinfo_mbr = i+1; 484 bootinfo_mbr = i+1;
428 } else if (part->mbrp_type == MBR_PTYPE_PREP && 485 } else if (part->mbrp_type == MBR_PTYPE_PREP &&
429 part->mbrp_size > 50) { 486 part->mbrp_size > 50) {
430 bprepstart = part->mbrp_start; 487 bprepstart = part->mbrp_start;
431 bprepsize = part->mbrp_size; 488 bprepsize = part->mbrp_size;
432 } 489 }
433 break; 490 break;
434 } 491 }
435 } 492 }
436 493
437 /* we need to either have a pair of prep partitions, or a single 494 /* we need to either have a pair of prep partitions, or a single
438 * fat. if neither, things are broken. */ 495 * fat. if neither, things are broken. */
439 if (!(bootsize >= (MIN_FAT12_BOOT/512) || 496 if (!(bootsize >= (MIN_FAT12_BOOT/512) ||
440 (binfosize >= (MIN_BINFO_BOOT/512) && 497 (binfosize >= (MIN_BINFO_BOOT/512) &&
441 bprepsize >= (MIN_PREP_BOOT/512)))) { 498 bprepsize >= (MIN_PREP_BOOT/512)))) {
442 msg_display(MSG_bootnotright); 499 msg_display(MSG_bootnotright);
443 msg_display_add(MSG_reeditpart, 0); 500 msg_display_add(MSG_reeditpart, 0);
444 process_menu(MENU_yesno, NULL); 501 process_menu(MENU_yesno, NULL);
445 if (!yesno) 502 if (!yesno)
446 return 0; 503 return 0;
447 return 1; 504 return 1;
448 } 505 }
449 506
450 /* check the prep partitions */ 507 /* check the prep partitions */
451 if ((binfosize > 0 || bprepsize > 0) && 508 if ((binfosize > 0 || bprepsize > 0) &&
452 (binfosize < (MIN_BINFO_BOOT/512) || 509 (binfosize < (MIN_BINFO_BOOT/512) ||
453 bprepsize < (MIN_PREP_BOOT/512))) { 510 bprepsize < (MIN_PREP_BOOT/512))) {
454 msg_display(MSG_preptoosmall); 511 msg_display(MSG_preptoosmall);
455 msg_display_add(MSG_reeditpart, 0); 512 msg_display_add(MSG_reeditpart, 0);
456 process_menu(MENU_yesno, NULL); 513 process_menu(MENU_yesno, NULL);
457 if (!yesno) 514 if (!yesno)
458 return 0; 515 return 0;
459 return 1; 516 return 1;
460 } 517 }
461 518
462 /* check the fat12 parititons */ 519 /* check the fat12 parititons */
463 if (bootsize > 0 && bootsize < (MIN_FAT12_BOOT/512)) { 520 if (bootsize > 0 && bootsize < (MIN_FAT12_BOOT/512)) {
464 msg_display(MSG_boottoosmall); 521 msg_display(MSG_boottoosmall);
465 msg_display_add(MSG_reeditpart, 0); 522 msg_display_add(MSG_reeditpart, 0);
466 process_menu(MENU_yesno, NULL); 523 process_menu(MENU_yesno, NULL);
467 if (!yesno) 524 if (!yesno)
468 return 0; 525 return 0;
469 return 1; 526 return 1;
470 } 527 }
471 528
472 /* if both sets contain zero, thats bad */ 529 /* if both sets contain zero, thats bad */
473 if ((bootstart == 0 || bootsize == 0) && 530 if ((bootstart == 0 || bootsize == 0) &&
474 (binfosize == 0 || binfostart == 0 || 531 (binfosize == 0 || binfostart == 0 ||
475 bprepsize == 0 || bprepstart == 0)) { 532 bprepsize == 0 || bprepstart == 0)) {
476 msg_display(MSG_nobootpart); 533 msg_display(MSG_nobootpart);
477 msg_display_add(MSG_reeditpart, 0); 534 msg_display_add(MSG_reeditpart, 0);
478 process_menu(MENU_yesno, NULL); 535 process_menu(MENU_yesno, NULL);
479 if (!yesno) 536 if (!yesno)
480 return 0; 537 return 0;
481 return 1; 538 return 1;
482 } 539 }
483 return 2; 540 return 2;
484} 541}
485 542
486/* 543/*
487 * NOTE, we use a reserved partition type, because some RS/6000 machines hang 544 * NOTE, we use a reserved partition type, because some RS/6000 machines hang
488 * hard if they find a FAT12, and if we use type prep, that indicates that 545 * hard if they find a FAT12, and if we use type prep, that indicates that
489 * it should be read raw. 546 * it should be read raw.
490 * One partition for FAT12 booting 547 * One partition for FAT12 booting
491 * One partition for NetBSD 548 * One partition for NetBSD
492 * One partition to hold the bootinfo.txt file 549 * One partition to hold the bootinfo.txt file
493 * One partition to hold ofwboot 550 * One partition to hold ofwboot
494 */ 551 */
495 552
496int 553int
497md_mbr_use_wholedisk(mbr_info_t *mbri) 554md_mbr_use_wholedisk(mbr_info_t *mbri)
498{ 555{
499 struct mbr_sector *mbrs = &mbri->mbr; 556 struct mbr_sector *mbrs = &mbri->mbr;
500 mbr_info_t *ext; 557 mbr_info_t *ext;
501 struct mbr_partition *part; 558 struct mbr_partition *part;
502 559
503 part = &mbrs->mbr_parts[0]; 560 part = &mbrs->mbr_parts[0];
504 /* Set the partition information for full disk usage. */ 561 /* Set the partition information for full disk usage. */
505 while ((ext = mbri->extended)) { 562 while ((ext = mbri->extended)) {
506 mbri->extended = ext->extended; 563 mbri->extended = ext->extended;
507 free(ext); 564 free(ext);
508 } 565 }
509 memset(part, 0, MBR_PART_COUNT * sizeof *part); 566 memset(part, 0, MBR_PART_COUNT * sizeof *part);
510 567
511 part[0].mbrp_type = MBR_PTYPE_RESERVED_x21; 568 part[0].mbrp_type = MBR_PTYPE_RESERVED_x21;
512 part[0].mbrp_size = FAT12_BOOT_SIZE/512; 569 part[0].mbrp_size = FAT12_BOOT_SIZE/512;
513 part[0].mbrp_start = bsec; 570 part[0].mbrp_start = bsec;
514 part[0].mbrp_flag = 0; 571 part[0].mbrp_flag = 0;
515 572
516 part[1].mbrp_type = MBR_PTYPE_NETBSD; 573 part[1].mbrp_type = MBR_PTYPE_NETBSD;
517 part[1].mbrp_size = dlsize - (bsec + FAT12_BOOT_SIZE/512 + 574 part[1].mbrp_size = dlsize - (bsec + FAT12_BOOT_SIZE/512 +
518 BINFO_BOOT_SIZE/512 + PREP_BOOT_SIZE/512); 575 BINFO_BOOT_SIZE/512 + PREP_BOOT_SIZE/512);
519 part[1].mbrp_start = bsec + FAT12_BOOT_SIZE/512 + BINFO_BOOT_SIZE/512 + 576 part[1].mbrp_start = bsec + FAT12_BOOT_SIZE/512 + BINFO_BOOT_SIZE/512 +
520 PREP_BOOT_SIZE/512; 577 PREP_BOOT_SIZE/512;
521 part[1].mbrp_flag = MBR_PFLAG_ACTIVE; 578 part[1].mbrp_flag = MBR_PFLAG_ACTIVE;
522 579
523 part[2].mbrp_type = MBR_PTYPE_PREP; 580 part[2].mbrp_type = MBR_PTYPE_PREP;
524 part[2].mbrp_size = BINFO_BOOT_SIZE/512; 581 part[2].mbrp_size = BINFO_BOOT_SIZE/512;
525 part[2].mbrp_start = bsec + FAT12_BOOT_SIZE/512; 582 part[2].mbrp_start = bsec + FAT12_BOOT_SIZE/512;
526 part[2].mbrp_flag = 0; 583 part[2].mbrp_flag = 0;
527 584
528 part[3].mbrp_type = MBR_PTYPE_PREP; 585 part[3].mbrp_type = MBR_PTYPE_PREP;
529 part[3].mbrp_size = PREP_BOOT_SIZE/512; 586 part[3].mbrp_size = PREP_BOOT_SIZE/512;
530 part[3].mbrp_start = bsec + FAT12_BOOT_SIZE/512 + BINFO_BOOT_SIZE/512; 587 part[3].mbrp_start = bsec + FAT12_BOOT_SIZE/512 + BINFO_BOOT_SIZE/512;
531 part[3].mbrp_flag = 0; 588 part[3].mbrp_flag = 0;
532 589
533 ptstart = part[1].mbrp_start; 590 ptstart = part[1].mbrp_start;
534 ptsize = part[1].mbrp_size; 591 ptsize = part[1].mbrp_size;
535 bootstart = part[0].mbrp_start; 592 bootstart = part[0].mbrp_start;
536 bootsize = part[0].mbrp_size; 593 bootsize = part[0].mbrp_size;
537 binfostart = part[2].mbrp_start; 594 binfostart = part[2].mbrp_start;
538 binfosize= part[2].mbrp_size; 595 binfosize= part[2].mbrp_size;
539 bprepstart = part[3].mbrp_start; 596 bprepstart = part[3].mbrp_start;
540 bprepsize = part[3].mbrp_size; 597 bprepsize = part[3].mbrp_size;
541 bootinfo_mbr = 4; 598 bootinfo_mbr = 4;
542 599
543 return 1; 600 return 1;
544} 601}
545 602
 603const char *md_disklabel_cmd(void)
 604{
 605
 606 /* we cannot rewrite an RDB disklabel */
 607 if (rdb_found)
 608 return "echo No disklabel";
 609
 610 return "disklabel -w -r";
 611}
 612
 613static int
 614check_rdb(void)
 615{
 616 char buf[512], diskpath[MAXPATHLEN];
 617 struct rdblock *rdb;
 618 off_t blk;
 619 int fd;
 620
 621 /* Find out if this disk has a valid RDB, before continuing. */
 622 rdb = (struct rdblock *)buf;
 623 fd = opendisk(diskdev, O_RDONLY, diskpath, sizeof(diskpath), 0);
 624 if (fd < 0)
 625 return 0;
 626 for (blk = 0; blk < RDB_MAXBLOCKS; blk++) {
 627 if (pread(fd, rdb, 512, blk * 512) != 512)
 628 return 0;
 629 if (rdb->id == RDBLOCK_ID && rdbchksum(rdb) == 0) {
 630 rdb_found = 1; /* do not repartition! */
 631 return 1;
 632 }
 633 }
 634 return 0;
 635}
 636
 637static uint32_t
 638rdbchksum(void *bdata)
 639{
 640 uint32_t *blp, cnt, val;
 641
 642 blp = bdata;
 643 cnt = blp[1];
 644 val = 0;
 645 while (cnt--)
 646 val += *blp++;
 647 return val;
 648}
 649
546int 650int
547md_pre_mount() 651md_pre_mount()
548{ 652{
 653
549 return 0; 654 return 0;
550} 655}

cvs diff -r1.6 -r1.7 src/distrib/utils/sysinst/arch/ofppc/Attic/md.h (switch to unified diff)

--- src/distrib/utils/sysinst/arch/ofppc/Attic/md.h 2011/08/21 15:21:46 1.6
+++ src/distrib/utils/sysinst/arch/ofppc/Attic/md.h 2012/01/29 16:01:37 1.7
@@ -1,103 +1,104 @@ @@ -1,103 +1,104 @@
1/* $NetBSD: md.h,v 1.6 2011/08/21 15:21:46 phx Exp $ */ 1/* $NetBSD: md.h,v 1.7 2012/01/29 16:01:37 phx Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Piermont Information Systems Inc. 4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Philip A. Nelson for Piermont Information Systems Inc. 7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of Piermont Information Systems Inc. may not be used to endorse 17 * 3. The name of Piermont Information Systems Inc. may not be used to endorse
18 * or promote products derived from this software without specific prior 18 * or promote products derived from this software without specific prior
19 * written permission. 19 * written permission.
20 * 20 *
21 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' 21 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 24 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE. 31 * THE POSSIBILITY OF SUCH DAMAGE.
32 * 32 *
33 */ 33 */
34 34
35/* md.h -- Machine specific definitions for the ofppc */ 35/* md.h -- Machine specific definitions for the ofppc */
36 36
37 37
38#include <machine/cpu.h> 38#include <machine/cpu.h>
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/stat.h> 40#include <sys/stat.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <unistd.h> 42#include <unistd.h>
43 43
44/* ofppc uses the mbr code. */ 44/* ofppc uses the mbr code. */
45#include "mbr.h" 45#include "mbr.h"
46 46
47/* constants and defines */ 47/* constants and defines */
48#define PREP_BOOT_SIZE 1048576 /* 1MB for prep-style boot */ 48#define PREP_BOOT_SIZE 1048576 /* 1MB for prep-style boot */
49#define BINFO_BOOT_SIZE 15*1024 /* 12k for bootinfo.txt */ 49#define BINFO_BOOT_SIZE 15*1024 /* 12k for bootinfo.txt */
50#define FAT12_BOOT_SIZE 10485760 /* 10MB boot partition */ 50#define FAT12_BOOT_SIZE 10485760 /* 10MB boot partition */
51#define MIN_FAT12_BOOT 2097152 /* 2MB absoule minimum */ 51#define MIN_FAT12_BOOT 2097152 /* 2MB absoule minimum */
52#define MIN_PREP_BOOT 1048576 52#define MIN_PREP_BOOT 1048576
53#define MIN_BINFO_BOOT 13312 53#define MIN_BINFO_BOOT 13312
54#define PART_ROOT PART_A 54#define PART_ROOT PART_A
55#define PART_SWAP PART_B 55#define PART_SWAP PART_B
56#define PART_RAW PART_C 56#define PART_RAW PART_C
57#define PART_BSD PART_D 57#define PART_BSD PART_D
58#define PART_BOOT_FAT12 PART_E 58#define PART_BOOT_FAT12 PART_E
59#define PART_BOOT_BINFO PART_F 59#define PART_BOOT_BINFO PART_F
60#define PART_BOOT_PREP PART_G 60#define PART_BOOT_PREP PART_G
61#define PART_USR PART_H /* Can be after PART_FIRST_FREE */ 61#define PART_USR PART_H /* Can be after PART_FIRST_FREE */
62#define PART_FIRST_FREE PART_I 62#define PART_FIRST_FREE PART_I
63 63
64/* We want the boot MSDOS partition mounted on /boot */ 64/* We want the boot MSDOS partition mounted on /boot */
65#define PART_BOOT_FAT12_PI_FLAGS (PIF_MOUNT) 65#define PART_BOOT_FAT12_PI_FLAGS (PIF_MOUNT)
66#define PART_BOOT_FAT12_PI_MOUNT "/boot" 66#define PART_BOOT_FAT12_PI_MOUNT "/boot"
67 67
68#define DEFSWAPRAM 32 /* Assume at least this RAM for swap calc */ 68#define DEFSWAPRAM 32 /* Assume at least this RAM for swap calc */
69#define DEFSWAPSIZE 128 69#define DEFSWAPSIZE 128
70#define DEFROOTSIZE 64 /* Default root size */ 70#define DEFROOTSIZE 64 /* Default root size */
71#define DEFVARSIZE 32 /* Default /var size, if created */ 71#define DEFVARSIZE 32 /* Default /var size, if created */
72#define DEFUSRSIZE 256 /* Default /usr size, if /home */ 72#define DEFUSRSIZE 256 /* Default /usr size, if /home */
73#define XNEEDMB 120 /* Extra megs for full X installation */ 73#define XNEEDMB 120 /* Extra megs for full X installation */
74 74
75/* allow using tmpfs for /tmp instead of mfs */ 75/* allow using tmpfs for /tmp instead of mfs */
76#define HAVE_TMPFS 76#define HAVE_TMPFS
77 77
78/* 78/*
79 * Default filesets to fetch and install during installation 79 * Default filesets to fetch and install during installation
80 * or upgrade. The standard sets are: 80 * or upgrade. The standard sets are:
81 * base etc comp games man misc tests text xbase xcomp xetc xfont xserver 81 * base etc comp games man misc tests text xbase xcomp xetc xfont xserver
82 * 82 *
83 * i386 has the MD set kern first, because generic kernels are too 83 * i386 has the MD set kern first, because generic kernels are too
84 * big to fit on install floppies. i386 does not yet include the x sets. 84 * big to fit on install floppies. i386 does not yet include the x sets.
85 * 85 *
86 * Third entry is the last extension name in the split sets for loading 86 * Third entry is the last extension name in the split sets for loading
87 * from floppy. 87 * from floppy.
88 */ 88 */
89#define SET_KERNEL_1_NAME "kern-GENERIC" 89#define SET_KERNEL_1_NAME "kern-GENERIC"
90#define MD_SETS_SELECTED SET_KERNEL_1, SET_SYSTEM, SET_X11 90#define MD_SETS_SELECTED SET_KERNEL_1, SET_SYSTEM, SET_X11
91 91
92/* 92/*
93 * Machine-specific command to write a new label to a disk. 93 * Machine-specific command to write a new label to a disk.
94 * For example, i386 uses "/sbin/disklabel -w -r", just like i386 94 * For example, i386 uses "/sbin/disklabel -w -r", just like i386
95 * miniroot scripts, though this may leave a bogus incore label. 95 * miniroot scripts, though this may leave a bogus incore label.
96 * Sun ports should probably use DISKLABEL_CMD "/sbin/disklabel -w" 96 * Sun ports should probably use DISKLABEL_CMD "/sbin/disklabel -w"
97 * to get incore to ondisk inode translation for the Sun proms. 97 * to get incore to ondisk inode translation for the Sun proms.
98 * If not defined, we assume the port does not support disklabels and 98 * If not defined, we assume the port does not support disklabels and
99 * hand-edited disklabel will NOT be written by MI code. 99 * hand-edited disklabel will NOT be written by MI code.
100 * 100 *
101 * On ofppc, do what the 1.2 install scripts did. 101 * On ofppc, do what the 1.2 install scripts did.
102 */ 102 */
103#define DISKLABEL_CMD "disklabel -w -r" 103const char *md_disklabel_cmd(void);
 104#define DISKLABEL_CMD md_disklabel_cmd()