MCPcopy Create free account
hub / github.com/F-Stack/f-stack / prison0_init

Function prison0_init

freebsd/kern/kern_jail.c:231–266  ·  view source on GitHub ↗

* Initialize the parts of prison0 that can't be static-initialized with * constants. This is called from proc0_init() after creating thread0 cpuset. */

Source from the content-addressed store, hash-verified

229 * constants. This is called from proc0_init() after creating thread0 cpuset.
230 */
231void
232prison0_init(void)
233{
234 uint8_t *file, *data;
235 size_t size;
236
237 prison0.pr_cpuset = cpuset_ref(thread0.td_cpuset);
238 prison0.pr_osreldate = osreldate;
239 strlcpy(prison0.pr_osrelease, osrelease, sizeof(prison0.pr_osrelease));
240
241 /* If we have a preloaded hostuuid, use it. */
242 file = preload_search_by_type(PRISON0_HOSTUUID_MODULE);
243 if (file != NULL) {
244 data = preload_fetch_addr(file);
245 size = preload_fetch_size(file);
246 if (data != NULL) {
247 /*
248 * The preloaded data may include trailing whitespace, almost
249 * certainly a newline; skip over any whitespace or
250 * non-printable characters to be safe.
251 */
252 while (size > 0 && data[size - 1] <= 0x20) {
253 data[size--] = '\0';
254 }
255 if (validate_uuid(data, size, NULL, 0) == 0) {
256 (void)strlcpy(prison0.pr_hostuuid, data,
257 size + 1);
258 } else if (bootverbose) {
259 printf("hostuuid: preload data malformed: '%s'",
260 data);
261 }
262 }
263 }
264 if (bootverbose)
265 printf("hostuuid: using %s\n", prison0.pr_hostuuid);
266}
267
268/*
269 * struct jail_args {

Callers 1

proc0_initFunction · 0.85

Calls 7

cpuset_refFunction · 0.85
preload_search_by_typeFunction · 0.85
preload_fetch_addrFunction · 0.85
preload_fetch_sizeFunction · 0.85
validate_uuidFunction · 0.85
printfFunction · 0.70
strlcpyFunction · 0.50

Tested by

no test coverage detected