md.c revision 1.8
1/* $NetBSD: md.c,v 1.8 2022/12/09 17:02:14 martin Exp $ */ 2 3/* 4 * Copyright 1997 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/* changes from the i386 version made by mrg */ 36 37/* md.c -- sparc machine specific routines */ 38/* This file is in close sync with pmax, vax, and x68k md.c */ 39 40#include <sys/types.h> 41#include <sys/ioctl.h> 42#include <sys/param.h> 43#include <sys/exec.h> 44#include <stdio.h> 45#include <curses.h> 46#include <unistd.h> 47#include <fcntl.h> 48#include <util.h> 49#include <dirent.h> 50 51#include "defs.h" 52#include "md.h" 53#include "msg_defs.h" 54#include "menu_defs.h" 55 56void 57md_init(void) 58{ 59} 60 61void 62md_init_set_status(int flags) 63{ 64 (void)flags; 65} 66 67bool 68md_get_info(struct install_partition_desc *install) 69{ 70 set_default_sizemult(pm->diskdev, MEG, pm->sectorsize); 71 return true; 72} 73 74/* 75 * md back-end code for menu-driven BSD disklabel editor. 76 */ 77int 78md_make_bsd_partitions(struct install_partition_desc *install) 79{ 80 return(make_bsd_partitions(install)); 81} 82 83/* 84 * any additional partition validation 85 */ 86bool 87md_check_partitions(struct install_partition_desc *install) 88{ 89 return true; 90} 91 92/* 93 * hook called before writing new disklabel. 94 */ 95bool 96md_pre_disklabel(struct install_partition_desc *install, 97 struct disk_partitions *parts) 98{ 99 return true; 100} 101 102/* 103 * hook called after writing disklabel to new target disk. 104 */ 105bool 106md_post_disklabel(struct install_partition_desc *install, 107 struct disk_partitions *parts) 108{ 109 return true; 110} 111 112/* 113 * hook called after upgrade() or install() has finished setting 114 * up the target disk but immediately before the user is given the 115 * ``disks are now set up'' message. 116 * 117 * On the sparc, we use this opportunity to install the boot blocks. 118 */ 119int 120md_post_newfs(struct install_partition_desc *install) 121{ 122 123 /* boot blocks ... */ 124 msg_fmt_display(MSG_dobootblks, "%s", pm->diskdev); 125 return (run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", pm->diskdev) || 126 run_program(RUN_DISPLAY, "/usr/mdec/binstall ffs %s", 127 targetroot_mnt)); 128} 129 130int 131md_post_extract(struct install_partition_desc *install, bool upgrade) 132{ 133 return 0; 134} 135 136void 137md_cleanup_install(struct install_partition_desc *install) 138{ 139#ifndef DEBUG 140 enable_rc_conf(); 141#endif 142} 143 144int 145md_pre_update(struct install_partition_desc *install) 146{ 147 return 1; 148} 149 150/* Upgrade support */ 151int 152md_update(struct install_partition_desc *install) 153{ 154 md_post_newfs(install); 155 return 1; 156} 157 158int 159md_pre_mount(struct install_partition_desc *install, size_t ndx) 160{ 161 return 0; 162} 163 164bool 165md_parts_use_wholedisk(struct disk_partitions *parts) 166{ 167 return parts_use_wholedisk(parts, 0, NULL); 168} 169 170#ifdef HAVE_GPT 171/* 172 * New GPT partitions have been written, update bootloader or remember 173 * data untill needed in md_post_newfs 174 */ 175bool 176md_gpt_post_write(struct disk_partitions *parts, part_id root_id, 177 bool root_is_new, part_id efi_id, bool efi_is_new) 178{ 179 180 return true; 181} 182#endif 183