| @@ -1,168 +1,157 @@ | | | @@ -1,168 +1,157 @@ |
1 | /* $NetBSD: md.c,v 1.55 2011/04/04 08:30:20 mbalmer Exp $ */ | | 1 | /* $NetBSD: md.c,v 1.56 2011/08/25 15:42:33 kiyohara 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 -- bebox machine specific routines */ | | 35 | /* md.c -- bebox 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 <stdio.h> | | 39 | #include <stdio.h> |
40 | #include <util.h> | | 40 | #include <util.h> |
41 | | | 41 | |
42 | #include "defs.h" | | 42 | #include "defs.h" |
43 | #include "md.h" | | 43 | #include "md.h" |
44 | #include "msg_defs.h" | | 44 | #include "msg_defs.h" |
45 | #include "menu_defs.h" | | 45 | #include "menu_defs.h" |
46 | | | 46 | |
47 | void | | 47 | void |
48 | md_init(void) | | 48 | md_init(void) |
49 | { | | 49 | { |
50 | } | | 50 | } |
51 | | | 51 | |
52 | void | | 52 | void |
53 | md_init_set_status(int flags) | | 53 | md_init_set_status(int flags) |
54 | { | | 54 | { |
55 | (void)flags; | | 55 | (void)flags; |
56 | } | | 56 | } |
57 | | | 57 | |
58 | int | | 58 | int |
59 | md_get_info(void) | | 59 | md_get_info(void) |
60 | { | | 60 | { |
61 | return set_bios_geom_with_mbr_guess(); | | 61 | return set_bios_geom_with_mbr_guess(); |
62 | } | | 62 | } |
63 | | | 63 | |
64 | /* | | 64 | /* |
65 | * md back-end code for menu-driven BSD disklabel editor. | | 65 | * md back-end code for menu-driven BSD disklabel editor. |
66 | */ | | 66 | */ |
67 | int | | 67 | int |
68 | md_make_bsd_partitions(void) | | 68 | md_make_bsd_partitions(void) |
69 | { | | 69 | { |
70 | return make_bsd_partitions(); | | 70 | return make_bsd_partitions(); |
71 | } | | 71 | } |
72 | | | 72 | |
73 | /* | | 73 | /* |
74 | * any additional partition validation | | 74 | * any additional partition validation |
75 | */ | | 75 | */ |
76 | int | | 76 | int |
77 | md_check_partitions(void) | | 77 | md_check_partitions(void) |
78 | { | | 78 | { |
79 | return 1; | | 79 | return 1; |
80 | } | | 80 | } |
81 | | | 81 | |
82 | /* | | 82 | /* |
83 | * hook called before writing new disklabel. | | 83 | * hook called before writing new disklabel. |
84 | */ | | 84 | */ |
85 | int | | 85 | int |
86 | md_pre_disklabel(void) | | 86 | md_pre_disklabel(void) |
87 | { | | 87 | { |
88 | printf ("%s", msg_string (MSG_dofdisk)); | | 88 | printf ("%s", msg_string (MSG_dofdisk)); |
89 | | | 89 | |
90 | /* write edited MBR onto disk. */ | | 90 | /* write edited MBR onto disk. */ |
91 | if (write_mbr(diskdev, &mbr, 1) != 0) { | | 91 | if (write_mbr(diskdev, &mbr, 1) != 0) { |
92 | msg_display(MSG_wmbrfail); | | 92 | msg_display(MSG_wmbrfail); |
93 | process_menu(MENU_ok, NULL); | | 93 | process_menu(MENU_ok, NULL); |
94 | return 1; | | 94 | return 1; |
95 | } | | 95 | } |
96 | return 0; | | 96 | return 0; |
97 | } | | 97 | } |
98 | | | 98 | |
99 | /* | | 99 | /* |
100 | * hook called after writing disklabel to new target disk. | | 100 | * hook called after writing disklabel to new target disk. |
101 | */ | | 101 | */ |
102 | int | | 102 | int |
103 | md_post_disklabel(void) | | 103 | md_post_disklabel(void) |
104 | { | | 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; | | 105 | return 0; |
112 | } | | 106 | } |
113 | | | 107 | |
114 | /* | | 108 | /* |
115 | * hook called after upgrade() or install() has finished setting | | 109 | * hook called after upgrade() or install() has finished setting |
116 | * up the target disk but immediately before the user is given the | | 110 | * up the target disk but immediately before the user is given the |
117 | * ``disks are now set up'' message. | | 111 | * ``disks are now set up'' message. |
118 | */ | | 112 | */ |
119 | int | | 113 | int |
120 | md_post_newfs(void) | | 114 | md_post_newfs(void) |
121 | { | | 115 | { |
122 | /* boot blocks ... */ | | | |
123 | printf (msg_string(MSG_dobootblks), diskdev); | | | |
124 | run_program(RUN_DISPLAY, | | | |
125 | "/usr/mdec/installboot -v /usr/mdec/biosboot.sym /dev/r%sa", | | | |
126 | diskdev); | | | |
127 | return 0; | | 116 | return 0; |
128 | } | | 117 | } |
129 | | | 118 | |
130 | int | | 119 | int |
131 | md_post_extract(void) | | 120 | md_post_extract(void) |
132 | { | | 121 | { |
133 | return 0; | | 122 | return 0; |
134 | } | | 123 | } |
135 | | | 124 | |
136 | void | | 125 | void |
137 | md_cleanup_install(void) | | 126 | md_cleanup_install(void) |
138 | { | | 127 | { |
139 | #ifndef DEBUG | | 128 | #ifndef DEBUG |
140 | enable_rc_conf(); | | 129 | enable_rc_conf(); |
141 | #endif | | 130 | #endif |
142 | } | | 131 | } |
143 | | | 132 | |
144 | int | | 133 | int |
145 | md_pre_update(void) | | 134 | md_pre_update(void) |
146 | { | | 135 | { |
147 | return 1; | | 136 | return 1; |
148 | } | | 137 | } |
149 | | | 138 | |
150 | /* Upgrade support */ | | 139 | /* Upgrade support */ |
151 | int | | 140 | int |
152 | md_update(void) | | 141 | md_update(void) |
153 | { | | 142 | { |
154 | md_post_newfs(); | | 143 | md_post_newfs(); |
155 | return 1; | | 144 | return 1; |
156 | } | | 145 | } |
157 | | | 146 | |
158 | int | | 147 | int |
159 | md_check_mbr(mbr_info_t *mbri) | | 148 | md_check_mbr(mbr_info_t *mbri) |
160 | { | | 149 | { |
161 | return 2; | | 150 | return 2; |
162 | } | | 151 | } |
163 | | | 152 | |
164 | int | | 153 | int |
165 | md_mbr_use_wholedisk(mbr_info_t *mbri) | | 154 | md_mbr_use_wholedisk(mbr_info_t *mbri) |
166 | { | | 155 | { |
167 | return mbr_use_wholedisk(mbri); | | 156 | return mbr_use_wholedisk(mbri); |
168 | } | | 157 | } |