author | jv227347 <Jordan.Vaughan@Sun.com> |
Tue, 18 May 2010 12:28:09 -0700 | |
changeset 12433 | a15cace5f27d |
parent 11771 | 5d55cb57dff3 |
child 12463 | 5259ac7d9677 |
permissions | -rw-r--r-- |
10840 | 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 |
/* |
|
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
22 |
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
10840 | 23 |
*/ |
24 |
||
25 |
/* |
|
26 |
* s10_support is a small cli utility used to perform some brand-specific |
|
27 |
* tasks when verifying a zone. This utility is not intended to be called |
|
28 |
* by users - it is intended to be invoked by the zones utilities. |
|
29 |
*/ |
|
30 |
||
31 |
#include <ctype.h> |
|
32 |
#include <errno.h> |
|
33 |
#include <fcntl.h> |
|
34 |
#include <libgen.h> |
|
35 |
#include <limits.h> |
|
36 |
#include <s10_brand.h> |
|
37 |
#include <stdarg.h> |
|
38 |
#include <stdio.h> |
|
39 |
#include <stdlib.h> |
|
40 |
#include <string.h> |
|
41 |
#include <strings.h> |
|
42 |
#include <stropts.h> |
|
43 |
#include <sys/stat.h> |
|
44 |
#include <sys/types.h> |
|
45 |
#include <sys/utsname.h> |
|
46 |
#include <sys/varargs.h> |
|
47 |
#include <unistd.h> |
|
48 |
#include <libintl.h> |
|
49 |
#include <locale.h> |
|
50 |
#include <dirent.h> |
|
51 |
#include <sys/systeminfo.h> |
|
52 |
||
53 |
#include <libzonecfg.h> |
|
54 |
||
55 |
static void s10_err(char *msg, ...) __NORETURN; |
|
56 |
static void usage(void) __NORETURN; |
|
57 |
||
58 |
/* |
|
59 |
* XXX This is a temporary flag for the initial release to enable the |
|
60 |
* use of features which are not yet tested or fully implemented. |
|
61 |
*/ |
|
62 |
static boolean_t override = B_FALSE; |
|
63 |
||
64 |
static char *bname = NULL; |
|
65 |
||
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
66 |
/* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
67 |
* DELETE_LIST_PATH represents the path to a solaris10-branded zone's "delete |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
68 |
* list", which is generated by patchrm when it needs to remove files after |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
69 |
* the zone reboots. See set_zone_emul_bitmap() below for additional details. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
70 |
*/ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
71 |
#define DELETE_LIST_PATH "/var/sadm/patch/.delete_list" |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
72 |
|
10840 | 73 |
#define PKGINFO_RD_LEN 128 |
74 |
#define PATCHLIST "PATCHLIST=" |
|
75 |
||
76 |
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */ |
|
77 |
#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ |
|
78 |
#endif |
|
79 |
||
80 |
/*PRINTFLIKE1*/ |
|
81 |
static void |
|
82 |
s10_err(char *msg, ...) |
|
83 |
{ |
|
84 |
char buf[1024]; |
|
85 |
va_list ap; |
|
86 |
||
87 |
va_start(ap, msg); |
|
88 |
(void) vsnprintf(buf, sizeof (buf), msg, ap); |
|
89 |
va_end(ap); |
|
90 |
||
91 |
/* This needs go to stdout so the msgs show up through zoneadm. */ |
|
92 |
(void) printf("Error: %s\n", buf); |
|
93 |
||
94 |
exit(1); |
|
95 |
/*NOTREACHED*/ |
|
96 |
} |
|
97 |
||
98 |
static int |
|
99 |
s10_verify(char *xmlfile) |
|
100 |
{ |
|
101 |
zone_dochandle_t handle; |
|
102 |
struct zone_fstab fstab; |
|
103 |
struct zone_devtab devtab; |
|
104 |
zone_iptype_t iptype; |
|
105 |
struct zone_dstab dstab; |
|
106 |
||
107 |
if ((handle = zonecfg_init_handle()) == NULL) |
|
108 |
s10_err(gettext("internal libzonecfg.so.1 error"), 0); |
|
109 |
||
110 |
if (zonecfg_get_xml_handle(xmlfile, handle) != Z_OK) { |
|
111 |
zonecfg_fini_handle(handle); |
|
112 |
s10_err(gettext("zonecfg provided an invalid XML file")); |
|
113 |
} |
|
114 |
||
115 |
/* |
|
116 |
* Check to see whether the zone has any inherit-pkg-dirs |
|
117 |
* configured. |
|
118 |
*/ |
|
119 |
if (zonecfg_setipdent(handle) != Z_OK) { |
|
120 |
zonecfg_fini_handle(handle); |
|
121 |
s10_err(gettext("zonecfg provided an invalid XML file")); |
|
122 |
} |
|
123 |
if (zonecfg_getipdent(handle, &fstab) == Z_OK) { |
|
124 |
zonecfg_fini_handle(handle); |
|
125 |
s10_err(gettext("solaris10 zones do not support " |
|
126 |
"inherit-pkg-dirs")); |
|
127 |
} |
|
128 |
(void) zonecfg_endipdent(handle); |
|
129 |
||
130 |
/* |
|
131 |
* Check to see whether the zone has any unsupported devices |
|
132 |
* configured. |
|
133 |
* |
|
134 |
* The audio framework has changed in Solaris Next as compared to |
|
135 |
* S10. Data indicates the less than 1/10 of 1 percent of zones |
|
136 |
* are using /dev/sound. Given the low usage vs. the effort to |
|
137 |
* provide emulation, /dev/sound is currently disallowed. We can |
|
138 |
* revisit this if there is enough demand. |
|
139 |
*/ |
|
140 |
if (zonecfg_setdevent(handle) != Z_OK) { |
|
141 |
zonecfg_fini_handle(handle); |
|
142 |
s10_err(gettext("zonecfg provided an invalid XML file")); |
|
143 |
} |
|
144 |
if (zonecfg_getdevent(handle, &devtab) == Z_OK) { |
|
145 |
if (strncmp(devtab.zone_dev_match, "/dev/sound", 10) == 0 && |
|
146 |
!override) { |
|
147 |
zonecfg_fini_handle(handle); |
|
148 |
s10_err(gettext("solaris10 zones do not currently " |
|
149 |
"support /dev/sound")); |
|
150 |
} |
|
151 |
} |
|
152 |
(void) zonecfg_enddevent(handle); |
|
153 |
||
154 |
/* |
|
155 |
* Check to see whether the zone has any experimental features |
|
156 |
* configured. |
|
157 |
*/ |
|
158 |
if (zonecfg_get_iptype(handle, &iptype) == Z_OK && |
|
159 |
iptype == ZS_EXCLUSIVE && !override) { |
|
160 |
zonecfg_fini_handle(handle); |
|
161 |
s10_err(gettext("solaris10 zones do not currently support " |
|
162 |
"exclusive ip-type stacks")); |
|
163 |
} |
|
164 |
||
165 |
if (zonecfg_setdsent(handle) != Z_OK) { |
|
166 |
zonecfg_fini_handle(handle); |
|
167 |
s10_err(gettext("zonecfg provided an invalid XML file")); |
|
168 |
} |
|
169 |
if (zonecfg_getdsent(handle, &dstab) == Z_OK && !override) { |
|
170 |
zonecfg_fini_handle(handle); |
|
171 |
s10_err(gettext("solaris10 zones do not currently support " |
|
172 |
"delegated datasets")); |
|
173 |
} |
|
174 |
(void) zonecfg_enddsent(handle); |
|
175 |
||
176 |
zonecfg_fini_handle(handle); |
|
177 |
return (0); |
|
178 |
} |
|
179 |
||
180 |
/* |
|
181 |
* Read an entry from a pkginfo file. Some of these lines can |
|
182 |
* either be arbitrarily long or be continued by a backslash at the end of |
|
183 |
* the line. This function coalesces lines that are longer than the read |
|
184 |
* buffer, and lines that are continued, into one buffer which is returned. |
|
185 |
* The caller must free this memory. NULL is returned when we hit EOF or |
|
186 |
* if we run out of memory (errno is set to ENOMEM). |
|
187 |
*/ |
|
188 |
static char * |
|
189 |
read_pkg_data(FILE *fp) |
|
190 |
{ |
|
191 |
char *start; |
|
192 |
char *inp; |
|
193 |
char *p; |
|
194 |
int char_cnt = 0; |
|
195 |
||
196 |
errno = 0; |
|
197 |
if ((start = (char *)malloc(PKGINFO_RD_LEN)) == NULL) { |
|
198 |
errno = ENOMEM; |
|
199 |
return (NULL); |
|
200 |
} |
|
201 |
||
202 |
inp = start; |
|
203 |
while ((p = fgets(inp, PKGINFO_RD_LEN, fp)) != NULL) { |
|
204 |
int len; |
|
205 |
||
206 |
len = strlen(inp); |
|
207 |
if (inp[len - 1] == '\n' && |
|
208 |
(len == 1 || inp[len - 2] != '\\')) { |
|
209 |
char_cnt = len; |
|
210 |
break; |
|
211 |
} |
|
212 |
||
213 |
if (inp[len - 1] == '\n' && inp[len - 2] == '\\') |
|
214 |
char_cnt += len - 2; |
|
215 |
else |
|
216 |
char_cnt += PKGINFO_RD_LEN - 1; |
|
217 |
||
218 |
if ((p = realloc(start, char_cnt + PKGINFO_RD_LEN)) == NULL) { |
|
219 |
errno = ENOMEM; |
|
220 |
break; |
|
221 |
} |
|
222 |
||
223 |
start = p; |
|
224 |
inp = start + char_cnt; |
|
225 |
} |
|
226 |
||
227 |
if (errno == ENOMEM || (p == NULL && char_cnt == 0)) { |
|
228 |
free(start); |
|
229 |
start = NULL; |
|
230 |
} |
|
231 |
||
232 |
return (start); |
|
233 |
} |
|
234 |
||
235 |
/* |
|
236 |
* Read the SUNWcakr pkginfo file and get the PATCHLIST for the pkg. |
|
237 |
*/ |
|
238 |
static int |
|
11441
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
239 |
get_ku_patchlist(char *zonepath, char **patchlist) |
10840 | 240 |
{ |
241 |
char pkginfo[MAXPATHLEN]; |
|
242 |
FILE *fp; |
|
243 |
char *buf; |
|
244 |
int err = 0; |
|
245 |
||
246 |
if (snprintf(pkginfo, sizeof (pkginfo), |
|
247 |
"%s/root/var/sadm/pkg/SUNWcakr/pkginfo", zonepath) |
|
248 |
>= sizeof (pkginfo)) |
|
249 |
s10_err(gettext("error formating pkg path")); |
|
250 |
||
251 |
if ((fp = fopen(pkginfo, "r")) == NULL) |
|
252 |
return (errno); |
|
253 |
||
254 |
while ((buf = read_pkg_data(fp)) != NULL) { |
|
255 |
if (strncmp(buf, PATCHLIST, sizeof (PATCHLIST) - 1) == 0) { |
|
256 |
int len; |
|
257 |
||
258 |
/* remove trailing newline */ |
|
259 |
len = strlen(buf); |
|
260 |
buf[len - 1] = '\0'; |
|
261 |
||
262 |
if ((*patchlist = |
|
263 |
strdup(buf + sizeof (PATCHLIST) - 1)) == NULL) |
|
264 |
err = ENOMEM; |
|
265 |
||
266 |
free(buf); |
|
267 |
break; |
|
268 |
} |
|
269 |
||
270 |
free(buf); |
|
271 |
} |
|
272 |
(void) fclose(fp); |
|
273 |
||
274 |
return (err); |
|
275 |
} |
|
276 |
||
277 |
/* |
|
278 |
* Verify that we have the minimum KU needed. |
|
279 |
* Note that KU patches are accumulative so future KUs will still deliver |
|
280 |
* 141444 or 141445. |
|
281 |
*/ |
|
282 |
static boolean_t |
|
283 |
have_valid_ku(char *zonename) |
|
284 |
{ |
|
285 |
char *p; |
|
286 |
char *lastp; |
|
287 |
char *pstr; |
|
288 |
char *patchlist = NULL; |
|
11441
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
289 |
char zonepath[MAXPATHLEN]; |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
290 |
char sanity_skip[MAXPATHLEN]; |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
291 |
struct stat64 buf; |
11771
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
292 |
boolean_t is_xpv = B_FALSE; |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
293 |
char platform[80]; |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
294 |
char *xpv_vers = "142910"; |
10840 | 295 |
char *vers_table[] = { |
296 |
"141444-09", |
|
11771
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
297 |
"141445-09"}; |
10840 | 298 |
|
11441
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
299 |
if (zone_get_zonepath(zonename, zonepath, sizeof (zonepath)) != Z_OK) |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
300 |
s10_err(gettext("error getting zone's path")); |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
301 |
|
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
302 |
/* |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
303 |
* If the zone was installed to bypass sanity checking for internal |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
304 |
* testing purposes, just return success. |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
305 |
*/ |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
306 |
if (snprintf(sanity_skip, sizeof (sanity_skip), "%s/root/.sanity_skip", |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
307 |
zonepath) >= sizeof (sanity_skip)) |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
308 |
s10_err(gettext("error formating file path")); |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
309 |
|
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
310 |
if (stat64(sanity_skip, &buf) == 0) |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
311 |
return (B_TRUE); |
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
312 |
|
c3be703336b7
6911417 need a way to test images with no patch metadata
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
11204
diff
changeset
|
313 |
if (get_ku_patchlist(zonepath, &patchlist) != 0 || patchlist == NULL) |
10840 | 314 |
return (B_FALSE); |
315 |
||
11771
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
316 |
/* |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
317 |
* Check if we're running on the i86xpv platform. If so, the zone |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
318 |
* needs a different ku patch to work properly. |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
319 |
*/ |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
320 |
if (sysinfo(SI_PLATFORM, platform, sizeof (platform)) != -1 && |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
321 |
strcmp(platform, "i86xpv") == 0) |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
322 |
is_xpv = B_TRUE; |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
323 |
|
10840 | 324 |
pstr = patchlist; |
325 |
while ((p = strtok_r(pstr, " ", &lastp)) != NULL) { |
|
11771
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
326 |
if (is_xpv) { |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
327 |
if (strncmp(p, xpv_vers, 6) == 0) |
10840 | 328 |
return (B_TRUE); |
11771
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
329 |
} else { |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
330 |
if (strcmp(p, vers_table[0]) == 0 || |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
331 |
strcmp(p, vers_table[1]) == 0) |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
332 |
return (B_TRUE); |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
333 |
} |
10840 | 334 |
|
335 |
pstr = NULL; |
|
336 |
} |
|
337 |
||
11771
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
338 |
if (is_xpv) |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
339 |
s10_err(gettext("the zone must have patch 142910 installed " |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
340 |
"when running in a paravirtualized domain")); |
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
341 |
|
5d55cb57dff3
6914369 enable s10brand on system booted under xvm
<gerald.jelinek@sun.com>
parents:
11441
diff
changeset
|
342 |
|
10840 | 343 |
return (B_FALSE); |
344 |
} |
|
345 |
||
346 |
/* |
|
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
347 |
* Convert the specified file basename into an unsigned integer. If the |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
348 |
* basename contains characters that cannot be converted into digits or the |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
349 |
* basename isn't NULL or newline-terminated, then this function returns |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
350 |
* the unsigned equivalent of -1. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
351 |
*/ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
352 |
static unsigned int |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
353 |
basename_to_uint(const char *basenamep) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
354 |
{ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
355 |
char *filename_endptr; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
356 |
unsigned int bit_index; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
357 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
358 |
errno = 0; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
359 |
bit_index = (unsigned int)strtoul(basenamep, &filename_endptr, 10); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
360 |
if (errno != 0 || (*filename_endptr != '\n' && |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
361 |
*filename_endptr != '\0') || filename_endptr == basenamep) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
362 |
return ((unsigned int)-1); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
363 |
return (bit_index); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
364 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
365 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
366 |
/* |
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
367 |
* Determine which features/behaviors should be emulated and construct a bitmap |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
368 |
* representing the results. Associate the bitmap with the zone so that |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
369 |
* the brand's emulation library will be able to retrieve the bitmap and |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
370 |
* determine how the zone's process' behaviors should be emulated. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
371 |
* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
372 |
* This function does not return if an error occurs. |
10840 | 373 |
*/ |
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
374 |
static void |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
375 |
set_zone_emul_bitmap(char *zonename) |
10840 | 376 |
{ |
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
377 |
char zoneroot[MAXPATHLEN]; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
378 |
char path[MAXPATHLEN]; |
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
379 |
DIR *req_emulation_dirp; |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
380 |
struct dirent *emul_feature_filep; |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
381 |
s10_emul_bitmap_t bitmap; |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
382 |
unsigned int bit_index; |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
383 |
zoneid_t zoneid; |
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
384 |
FILE *delete_listp; |
10840 | 385 |
|
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
386 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
387 |
* If the Solaris 10 directory containing emulation feature files |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
388 |
* doesn't exist in the zone, then assume that it only needs the |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
389 |
* most basic emulation and, therefore, doesn't need a bitmap. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
390 |
*/ |
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
391 |
if (zone_get_rootpath(zonename, zoneroot, sizeof (zoneroot)) != Z_OK) |
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
392 |
s10_err(gettext("error getting zone's path")); |
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
393 |
if (snprintf(path, sizeof (path), "%s" S10_REQ_EMULATION_DIR, |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
394 |
zoneroot) >= sizeof (path)) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
395 |
s10_err(gettext("zone's emulation versioning directory's path " |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
396 |
"%s" S10_REQ_EMULATION_DIR " is too long"), zoneroot); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
397 |
if ((req_emulation_dirp = opendir(path)) == NULL) |
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
398 |
return; |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
399 |
bzero(bitmap, sizeof (bitmap)); |
10840 | 400 |
|
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
401 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
402 |
* Iterate over the contents of the directory and determine which |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
403 |
* features the brand should emulate for this zone. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
404 |
*/ |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
405 |
while ((emul_feature_filep = readdir(req_emulation_dirp)) != NULL) { |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
406 |
if (strcmp(emul_feature_filep->d_name, ".") == 0 || |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
407 |
strcmp(emul_feature_filep->d_name, "..") == 0) |
10840 | 408 |
continue; |
409 |
||
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
410 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
411 |
* Convert the file's name to an unsigned integer. Ignore |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
412 |
* files whose names aren't unsigned integers. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
413 |
*/ |
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
414 |
bit_index = basename_to_uint(emul_feature_filep->d_name); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
415 |
if (bit_index == (unsigned int)-1) |
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
416 |
continue; |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
417 |
|
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
418 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
419 |
* Determine if the brand can emulate the feature specified |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
420 |
* by bit_index. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
421 |
*/ |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
422 |
if (bit_index >= S10_NUM_EMUL_FEATURES) { |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
423 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
424 |
* The zone requires emulation that the brand can't |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
425 |
* provide. Notify the user by displaying an error |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
426 |
* message. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
427 |
*/ |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
428 |
s10_err(gettext("The zone's version of Solaris 10 is " |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
429 |
"incompatible with the\ncurrent version of the " |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
430 |
"solaris10 brand.\nPlease update your Solaris " |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
431 |
"system to the latest release.")); |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
432 |
} else { |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
433 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
434 |
* Set the feature's flag in the bitmap. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
435 |
*/ |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
436 |
bitmap[(bit_index >> 3)] |= (1 << (bit_index & 0x7)); |
10840 | 437 |
} |
438 |
} |
|
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
439 |
(void) closedir(req_emulation_dirp); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
440 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
441 |
/* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
442 |
* The zone's administrator might have removed a patch that delivered |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
443 |
* an emulation feature file the last time the zone ran. If so, then |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
444 |
* the zone's patch utilities won't delete the file until the zone's |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
445 |
* svc:/system/patch-finish:delete SMF service runs. This is |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
446 |
* problematic because the zone will be using system libraries whose |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
447 |
* ioctl structures and syscall invocations will differ from those |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
448 |
* expected by the emulation library. For example, if an administrator |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
449 |
* removes a patch that affects the formats of MNTFS ioctls, then the |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
450 |
* administrator's zone will use a version of libc.so.1 that issues |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
451 |
* MNTFS ioctls that use older structure versions than the zone's |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
452 |
* emulation library will expect. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
453 |
* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
454 |
* Fortunately, the patchrm utility creates a hidden file, |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
455 |
* /var/sadm/patch/.delete_list, which lists all files that |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
456 |
* svc:/system/patch-finish:delete will delete. We'll determine whether |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
457 |
* this file exists in the zone and disable the emulation bits |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
458 |
* associated with the emulation feature files that will be deleted. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
459 |
* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
460 |
* NOTE: The patch tools lofs mount backup copies of critical system |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
461 |
* libraries, such as /lib/libc.so.1, over their replacements whenever |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
462 |
* administrators add or remove DAP patches. Consequently, there isn't |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
463 |
* a window of vulnerability between patch addition or removal and |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
464 |
* zone reboot. The aforementioned problem only occurs after a zone |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
465 |
* reboots. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
466 |
*/ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
467 |
if (snprintf(path, sizeof (path), "%s" DELETE_LIST_PATH, zoneroot) >= |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
468 |
sizeof (path)) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
469 |
s10_err(gettext("zone's delete list's path %s" DELETE_LIST_PATH |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
470 |
" is too long"), zoneroot); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
471 |
if ((delete_listp = fopen(path, "r")) != NULL) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
472 |
while (fgets(path, sizeof (path), delete_listp) != NULL) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
473 |
char *const basenamep = path + |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
474 |
sizeof (S10_REQ_EMULATION_DIR); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
475 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
476 |
/* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
477 |
* Make sure that the file is in the directory |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
478 |
* containing emulation feature files. If it is, |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
479 |
* then basenamep should refer to the basename of |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
480 |
* the file. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
481 |
*/ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
482 |
if (strncmp(path, S10_REQ_EMULATION_DIR, |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
483 |
sizeof (S10_REQ_EMULATION_DIR) - 1) != 0) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
484 |
continue; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
485 |
if (*(basenamep - 1) != '/') |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
486 |
continue; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
487 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
488 |
/* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
489 |
* Convert the file's basename into a bit index in |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
490 |
* the emulation bitmap. If the file's basename isn't |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
491 |
* integral, then skip the file. Otherwise, clear the |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
492 |
* corresponding bit in the bitmap. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
493 |
*/ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
494 |
bit_index = basename_to_uint(basenamep); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
495 |
if (bit_index == (unsigned int)-1) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
496 |
continue; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
497 |
if (bit_index < S10_NUM_EMUL_FEATURES) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
498 |
bitmap[(bit_index >> 3)] &= |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
499 |
~(1 << (bit_index & 0x7)); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
500 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
501 |
if (ferror(delete_listp) != 0 || feof(delete_listp) == 0) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
502 |
s10_err(gettext("The program encountered an error while" |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
503 |
" reading from %s" DELETE_LIST_PATH "."), zoneroot); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
504 |
(void) fclose(delete_listp); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
505 |
} else if (errno != ENOENT) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
506 |
/* |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
507 |
* The delete list exists but couldn't be opened. Warn the |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
508 |
* administrator. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
509 |
*/ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
510 |
s10_err(gettext("Unable to open %s" DELETE_LIST_PATH ": %s"), |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
511 |
zoneroot, strerror(errno)); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
11771
diff
changeset
|
512 |
} |
10840 | 513 |
|
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
514 |
/* |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
515 |
* We're done scanning files. Set the zone's emulation bitmap. |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
516 |
*/ |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
517 |
if ((zoneid = getzoneidbyname(zonename)) < 0) |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
518 |
s10_err(gettext("unable to get zoneid")); |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
519 |
if (zone_setattr(zoneid, S10_EMUL_BITMAP, bitmap, sizeof (bitmap)) != 0) |
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
520 |
s10_err(gettext("error setting zone's emulation bitmap")); |
10840 | 521 |
} |
522 |
||
523 |
static int |
|
524 |
s10_boot(char *zonename) |
|
525 |
{ |
|
526 |
if (!have_valid_ku(zonename)) |
|
527 |
s10_err(gettext("The installed version of Solaris 10 is " |
|
528 |
"not supported")); |
|
529 |
||
10963
0984a1a1a377
6898315 solaris10-branded zones need a new versioning mechanism
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
530 |
set_zone_emul_bitmap(zonename); |
10840 | 531 |
|
532 |
return (0); |
|
533 |
} |
|
534 |
||
535 |
static void |
|
536 |
usage() |
|
537 |
{ |
|
538 |
(void) fprintf(stderr, gettext( |
|
539 |
"usage:\t%s verify <xml file>\n" |
|
540 |
"\t%s boot\n"), |
|
541 |
bname, bname); |
|
542 |
exit(1); |
|
543 |
} |
|
544 |
||
545 |
int |
|
546 |
main(int argc, char *argv[]) |
|
547 |
{ |
|
548 |
(void) setlocale(LC_ALL, ""); |
|
549 |
(void) textdomain(TEXT_DOMAIN); |
|
550 |
||
551 |
bname = basename(argv[0]); |
|
552 |
||
553 |
if (argc != 3) |
|
554 |
usage(); |
|
555 |
||
556 |
/* |
|
557 |
* XXX This is a temporary env variable for the initial release to |
|
558 |
* enable the use of features which are not yet tested or fully |
|
559 |
* implemented. |
|
560 |
*/ |
|
561 |
if (getenv("S10BRAND_TEST") != NULL) |
|
562 |
override = B_TRUE; |
|
563 |
||
564 |
if (strcmp(argv[1], "verify") == 0) |
|
565 |
return (s10_verify(argv[2])); |
|
566 |
||
567 |
if (strcmp(argv[1], "boot") == 0) |
|
568 |
return (s10_boot(argv[2])); |
|
569 |
||
570 |
usage(); |
|
571 |
/*NOTREACHED*/ |
|
572 |
} |