xref: /illumos-gate/usr/src/uts/sparc/zfs/spa_boot.c (revision 30c304d9746f4a048a7de56d31333b0fa8e43dee)
1e7cbe64fSgw /*
2e7cbe64fSgw  * CDDL HEADER START
3e7cbe64fSgw  *
4e7cbe64fSgw  * The contents of this file are subject to the terms of the
5e7cbe64fSgw  * Common Development and Distribution License (the "License").
6e7cbe64fSgw  * You may not use this file except in compliance with the License.
7e7cbe64fSgw  *
8e7cbe64fSgw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e7cbe64fSgw  * or http://www.opensolaris.org/os/licensing.
10e7cbe64fSgw  * See the License for the specific language governing permissions
11e7cbe64fSgw  * and limitations under the License.
12e7cbe64fSgw  *
13e7cbe64fSgw  * When distributing Covered Code, include this CDDL HEADER in each
14e7cbe64fSgw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15e7cbe64fSgw  * If applicable, add the following below this CDDL HEADER, with the
16e7cbe64fSgw  * fields enclosed by brackets "[]" replaced with your own identifying
17e7cbe64fSgw  * information: Portions Copyright [yyyy] [name of copyright owner]
18e7cbe64fSgw  *
19e7cbe64fSgw  * CDDL HEADER END
20e7cbe64fSgw  */
21e7cbe64fSgw 
22e7cbe64fSgw /*
23b24ab676SJeff Bonwick  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24e7cbe64fSgw  * Use is subject to license terms.
25e7cbe64fSgw  */
26e7cbe64fSgw 
27283b8460SGeorge.Wilson /*
28283b8460SGeorge.Wilson  * Copyright (c) 2012 by Delphix. All rights reserved.
29*30c304d9SJoshua M. Clulow  * Copyright 2020 Joshua M. Clulow <josh@sysmgr.org>
30283b8460SGeorge.Wilson  */
31283b8460SGeorge.Wilson 
32b24ab676SJeff Bonwick #include <sys/zio.h>
33e7cbe64fSgw #include <sys/spa.h>
34e7cbe64fSgw #include <sys/bootconf.h>
35e7cbe64fSgw 
36283b8460SGeorge.Wilson extern int zfs_deadman_enabled;
37283b8460SGeorge.Wilson 
38e7cbe64fSgw char *
39*30c304d9SJoshua M. Clulow spa_get_bootprop(const char *propname)
40e7cbe64fSgw {
41e7cbe64fSgw 	int proplen;
42051aabe6Staylor 	char *value;
43e7cbe64fSgw 
44051aabe6Staylor 	proplen = BOP_GETPROPLEN(bootops, propname);
45051aabe6Staylor 	if (proplen <= 0)
46e7cbe64fSgw 		return (NULL);
47e7cbe64fSgw 
48051aabe6Staylor 	value = kmem_zalloc(proplen, KM_SLEEP);
49051aabe6Staylor 	if (BOP_GETPROP(bootops, propname, value) == -1) {
50051aabe6Staylor 		kmem_free(value, proplen);
51e7cbe64fSgw 		return (NULL);
52e7cbe64fSgw 	}
53e7cbe64fSgw 
54051aabe6Staylor 	return (value);
55e7cbe64fSgw }
56e7cbe64fSgw 
57e7cbe64fSgw void
58*30c304d9SJoshua M. Clulow spa_free_bootprop(char *propval)
59e7cbe64fSgw {
60*30c304d9SJoshua M. Clulow 	if (propval == NULL) {
61*30c304d9SJoshua M. Clulow 		return;
62*30c304d9SJoshua M. Clulow 	}
63*30c304d9SJoshua M. Clulow 
64*30c304d9SJoshua M. Clulow 	kmem_free(propval, strlen(propval) + 1);
65e7cbe64fSgw }
66283b8460SGeorge.Wilson 
67283b8460SGeorge.Wilson void
68283b8460SGeorge.Wilson spa_arch_init(void)
69283b8460SGeorge.Wilson {
70283b8460SGeorge.Wilson 	/*
71283b8460SGeorge.Wilson 	 * The deadman is disabled by default on sparc.
72283b8460SGeorge.Wilson 	 */
73283b8460SGeorge.Wilson 	if (zfs_deadman_enabled == -1)
74283b8460SGeorge.Wilson 		zfs_deadman_enabled = 0;
75283b8460SGeorge.Wilson }
76