subr_hints.c (148586) | subr_hints.c (160217) |
---|---|
1/*- 2 * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/subr_hints.c 148586 2005-07-31 10:46:55Z netchild $"); | 28__FBSDID("$FreeBSD: head/sys/kern/subr_hints.c 160217 2006-07-09 21:42:58Z scottl $"); |
29 30#include <sys/param.h> 31#include <sys/lock.h> | 29 30#include <sys/param.h> 31#include <sys/lock.h> |
32#include <sys/sx.h> | 32#include <sys/mutex.h> |
33#include <sys/systm.h> 34#include <sys/bus.h> 35 36/* 37 * Access functions for device resources. 38 */ 39 40static int checkmethod = 1; --- 26 unchanged lines hidden (view full) --- 67 case 0: /* loader hints in environment only */ 68 break; 69 case 1: /* static hints only */ 70 hintp = static_hints; 71 checkmethod = 0; 72 break; 73 case 2: /* fallback mode */ 74 if (dynamic_kenv) { | 33#include <sys/systm.h> 34#include <sys/bus.h> 35 36/* 37 * Access functions for device resources. 38 */ 39 40static int checkmethod = 1; --- 26 unchanged lines hidden (view full) --- 67 case 0: /* loader hints in environment only */ 68 break; 69 case 1: /* static hints only */ 70 hintp = static_hints; 71 checkmethod = 0; 72 break; 73 case 2: /* fallback mode */ 74 if (dynamic_kenv) { |
75 sx_slock(&kenv_lock); | 75 mtx_lock(&kenv_lock); |
76 cp = kenvp[0]; 77 for (i = 0; cp != NULL; cp = kenvp[++i]) { 78 if (!strncmp(cp, "hint.", 5)) { 79 use_kenv = 1; 80 checkmethod = 0; 81 break; 82 } 83 } | 76 cp = kenvp[0]; 77 for (i = 0; cp != NULL; cp = kenvp[++i]) { 78 if (!strncmp(cp, "hint.", 5)) { 79 use_kenv = 1; 80 checkmethod = 0; 81 break; 82 } 83 } |
84 sx_sunlock(&kenv_lock); | 84 mtx_unlock(&kenv_lock); |
85 } else { 86 cp = kern_envp; 87 while (cp) { 88 if (strncmp(cp, "hint.", 5) == 0) { 89 cp = NULL; 90 hintp = kern_envp; 91 break; 92 } --- 16 unchanged lines hidden (view full) --- 109 use_kenv = 1; 110 checkmethod = 0; 111 } else 112 hintp = kern_envp; 113 } 114 } 115 116 if (use_kenv) { | 85 } else { 86 cp = kern_envp; 87 while (cp) { 88 if (strncmp(cp, "hint.", 5) == 0) { 89 cp = NULL; 90 hintp = kern_envp; 91 break; 92 } --- 16 unchanged lines hidden (view full) --- 109 use_kenv = 1; 110 checkmethod = 0; 111 } else 112 hintp = kern_envp; 113 } 114 } 115 116 if (use_kenv) { |
117 sx_slock(&kenv_lock); | 117 mtx_lock(&kenv_lock); |
118 i = 0; 119 cp = kenvp[0]; 120 if (cp == NULL) { | 118 i = 0; 119 cp = kenvp[0]; 120 if (cp == NULL) { |
121 sx_sunlock(&kenv_lock); | 121 mtx_unlock(&kenv_lock); |
122 return (ENOENT); 123 } 124 } else 125 cp = hintp; 126 while (cp) { 127 hit = 1; 128 (*line)++; 129 if (strncmp(cp, "hint.", 5) != 0) --- 30 unchanged lines hidden (view full) --- 160 cp++; 161 if (*cp == '\0') { 162 cp = NULL; 163 break; 164 } 165 } 166 } 167 if (use_kenv) | 122 return (ENOENT); 123 } 124 } else 125 cp = hintp; 126 while (cp) { 127 hit = 1; 128 (*line)++; 129 if (strncmp(cp, "hint.", 5) != 0) --- 30 unchanged lines hidden (view full) --- 160 cp++; 161 if (*cp == '\0') { 162 cp = NULL; 163 break; 164 } 165 } 166 } 167 if (use_kenv) |
168 sx_sunlock(&kenv_lock); | 168 mtx_unlock(&kenv_lock); |
169 if (cp == NULL) 170 return ENOENT; 171 172 s = cp; 173 /* This is a bit of a hack, but at least is reentrant */ 174 /* Note that it returns some !unterminated! strings. */ 175 s = index(s, '.') + 1; /* start of device */ 176 if (ret_name) --- 207 unchanged lines hidden --- | 169 if (cp == NULL) 170 return ENOENT; 171 172 s = cp; 173 /* This is a bit of a hack, but at least is reentrant */ 174 /* Note that it returns some !unterminated! strings. */ 175 s = index(s, '.') + 1; /* start of device */ 176 if (ret_name) --- 207 unchanged lines hidden --- |