Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Enable the ioctl's.
details: https://anonhg.NetBSD.org/src/rev/78cecc7f1fe1
branches: trunk
changeset: 546573:78cecc7f1fe1
user: ragge <ragge%NetBSD.org@localhost>
date: Thu May 01 20:46:20 2003 +0000
description:
Enable the ioctl's.
diffstat:
sys/kern/kern_ksyms.c | 38 +++++++++++++++++++++++++++-----------
sys/sys/ksyms.h | 29 ++++++++++++++++-------------
2 files changed, 43 insertions(+), 24 deletions(-)
diffs (176 lines):
diff -r 9586cb3987c2 -r 78cecc7f1fe1 sys/kern/kern_ksyms.c
--- a/sys/kern/kern_ksyms.c Thu May 01 20:18:35 2003 +0000
+++ b/sys/kern/kern_ksyms.c Thu May 01 20:46:20 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ksyms.c,v 1.4 2003/04/26 10:24:58 ragge Exp $ */
+/* $NetBSD: kern_ksyms.c,v 1.5 2003/05/01 20:46:20 ragge Exp $ */
/*
* Copyright (c) 2001, 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
* All rights reserved.
@@ -81,6 +81,7 @@
static void ksyms_hdr_init(caddr_t hdraddr);
static void ksyms_sizes_calc(void);
static int ksyms_isopen;
+static int ksyms_maxlen;
#endif
#ifdef KSYMS_DEBUG
@@ -189,8 +190,14 @@
/* Change all symbols to be absolute references */
sym = (Elf_Sym *)tab->sd_symstart;
- for (i = 0; i < tab->sd_symsize/sizeof(Elf_Sym); i++)
+ for (i = 0; i < tab->sd_symsize/sizeof(Elf_Sym); i++) {
sym[i].st_shndx = SHN_ABS;
+ if (sym[i].st_name == 0)
+ continue;
+ j = strlen(sym[i].st_name + tab->sd_strstart) + 1;
+ if (j > ksyms_maxlen)
+ ksyms_maxlen = j;
+ }
CIRCLEQ_INSERT_HEAD(&symtab_queue, tab, sd_queue);
}
@@ -392,14 +399,16 @@
printf("addsym: name %s val %lx\n", name, (long)sym->st_value);
#endif
if (cursyms == NSAVEDSYMS ||
- ((len = strlen(name)) + curnamep + 1) > SZSYMNAMES) {
+ ((len = strlen(name) + 1) + curnamep) > SZSYMNAMES) {
printf("addsym: too many sumbols, skipping '%s'\n", name);
return;
}
strcpy(&symnames[curnamep], name);
savedsyms[cursyms] = *sym;
symnmoff[cursyms] = savedsyms[cursyms].st_name = curnamep;
- curnamep += (len + 1);
+ curnamep += len;
+ if (len > ksyms_maxlen)
+ ksyms_maxlen = len;
cursyms++;
}
/*
@@ -469,6 +478,7 @@
/* Ok, save this symbol */
addsym(&sym[i], strstart + sym[i].st_name);
}
+
sym = malloc(sizeof(Elf_Sym)*cursyms, M_DEVBUF, M_WAITOK);
str = malloc(curnamep, M_DEVBUF, M_WAITOK);
memcpy(sym, savedsyms, sizeof(Elf_Sym)*cursyms);
@@ -771,12 +781,15 @@
int
ksymsioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
{
-#ifdef notyet
struct ksyms_gsymbol *kg = (struct ksyms_gsymbol *)data;
struct symtab *st;
Elf_Sym *sym;
unsigned long val;
int error = 0;
+ char *str;
+
+ if (cmd == KIOCGVALUE || cmd == KIOCGSYMBOL)
+ str = malloc(ksyms_maxlen, M_DEVBUF, M_WAITOK);
switch (cmd) {
case KIOCGVALUE:
@@ -784,9 +797,9 @@
* Use the in-kernel symbol lookup code for fast
* retreival of a value.
*/
- if (error = copyinstr(kg->kg_name, symnm, maxsymnmsz, NULL))
+ if ((error = copyinstr(kg->kg_name, str, ksyms_maxlen, NULL)))
break;
- if (error = ksyms_getval(NULL, symnm, &val, KSYMS_EXTERN))
+ if ((error = ksyms_getval(NULL, str, &val, KSYMS_EXTERN)))
break;
error = copyout(&val, kg->kg_value, sizeof(long));
break;
@@ -796,10 +809,10 @@
* Use the in-kernel symbol lookup code for fast
* retreival of a symbol.
*/
- if (error = copyinstr(kg->kg_name, symnm, maxsymnmsz, NULL))
+ if ((error = copyinstr(kg->kg_name, str, ksyms_maxlen, NULL)))
break;
CIRCLEQ_FOREACH(st, &symtab_queue, sd_queue) {
- if ((sym = findsym(symnm, st)) == NULL)
+ if ((sym = findsym(str, st)) == NULL)
continue;
/* Skip if bad binding */
@@ -826,7 +839,10 @@
error = ENOTTY;
break;
}
-#endif
- return ENOTTY;
+
+ if (cmd == KIOCGVALUE || cmd == KIOCGSYMBOL)
+ free(str, M_DEVBUF);
+
+ return error;
}
#endif
diff -r 9586cb3987c2 -r 78cecc7f1fe1 sys/sys/ksyms.h
--- a/sys/sys/ksyms.h Thu May 01 20:18:35 2003 +0000
+++ b/sys/sys/ksyms.h Thu May 01 20:46:20 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ksyms.h,v 1.3 2003/04/26 10:24:59 ragge Exp $ */
+/* $NetBSD: ksyms.h,v 1.4 2003/05/01 20:46:20 ragge Exp $ */
/*
* Copyright (c) 2001, 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
* All rights reserved.
@@ -26,24 +26,16 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * Definitions used in ksyms_getname() and ksyms_getval().
- */
-#define KSYMS_CLOSEST 0001 /* Nearest lower match */
-#define KSYMS_EXACT 0002 /* Only exact match allowed */
-#define KSYMS_EXTERN 0000 /* Only external symbols (pseudo) */
-#define KSYMS_PROC 0100 /* Procedures only */
-#define KSYMS_ANY 0200 /* Also local symbols (DDB use only) */
+#ifndef _SYS_KSYMS_H_
+#define _SYS_KSYMS_H_
-#ifdef notyet
/*
* Do a lookup of a symbol using the in-kernel lookup algorithm.
*/
-
struct ksyms_gsymbol {
char *kg_name;
union {
- Elf_Sym *ku_sym;
+ void *ku_sym; /* Normally Elf_Sym */
unsigned long *ku_value;
} _un;
#define kg_sym _un.ku_sym
@@ -53,7 +45,16 @@
#define KIOCGSYMBOL _IOW('l', 1, struct ksyms_gsymbol)
#define KIOCGVALUE _IOW('l', 2, struct ksyms_gsymbol)
#define KIOCGSIZE _IOR('l', 3, int)
-#endif
+
+#ifdef _KERNEL
+/*
+ * Definitions used in ksyms_getname() and ksyms_getval().
+ */
+#define KSYMS_CLOSEST 0001 /* Nearest lower match */
+#define KSYMS_EXACT 0002 /* Only exact match allowed */
+#define KSYMS_EXTERN 0000 /* Only external symbols (pseudo) */
+#define KSYMS_PROC 0100 /* Procedures only */
+#define KSYMS_ANY 0200 /* Also local symbols (DDB use only) */
/*
* Prototypes
@@ -66,3 +67,5 @@
#ifdef DDB
int ksyms_sift(char *mod, char *sym, int mode);
#endif
+#endif /* _KERNEL */
+#endif /* _SYS_KSYMS_H_ */
Home |
Main Index |
Thread Index |
Old Index