Deleted Added
sdiff udiff text old ( 105337 ) new ( 107089 )
full compact
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 105337 2002-10-17 17:28:57Z sam $
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>
35#include <sys/sysproto.h>
36#include <sys/sysent.h>
37#include <sys/proc.h>
38#include <sys/lock.h>
39#include <sys/mutex.h>
40#include <sys/sx.h>
41#include <sys/module.h>
42#include <sys/linker.h>
43#include <sys/fcntl.h>
44#include <sys/libkern.h>
45#include <sys/namei.h>
46#include <sys/vnode.h>
47#include <sys/sysctl.h>
48

--- 420 unchanged lines hidden (view full) ---

469 struct common_symbol *cp;
470 int error, i;
471
472 error = 0;
473
474 /* Refuse to unload modules if securelevel raised. */
475 if (securelevel > 0)
476 return (EPERM);
477
478 KLD_DPF(FILE, ("linker_file_unload: lf->refs=%d\n", file->refs));
479 if (file->refs == 1) {
480 KLD_DPF(FILE, ("linker_file_unload: file is unloading,"
481 " informing modules\n"));
482
483 /*
484 * Inform any modules associated with this file.

--- 334 unchanged lines hidden (view full) ---

819int
820kldfind(struct thread *td, struct kldfind_args *uap)
821{
822 char *pathname;
823 const char *filename;
824 linker_file_t lf;
825 int error = 0;
826
827 mtx_lock(&Giant);
828 td->td_retval[0] = -1;
829
830 pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
831 if ((error = copyinstr(SCARG(uap, file), pathname, MAXPATHLEN,
832 NULL)) != 0)
833 goto out;
834

--- 14 unchanged lines hidden (view full) ---

849 * MPSAFE
850 */
851int
852kldnext(struct thread *td, struct kldnext_args *uap)
853{
854 linker_file_t lf;
855 int error = 0;
856
857 mtx_lock(&Giant);
858
859 if (SCARG(uap, fileid) == 0) {
860 mtx_lock(&kld_mtx);
861 if (TAILQ_FIRST(&linker_files))
862 td->td_retval[0] = TAILQ_FIRST(&linker_files)->id;
863 else
864 td->td_retval[0] = 0;

--- 19 unchanged lines hidden (view full) ---

884int
885kldstat(struct thread *td, struct kldstat_args *uap)
886{
887 linker_file_t lf;
888 int error = 0;
889 int namelen, version;
890 struct kld_file_stat *stat;
891
892 mtx_lock(&Giant);
893
894 lf = linker_find_file_by_id(SCARG(uap, fileid));
895 if (lf == NULL) {
896 error = ENOENT;
897 goto out;
898 }
899 stat = SCARG(uap, stat);

--- 33 unchanged lines hidden (view full) ---

933 */
934int
935kldfirstmod(struct thread *td, struct kldfirstmod_args *uap)
936{
937 linker_file_t lf;
938 module_t mp;
939 int error = 0;
940
941 mtx_lock(&Giant);
942 lf = linker_find_file_by_id(SCARG(uap, fileid));
943 if (lf) {
944 MOD_SLOCK;
945 mp = TAILQ_FIRST(&lf->modules);
946 if (mp != NULL)
947 td->td_retval[0] = module_getid(mp);
948 else

--- 13 unchanged lines hidden (view full) ---

962{
963 char *symstr = NULL;
964 c_linker_sym_t sym;
965 linker_symval_t symval;
966 linker_file_t lf;
967 struct kld_sym_lookup lookup;
968 int error = 0;
969
970 mtx_lock(&Giant);
971
972 if ((error = copyin(SCARG(uap, data), &lookup, sizeof(lookup))) != 0)
973 goto out;
974 if (lookup.version != sizeof(lookup) ||
975 SCARG(uap, cmd) != KLDSYM_LOOKUP) {
976 error = EINVAL;
977 goto out;

--- 817 unchanged lines hidden (view full) ---

1795 * in the kernel.
1796 */
1797static int
1798sysctl_kern_function_list(SYSCTL_HANDLER_ARGS)
1799{
1800 linker_file_t lf;
1801 int error;
1802
1803 sysctl_wire_old_buffer(req, 0);
1804 mtx_lock(&kld_mtx);
1805 TAILQ_FOREACH(lf, &linker_files, link) {
1806 error = LINKER_EACH_FUNCTION_NAME(lf,
1807 sysctl_kern_function_list_iterate, req);
1808 if (error) {
1809 mtx_unlock(&kld_mtx);
1810 return (error);
1811 }
1812 }
1813 mtx_unlock(&kld_mtx);
1814 return (SYSCTL_OUT(req, "", 1));
1815}
1816
1817SYSCTL_PROC(_kern, OID_AUTO, function_list, CTLFLAG_RD,
1818 NULL, 0, sysctl_kern_function_list, "", "kernel function list");