kern_linker.c (69781) | kern_linker.c (70417) |
---|---|
1/*- 2 * Copyright (c) 1997-2000 Doug Rabson 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 1/*- 2 * Copyright (c) 1997-2000 Doug Rabson 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: head/sys/kern/kern_linker.c 69781 2000-12-08 21:51:06Z dwmalone $ | 26 * $FreeBSD: head/sys/kern/kern_linker.c 70417 2000-12-28 08:14:58Z peter $ |
27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/systm.h> 34#include <sys/malloc.h> --- 1131 unchanged lines hidden (view full) --- 1166 * 1167 * If the module name is qualified in any way (contains path, etc.) 1168 * the we simply return a copy of it. 1169 * 1170 * The search path can be manipulated via sysctl. Note that we use the ';' 1171 * character as a separator to be consistent with the bootloader. 1172 */ 1173 | 27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/systm.h> 34#include <sys/malloc.h> --- 1131 unchanged lines hidden (view full) --- 1166 * 1167 * If the module name is qualified in any way (contains path, etc.) 1168 * the we simply return a copy of it. 1169 * 1170 * The search path can be manipulated via sysctl. Note that we use the ';' 1171 * character as a separator to be consistent with the bootloader. 1172 */ 1173 |
1174static char linker_path[MAXPATHLEN] = "/boot/modules/;/modules/;/boot/kernel/"; | 1174static char def_linker_path[] = "/boot/modules/;/modules/;/boot/kernel/"; 1175static char linker_path[MAXPATHLEN] = ""; |
1175 1176SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path, 1177 sizeof(linker_path), "module load search path"); 1178 | 1176 1177SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path, 1178 sizeof(linker_path), "module load search path"); 1179 |
1180TUNABLE_STR_DECL("module_path", def_linker_path, linker_path, 1181 sizeof(linker_path)); 1182 |
|
1179static char *linker_ext_list[] = { 1180 ".ko", 1181 "", 1182 NULL 1183}; 1184 1185static char * 1186linker_search_path(const char *name) --- 19 unchanged lines hidden (view full) --- 1206 /* traverse the linker path */ 1207 cp = linker_path; 1208 len = strlen(name); 1209 for (;;) { 1210 1211 /* find the end of this component */ 1212 for (ep = cp; (*ep != 0) && (*ep != ';'); ep++) 1213 ; | 1183static char *linker_ext_list[] = { 1184 ".ko", 1185 "", 1186 NULL 1187}; 1188 1189static char * 1190linker_search_path(const char *name) --- 19 unchanged lines hidden (view full) --- 1210 /* traverse the linker path */ 1211 cp = linker_path; 1212 len = strlen(name); 1213 for (;;) { 1214 1215 /* find the end of this component */ 1216 for (ep = cp; (*ep != 0) && (*ep != ';'); ep++) 1217 ; |
1214 result = malloc((len + (ep - cp) + extlen), M_LINKER, M_WAITOK); | 1218 result = malloc((len + (ep - cp) + extlen + 1), M_LINKER, M_WAITOK); |
1215 if (result == NULL) /* actually ENOMEM */ 1216 return(NULL); 1217 for (cpp = linker_ext_list; *cpp; cpp++) { 1218 strncpy(result, cp, ep - cp); | 1219 if (result == NULL) /* actually ENOMEM */ 1220 return(NULL); 1221 for (cpp = linker_ext_list; *cpp; cpp++) { 1222 strncpy(result, cp, ep - cp); |
1219 strcpy(result + (ep - cp), name); | 1223 strcpy(result + (ep - cp), "/"); 1224 strcat(result, name); |
1220 strcat(result, *cpp); | 1225 strcat(result, *cpp); |
1221 | |
1222 /* 1223 * Attempt to open the file, and return the path if we succeed 1224 * and it's a regular file. 1225 */ 1226 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, p); 1227 flags = FREAD; 1228 error = vn_open(&nd, &flags, 0); 1229 if (error == 0) { --- 163 unchanged lines hidden --- | 1226 /* 1227 * Attempt to open the file, and return the path if we succeed 1228 * and it's a regular file. 1229 */ 1230 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, p); 1231 flags = FREAD; 1232 error = vn_open(&nd, &flags, 0); 1233 if (error == 0) { --- 163 unchanged lines hidden --- |