xref: /netbsd-src/usr.sbin/sysinst/arch/sparc/md.c (revision 53d1339bf7f9c7367b35a9e1ebe693f9b047a47b)
1 /*	$NetBSD: md.c,v 1.6 2020/10/12 16:14:36 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 
56 void
57 md_init(void)
58 {
59 }
60 
61 void
62 md_init_set_status(int flags)
63 {
64 	(void)flags;
65 }
66 
67 bool
68 md_get_info(struct install_partition_desc *install)
69 {
70 	return true;
71 }
72 
73 /*
74  * md back-end code for menu-driven BSD disklabel editor.
75  */
76 int
77 md_make_bsd_partitions(struct install_partition_desc *install)
78 {
79 	return(make_bsd_partitions(install));
80 }
81 
82 /*
83  * any additional partition validation
84  */
85 bool
86 md_check_partitions(struct install_partition_desc *install)
87 {
88 	return true;
89 }
90 
91 /*
92  * hook called before writing new disklabel.
93  */
94 bool
95 md_pre_disklabel(struct install_partition_desc *install,
96     struct disk_partitions *parts)
97 {
98 	return true;
99 }
100 
101 /*
102  * hook called after writing disklabel to new target disk.
103  */
104 bool
105 md_post_disklabel(struct install_partition_desc *install,
106     struct disk_partitions *parts)
107 {
108 	return true;
109 }
110 
111 /*
112  * hook called after upgrade() or install() has finished setting
113  * up the target disk but immediately before the user is given the
114  * ``disks are now set up'' message.
115  *
116  * On the sparc, we use this opportunity to install the boot blocks.
117  */
118 int
119 md_post_newfs(struct install_partition_desc *install)
120 {
121 
122 	/* boot blocks ... */
123 	msg_fmt_display(MSG_dobootblks, "%s", pm->diskdev);
124 	return (run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", pm->diskdev) ||
125 	    run_program(RUN_DISPLAY, "/usr/mdec/binstall ffs %s",
126 		targetroot_mnt));
127 }
128 
129 int
130 md_post_extract(struct install_partition_desc *install)
131 {
132 	return 0;
133 }
134 
135 void
136 md_cleanup_install(struct install_partition_desc *install)
137 {
138 #ifndef DEBUG
139 	enable_rc_conf();
140 #endif
141 }
142 
143 int
144 md_pre_update(struct install_partition_desc *install)
145 {
146 	return 1;
147 }
148 
149 /* Upgrade support */
150 int
151 md_update(struct install_partition_desc *install)
152 {
153 	md_post_newfs(install);
154 	return 1;
155 }
156 
157 int
158 md_pre_mount(struct install_partition_desc *install, size_t ndx)
159 {
160 	return 0;
161 }
162 
163 bool
164 md_parts_use_wholedisk(struct disk_partitions *parts)
165 {
166 	return parts_use_wholedisk(parts, 0, NULL);
167 }
168 
169 #ifdef HAVE_GPT
170 /*
171  * New GPT partitions have been written, update bootloader or remember
172  * data untill needed in md_post_newfs
173  */
174 bool
175 md_gpt_post_write(struct disk_partitions *parts, part_id root_id,
176     bool root_is_new, part_id efi_id, bool efi_is_new)
177 {
178 
179 	return true;
180 }
181 #endif
182