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

Function kern_kldstat

freebsd/kern/kern_linker.c:1273–1311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271}
1272
1273int
1274kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat)
1275{
1276 linker_file_t lf;
1277 int namelen;
1278#ifdef MAC
1279 int error;
1280
1281 error = mac_kld_check_stat(td->td_ucred);
1282 if (error)
1283 return (error);
1284#endif
1285
1286 sx_xlock(&kld_sx);
1287 lf = linker_find_file_by_id(fileid);
1288 if (lf == NULL) {
1289 sx_xunlock(&kld_sx);
1290 return (ENOENT);
1291 }
1292
1293 /* Version 1 fields: */
1294 namelen = strlen(lf->filename) + 1;
1295 if (namelen > sizeof(stat->name))
1296 namelen = sizeof(stat->name);
1297 bcopy(lf->filename, &stat->name[0], namelen);
1298 stat->refs = lf->refs;
1299 stat->id = lf->id;
1300 stat->address = lf->address;
1301 stat->size = lf->size;
1302 /* Version 2 fields: */
1303 namelen = strlen(lf->pathname) + 1;
1304 if (namelen > sizeof(stat->pathname))
1305 namelen = sizeof(stat->pathname);
1306 bcopy(lf->pathname, &stat->pathname[0], namelen);
1307 sx_xunlock(&kld_sx);
1308
1309 td->td_retval[0] = 0;
1310 return (0);
1311}
1312
1313#ifdef DDB
1314DB_COMMAND(kldstat, db_kldstat)

Callers 1

sys_kldstatFunction · 0.85

Calls 2

mac_kld_check_statFunction · 0.85
linker_find_file_by_idFunction · 0.85

Tested by

no test coverage detected