kern_linker.c (217555) | kern_linker.c (220158) |
---|---|
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 --- 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) 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 --- 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/kern_linker.c 217555 2011-01-18 21:14:18Z mdf $"); | 28__FBSDID("$FreeBSD: head/sys/kern/kern_linker.c 220158 2011-03-30 14:46:12Z kib $"); |
29 30#include "opt_ddb.h" 31#include "opt_hwpmc_hooks.h" 32 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> --- 1159 unchanged lines hidden (view full) --- 1196 KLD_UNLOCK(); 1197 return (error); 1198} 1199 1200int 1201kldstat(struct thread *td, struct kldstat_args *uap) 1202{ 1203 struct kld_file_stat stat; | 29 30#include "opt_ddb.h" 31#include "opt_hwpmc_hooks.h" 32 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> --- 1159 unchanged lines hidden (view full) --- 1196 KLD_UNLOCK(); 1197 return (error); 1198} 1199 1200int 1201kldstat(struct thread *td, struct kldstat_args *uap) 1202{ 1203 struct kld_file_stat stat; |
1204 linker_file_t lf; 1205 int error, namelen, version, version_num; | 1204 int error, version; |
1206 1207 /* 1208 * Check the version of the user's structure. 1209 */ | 1205 1206 /* 1207 * Check the version of the user's structure. 1208 */ |
1210 if ((error = copyin(&uap->stat->version, &version, sizeof(version))) != 0) | 1209 if ((error = copyin(&uap->stat->version, &version, sizeof(version))) 1210 != 0) |
1211 return (error); | 1211 return (error); |
1212 if (version == sizeof(struct kld_file_stat_1)) 1213 version_num = 1; 1214 else if (version == sizeof(struct kld_file_stat)) 1215 version_num = 2; 1216 else | 1212 if (version != sizeof(struct kld_file_stat_1) && 1213 version != sizeof(struct kld_file_stat)) |
1217 return (EINVAL); 1218 | 1214 return (EINVAL); 1215 |
1216 error = kern_kldstat(td, uap->fileid, &stat); 1217 if (error != 0) 1218 return (error); 1219 return (copyout(&stat, uap->stat, version)); 1220} 1221 1222int 1223kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat) 1224{ 1225 linker_file_t lf; 1226 int namelen; |
|
1219#ifdef MAC | 1227#ifdef MAC |
1228 int error; 1229 |
|
1220 error = mac_kld_check_stat(td->td_ucred); 1221 if (error) 1222 return (error); 1223#endif 1224 1225 KLD_LOCK(); | 1230 error = mac_kld_check_stat(td->td_ucred); 1231 if (error) 1232 return (error); 1233#endif 1234 1235 KLD_LOCK(); |
1226 lf = linker_find_file_by_id(uap->fileid); | 1236 lf = linker_find_file_by_id(fileid); |
1227 if (lf == NULL) { 1228 KLD_UNLOCK(); 1229 return (ENOENT); 1230 } 1231 1232 /* Version 1 fields: */ 1233 namelen = strlen(lf->filename) + 1; 1234 if (namelen > MAXPATHLEN) 1235 namelen = MAXPATHLEN; | 1237 if (lf == NULL) { 1238 KLD_UNLOCK(); 1239 return (ENOENT); 1240 } 1241 1242 /* Version 1 fields: */ 1243 namelen = strlen(lf->filename) + 1; 1244 if (namelen > MAXPATHLEN) 1245 namelen = MAXPATHLEN; |
1236 bcopy(lf->filename, &stat.name[0], namelen); 1237 stat.refs = lf->refs; 1238 stat.id = lf->id; 1239 stat.address = lf->address; 1240 stat.size = lf->size; 1241 if (version_num > 1) { 1242 /* Version 2 fields: */ 1243 namelen = strlen(lf->pathname) + 1; 1244 if (namelen > MAXPATHLEN) 1245 namelen = MAXPATHLEN; 1246 bcopy(lf->pathname, &stat.pathname[0], namelen); 1247 } | 1246 bcopy(lf->filename, &stat->name[0], namelen); 1247 stat->refs = lf->refs; 1248 stat->id = lf->id; 1249 stat->address = lf->address; 1250 stat->size = lf->size; 1251 /* Version 2 fields: */ 1252 namelen = strlen(lf->pathname) + 1; 1253 if (namelen > MAXPATHLEN) 1254 namelen = MAXPATHLEN; 1255 bcopy(lf->pathname, &stat->pathname[0], namelen); |
1248 KLD_UNLOCK(); 1249 1250 td->td_retval[0] = 0; | 1256 KLD_UNLOCK(); 1257 1258 td->td_retval[0] = 0; |
1251 1252 return (copyout(&stat, uap->stat, version)); | 1259 return (0); |
1253} 1254 1255int 1256kldfirstmod(struct thread *td, struct kldfirstmod_args *uap) 1257{ 1258 linker_file_t lf; 1259 module_t mp; 1260 int error = 0; --- 889 unchanged lines hidden --- | 1260} 1261 1262int 1263kldfirstmod(struct thread *td, struct kldfirstmod_args *uap) 1264{ 1265 linker_file_t lf; 1266 module_t mp; 1267 int error = 0; --- 889 unchanged lines hidden --- |