md.c revision 1.32
1/* $NetBSD: md.c,v 1.32 2011/11/04 11:27:02 martin Exp $ */ 2 3/* 4 * Copyright 1997,2002 Piermont Information Systems Inc. 5 * All rights reserved. 6 * 7 * Based on code written by Philip A. Nelson for Piermont Information 8 * Systems Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 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 19 * or promote products derived from this software without specific prior 20 * written permission. 21 * 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 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 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 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35/* md.c -- evbppc machine specific routines */ 36 37#include <sys/param.h> 38#include <sys/sysctl.h> 39#include <stdio.h> 40#include <util.h> 41 42#include "defs.h" 43#include "md.h" 44#include "msg_defs.h" 45#include "menu_defs.h" 46 47void 48md_init(void) 49{ 50} 51 52void 53md_init_set_status(int flags) 54{ 55 (void)flags; 56} 57 58int 59md_get_info(void) 60{ 61 return set_bios_geom_with_mbr_guess(); 62} 63 64/* 65 * md back-end code for menu-driven BSD disklabel editor. 66 */ 67int 68md_make_bsd_partitions(void) 69{ 70 return make_bsd_partitions(); 71} 72 73/* 74 * any additional partition validation 75 */ 76int 77md_check_partitions(void) 78{ 79 return 1; 80} 81 82/* 83 * hook called before writing new disklabel. 84 */ 85int 86md_pre_disklabel(void) 87{ 88 printf ("%s", msg_string (MSG_dofdisk)); 89 90 /* write edited MBR onto disk. */ 91 if (write_mbr(diskdev, &mbr, 1) != 0) { 92 msg_display(MSG_wmbrfail); 93 process_menu(MENU_ok, NULL); 94 return 1; 95 } 96 return 0; 97} 98 99/* 100 * hook called after writing disklabel to new target disk. 101 */ 102int 103md_post_disklabel(void) 104{ 105 /* Sector forwarding / badblocks ... */ 106 if (*doessf) { 107 printf ("%s", msg_string (MSG_dobad144)); 108 return run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0", 109 diskdev); 110 } 111 return 0; 112} 113 114/* 115 * hook called after upgrade() or install() has finished setting 116 * up the target disk but immediately before the user is given the 117 * ``disks are now set up'' message. 118 */ 119int 120md_post_newfs(void) 121{ 122 /* Walnut doesn't do bootblocks */ 123 return 0; 124} 125 126int 127md_post_extract(void) 128{ 129 return 0; 130} 131 132void 133md_cleanup_install(void) 134{ 135#ifndef DEBUG 136 enable_rc_conf(); 137#endif 138} 139 140int 141md_pre_update(void) 142{ 143 return 1; 144} 145 146/* Upgrade support */ 147int 148md_update(void) 149{ 150 md_post_newfs(); 151 return 1; 152} 153 154int 155md_check_mbr(mbr_info_t *mbri) 156{ 157 return 2; 158} 159 160int 161md_mbr_use_wholedisk(mbr_info_t *mbri) 162{ 163 return mbr_use_wholedisk(mbri); 164} 165 166int 167md_pre_mount() 168{ 169 return 0; 170} 171