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