Print this page
bootadm.c updated
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/boot/bootadm/bootadm.h
+++ new/usr/src/cmd/boot/bootadm/bootadm.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #ifndef _BOOTADM_H
27 27 #define _BOOTADM_H
28 28
29 29 #ifdef __cplusplus
30 30 extern "C" {
31 31 #endif
32 32
33 33 #include <assert.h>
34 34
35 35 #ifndef TEXT_DOMAIN
36 36 #define TEXT_DOMAIN "SUNW_OST_OSCMD"
37 37 #endif /* TEXT_DOMAIN */
38 38
39 39 /* Type definitions */
40 40
41 41 /* GRUB menu per-line classification */
42 42 typedef enum {
43 43 BAM_INVALID = 0,
44 44 BAM_EMPTY,
45 45 BAM_COMMENT,
46 46 BAM_GLOBAL,
47 47 BAM_ENTRY,
48 48 BAM_TITLE
49 49 } menu_flag_t;
50 50
51 51 /* struct for menu.lst contents */
52 52 typedef struct line {
53 53 int lineNum; /* Line number in menu.lst */
54 54 int entryNum; /* menu boot entry #. ENTRY_INIT if not applicable */
55 55 char *cmd;
56 56 char *sep;
57 57 char *arg;
58 58 char *line;
59 59 menu_flag_t flags;
60 60 struct line *next;
61 61 struct line *prev;
62 62 } line_t;
63 63
64 64 typedef struct entry {
65 65 struct entry *next;
66 66 struct entry *prev;
67 67 line_t *start;
68 68 line_t *end;
69 69 int entryNum;
70 70 uint_t flags;
71 71 } entry_t;
72 72
73 73 /* For flags value in entry_t */
74 74 #define BAM_ENTRY_BOOTADM 0x01 /* entry created by bootadm */
75 75 #define BAM_ENTRY_LU 0x02 /* entry created by Live Upgrade */
76 76 #define BAM_ENTRY_CHAINLOADER 0x04 /* chainloader entry; do not disturb */
77 77 #define BAM_ENTRY_ROOT 0x08 /* entry has a root line */
78 78 #define BAM_ENTRY_FAILSAFE 0x10 /* failsafe entry */
79 79 #define BAM_ENTRY_DBOOT 0x20 /* Is dboot (normal or failsafe) */
80 80 #define BAM_ENTRY_32BIT 0x40 /* Is a 32-bit entry */
81 81 #define BAM_ENTRY_HV 0x80 /* Is a hypervisor entry */
82 82 #define BAM_ENTRY_FINDROOT 0x100 /* entry has a findroot line */
83 83 #define BAM_ENTRY_MULTIBOOT 0x200 /* is multiboot (normal or failsafe) */
84 84 #define BAM_ENTRY_64BIT 0x400 /* Is a 64-bit entry */
85 85
86 86 #define BAM_ENTRY_UPGFSKERNEL 0x800 /* Upgrade failsafe kernel entry */
87 87 #define BAM_ENTRY_UPGFSMODULE 0x1000 /* Upgrade failsafe module entry */
88 88
89 89 #define BAM_ENTRY_LIBBE 0x2000 /* entry created by libbe */
90 90
91 91 typedef struct {
92 92 line_t *start;
93 93 line_t *end;
94 94 line_t *curdefault; /* line containing default */
95 95 line_t *olddefault; /* old default line (commented) */
96 96 line_t *old_rc_default; /* old default line for bootenv.rc */
97 97 entry_t *entries; /* os entries */
98 98 } menu_t;
99 99
100 100 typedef enum {
101 101 BAM_ERROR = -1, /* Must be negative. add_boot_entry() depends on it */
102 102 BAM_SUCCESS = 0,
103 103 BAM_WRITE = 2,
104 104 BAM_MSG, /* Used by upgrade_menu() */
105 105 BAM_NOCHANGE /* Used by cvt_to_hyper()/cvt_to_metal() */
106 106 } error_t;
107 107
108 108 /*
109 109 * Menu related
110 110 * menu_cmd_t and menu_cmds must be kept in sync
111 111 *
112 112 * The *_DOLLAR_CMD values must be 1 greater than the
113 113 * respective [KERNEL|MODULE]_CMD values.
114 114 */
115 115 typedef enum {
116 116 DEFAULT_CMD = 0,
117 117 TIMEOUT_CMD,
118 118 TITLE_CMD,
↓ open down ↓ |
118 lines elided |
↑ open up ↑ |
119 119 ROOT_CMD,
120 120 KERNEL_CMD,
121 121 KERNEL_DOLLAR_CMD, /* Must be KERNEL_CMD + 1 */
122 122 MODULE_CMD,
123 123 MODULE_DOLLAR_CMD, /* Must be MODULE_CMD + 1 */
124 124 SEP_CMD,
125 125 COMMENT_CMD,
126 126 CHAINLOADER_CMD,
127 127 ARGS_CMD,
128 128 FINDROOT_CMD,
129 - BOOTFS_CMD
129 + BOOTFS_CMD,
130 + KERNEL_OPTIONS_CMD,
130 131 } menu_cmd_t;
131 132
132 133 extern char *menu_cmds[];
133 134
134 135 /* For multi- or direct-boot */
135 136 typedef enum {
136 137 BAM_DIRECT_NOT_SET,
137 138 BAM_DIRECT_MULTIBOOT,
138 139 BAM_DIRECT_DBOOT
139 140 } direct_or_multi_t;
140 141
141 142 /* Is there a hypervisor present? */
142 143 typedef enum {
143 144 BAM_HV_UNKNOWN,
144 145 BAM_HV_NO,
145 146 BAM_HV_PRESENT
146 147 } hv_t;
147 148
148 149 /* Is there findroot capability present ? */
149 150 typedef enum {
150 151 BAM_FINDROOT_UNKNOWN,
151 152 BAM_FINDROOT_ABSENT,
152 153 BAM_FINDROOT_PRESENT
153 154 } findroot_t;
154 155
155 156 extern int bam_verbose;
156 157 extern int bam_force;
157 158 extern direct_or_multi_t bam_direct;
158 159 extern hv_t bam_is_hv;
159 160 extern findroot_t bam_is_findroot;
160 161 extern int bam_debug;
161 162
162 163 extern void bam_add_line(menu_t *mp, entry_t *entry, line_t *prev, line_t *lp);
163 164 extern void update_numbering(menu_t *mp);
164 165 extern error_t set_global(menu_t *, char *, int);
165 166 extern error_t upgrade_menu(menu_t *, char *, char *);
166 167 extern error_t cvt_to_hyper(menu_t *, char *, char *);
167 168 extern error_t cvt_to_metal(menu_t *, char *, char *);
168 169 extern void *s_calloc(size_t, size_t);
169 170 extern void *s_realloc(void *, size_t);
170 171 extern char *s_fgets(char *buf, int n, FILE *fp);
171 172 extern void bam_error(char *format, ...);
172 173 extern void bam_exit(int);
173 174 extern void bam_print(char *, ...);
174 175 extern void bam_print_stderr(char *format, ...);
175 176 extern void bam_derror(char *format, ...);
176 177 extern error_t get_boot_cap(const char *osroot);
177 178 extern char *get_special(char *);
178 179 extern char *os_to_grubdisk(char *, int);
179 180 extern void update_line(line_t *);
180 181 extern int add_boot_entry(menu_t *, char *, char *, char *, char *, char *,
181 182 char *);
182 183 extern error_t delete_boot_entry(menu_t *, int, int);
183 184 extern int is_grub(const char *);
184 185 extern char *get_grubsign(char *osroot, char *osdev);
185 186 extern char *get_grubroot(char *osroot, char *osdev, char *menu_root);
186 187 extern int root_optional(char *osroot, char *menu_root);
187 188 extern void unlink_line(menu_t *mp, line_t *lp);
188 189 extern void line_free(line_t *lp);
189 190 extern char *s_strdup(char *);
190 191 extern int is_sparc(void);
191 192
192 193 #define BAM_MAXLINE 8192
193 194
194 195 /* menu.lst comments created by bootadm */
195 196 #define BAM_BOOTADM_HDR "---------- ADDED BY BOOTADM - DO NOT EDIT ----------"
196 197 #define BAM_BOOTADM_FTR "---------------------END BOOTADM--------------------"
197 198
198 199 /*
199 200 * menu.lst comments create by Live Upgrade. Note that these are the end of
200 201 * the comment strings - there will be other text before them.
201 202 */
202 203 #define BAM_LU_HDR " - ADDED BY LIVE UPGRADE - DO NOT EDIT -----"
203 204 #define BAM_LU_FTR " -------------- END LIVE UPGRADE ------------"
204 205
205 206 #define BAM_OLDDEF "BOOTADM SAVED DEFAULT: "
206 207 #define BAM_OLD_RC_DEF "BOOTADM RC SAVED DEFAULT: "
207 208
208 209 /*
209 210 * menu.lst comment created by libbe
210 211 */
211 212 #define BAM_LIBBE_FTR "============ End of LIBBE entry ============="
212 213
213 214 /* Title used for failsafe entries */
214 215 #define FAILSAFE_TITLE "Solaris failsafe"
215 216
216 217 /* Title used for hv entries */
217 218 #define NEW_HV_ENTRY "Solaris xVM"
218 219
219 220 /* ZFS boot option */
220 221 #define ZFS_BOOT "-B $ZFS-BOOTFS"
221 222
222 223 /* multiboot */
223 224 #define MULTI_BOOT "/platform/i86pc/multiboot"
224 225 #define MULTI_BOOT_FAILSAFE "/boot/multiboot"
225 226 #define MULTI_BOOT_FAILSAFE_UNIX "kernel/unix"
226 227 #define MULTI_BOOT_FAILSAFE_LINE "/boot/multiboot kernel/unix -s"
227 228
228 229 /* directboot kernels */
229 230 #define DIRECT_BOOT_32 "/platform/i86pc/kernel/unix"
230 231 #define DIRECT_BOOT_64 "/platform/i86pc/kernel/amd64/unix"
231 232 #define DIRECT_BOOT_KERNEL "/platform/i86pc/kernel/$ISADIR/unix"
232 233 #define DIRECT_BOOT_FAILSAFE_32 "/boot/platform/i86pc/kernel/unix"
233 234 #define DIRECT_BOOT_FAILSAFE_64 "/boot/platform/i86pc/kernel/amd64/unix"
234 235 #define DIRECT_BOOT_FAILSAFE_KERNEL \
235 236 "/boot/platform/i86pc/kernel/$ISADIR/unix"
236 237 #define DIRECT_BOOT_FAILSAFE_LINE DIRECT_BOOT_FAILSAFE_KERNEL " -s"
237 238 #define DIRECT_BOOT_KERNEL_ZFS DIRECT_BOOT_KERNEL " " ZFS_BOOT
238 239 #define DIRECT_BOOT_PREFIX "/platform/i86pc/"
239 240 #define KERNEL_PREFIX "/platform/i86pc/"
240 241 #define AMD_UNIX_SPACE "/amd64/unix "
241 242 #define UNIX_SPACE "/unix "
242 243
243 244 /* xVM kernels */
244 245 #define XEN_KERNEL_SUBSTR "xen.gz"
245 246
246 247 /* Boot archives */
247 248 #define ARCHIVE_PREFIX "/platform/"
248 249 #define ARCHIVE_SUFFIX "/boot_archive"
249 250 #define CACHEDIR_SUFFIX "/archive_cache"
250 251 #define UPDATEDIR_SUFFIX "/updates"
251 252 #define DIRECT_BOOT_ARCHIVE "/platform/i86pc/$ISADIR/boot_archive"
252 253 #define DIRECT_BOOT_ARCHIVE_32 "/platform/i86pc/boot_archive"
253 254 #define DIRECT_BOOT_ARCHIVE_64 "/platform/i86pc/amd64/boot_archive"
254 255 #define MULTIBOOT_ARCHIVE DIRECT_BOOT_ARCHIVE_32
255 256 #define FAILSAFE_ARCHIVE "/boot/$ISADIR/x86.miniroot-safe"
256 257 #define FAILSAFE_ARCHIVE_32 "/boot/x86.miniroot-safe"
257 258 #define FAILSAFE_ARCHIVE_64 "/boot/amd64/x86.miniroot-safe"
258 259 #define CACHEDIR_32 "/platform/i86pc/archive_cache"
259 260 #define CACHEDIR_64 "/platform/i86pc/amd64/archive_cache"
260 261 #define UPDATEDIR_32 "/platform/i86pc/updates"
261 262 #define UPDATEDIR_64 "/platform/i86pc/amd64/updates"
262 263
263 264 /* Hypervisors */
264 265 #define XEN_64 "/boot/amd64/xen.gz"
265 266 #define XEN_MENU "/boot/$ISADIR/xen.gz"
266 267 #define HYPERVISOR_KERNEL "/platform/i86xpv/kernel/$ISADIR/unix"
267 268 #define XEN_KERNEL_MODULE_LINE HYPERVISOR_KERNEL " " HYPERVISOR_KERNEL
268 269 #define XEN_KERNEL_MODULE_LINE_ZFS \
269 270 HYPERVISOR_KERNEL " " HYPERVISOR_KERNEL " " ZFS_BOOT
270 271
271 272 /* Helpers */
272 273 #define MKISOFS_PATH "/usr/bin/mkisofs"
273 274 #define DD_PATH_USR "/usr/bin/dd"
274 275 #define LOCKFS_PATH "/usr/sbin/lockfs"
275 276
276 277 /* A first guess at the number of entries in a menu */
277 278 #define BAM_ENTRY_NUM 10
278 279
279 280 /* toggle for whether delete_boot_entry prints an error message or not */
280 281 #define DBE_PRINTERR 0
281 282 #define DBE_QUIET 1
282 283
283 284 /*
284 285 * Debugging defines
285 286 */
286 287 #define INJECT_ERROR1(x, y) \
287 288 { \
288 289 if (bam_debug) { \
289 290 char *inj = getenv("_BOOTADM_INJECT"); \
290 291 if (inj && strcmp(inj, (x)) == 0) { \
291 292 y; \
292 293 } \
293 294 } \
294 295 }
295 296
296 297 #define INJECT_ERROR2(x, y, z) \
297 298 { \
298 299 if (bam_debug) { \
299 300 char *inj = getenv("_BOOTADM_INJECT"); \
300 301 if (inj && strcmp(inj, (x)) == 0) { \
301 302 y; \
302 303 z; \
303 304 } \
304 305 } \
305 306 }
306 307
307 308 #define BAM_DPRINTF(x) {if (bam_debug) bam_derror x; }
308 309
309 310 #ifdef __cplusplus
310 311 }
311 312 #endif
312 313
313 314 #endif /* _BOOTADM_H */
↓ open down ↓ |
174 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX