Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/ibcs2 Allow dynamic twiddling of debug messages.
details: https://anonhg.NetBSD.org/src/rev/d4c5c488061a
branches: trunk
changeset: 487968:d4c5c488061a
user: matt <matt%NetBSD.org@localhost>
date: Fri Jun 16 01:56:36 2000 +0000
description:
Allow dynamic twiddling of debug messages.
Fix printf problem when printing debug messages.
fix coff shlib loading. Add a few sanity checks.
diffstat:
sys/compat/ibcs2/ibcs2_exec.c | 38 +++++++++++++++++++++++++++++---------
sys/compat/ibcs2/ibcs2_ioctl.c | 4 ++--
sys/compat/ibcs2/ibcs2_util.h | 9 ++++-----
3 files changed, 35 insertions(+), 16 deletions(-)
diffs (143 lines):
diff -r aa0693534393 -r d4c5c488061a sys/compat/ibcs2/ibcs2_exec.c
--- a/sys/compat/ibcs2/ibcs2_exec.c Fri Jun 16 00:57:04 2000 +0000
+++ b/sys/compat/ibcs2/ibcs2_exec.c Fri Jun 16 01:56:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ibcs2_exec.c,v 1.27 2000/06/04 16:24:02 mycroft Exp $ */
+/* $NetBSD: ibcs2_exec.c,v 1.28 2000/06/16 01:56:36 matt Exp $ */
/*
* Copyright (c) 1994, 1995, 1998 Scott Bartram
@@ -49,9 +49,6 @@
#include <sys/exec_coff.h>
#include <sys/exec_elf.h>
#include <sys/resourcevar.h>
-#ifdef IBCS2_DEBUG
-#include <sys/syslog.h>
-#endif
#include <sys/mman.h>
#include <sys/syscallargs.h>
@@ -109,6 +106,12 @@
const char ibcs2_emul_path[] = "/emul/ibcs2";
+#ifdef IBCS2_DEBUG
+int ibcs2_debug = 1;
+#else
+int ibcs2_debug = 0;
+#endif
+
struct emul emul_ibcs2_coff = {
"ibcs2",
native_to_ibcs2_errno,
@@ -565,9 +568,18 @@
if (!error) {
size_t resid;
struct coff_slhdr *slhdr;
- char buf[128], *bufp; /* FIXME */
+ char *buf, *bufp;
int len = sh.s_size, path_index, entry_len;
-
+
+#if 0
+ if (len > COFF_SHLIBSEC_MAXSIZE) {
+ return ENOEXEC;
+ }
+#endif
+ buf = (char *) malloc(len, M_TEMP, M_WAITOK);
+ if (buf == NULL)
+ return ENOEXEC;
+
/* DPRINTF(("COFF shlib size %d offset %d\n",
sh.s_size, sh.s_scnptr)); */
@@ -577,6 +589,7 @@
&resid, p);
if (error) {
DPRINTF(("shlib section read error %d\n", error));
+ free(buf, M_TEMP);
return ENOEXEC;
}
bufp = buf;
@@ -585,15 +598,23 @@
path_index = slhdr->path_index * sizeof(long);
entry_len = slhdr->entry_len * sizeof(long);
+ if (entry_len > len) {
+ free(buf, M_TEMP);
+ return ENOEXEC;
+ }
+
/* DPRINTF(("path_index: %d entry_len: %d name: %s\n",
path_index, entry_len, slhdr->sl_name)); */
error = coff_load_shlib(p, slhdr->sl_name, epp);
- if (error)
+ if (error) {
+ free(buf, M_TEMP);
return ENOEXEC;
+ }
bufp += entry_len;
len -= entry_len;
}
+ free(buf, M_TEMP);
}
/* set up entry point */
@@ -621,14 +642,13 @@
struct nameidata nd;
struct coff_filehdr fh, *fhp = &fh;
struct coff_scnhdr sh, *shp = &sh;
- caddr_t sg = stackgap_init(p->p_emul);
/*
* 1. open shlib file
* 2. read filehdr
* 3. map text, data, and bss out of it using VM_*
*/
- IBCS2_CHECK_ALT_EXIST(p, &sg, path);
+ IBCS2_CHECK_ALT_EXIST(p, NULL, path); /* path is on kernel stack */
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p);
/* first get the vnode */
if ((error = namei(&nd)) != 0) {
diff -r aa0693534393 -r d4c5c488061a sys/compat/ibcs2/ibcs2_ioctl.c
--- a/sys/compat/ibcs2/ibcs2_ioctl.c Fri Jun 16 00:57:04 2000 +0000
+++ b/sys/compat/ibcs2/ibcs2_ioctl.c Fri Jun 16 01:56:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ibcs2_ioctl.c,v 1.18 2000/03/30 11:27:16 augustss Exp $ */
+/* $NetBSD: ibcs2_ioctl.c,v 1.19 2000/06/16 01:56:37 matt Exp $ */
/*
* Copyright (c) 1994, 1995 Scott Bartram
@@ -552,7 +552,7 @@
return sys_ioctl(p, uap, retval);
default:
- DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ",
+ DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%x ",
p->p_pid, SCARG(uap, cmd)));
return ENOSYS;
}
diff -r aa0693534393 -r d4c5c488061a sys/compat/ibcs2/ibcs2_util.h
--- a/sys/compat/ibcs2/ibcs2_util.h Fri Jun 16 00:57:04 2000 +0000
+++ b/sys/compat/ibcs2/ibcs2_util.h Fri Jun 16 01:56:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ibcs2_util.h,v 1.5 1998/09/05 14:50:26 christos Exp $ */
+/* $NetBSD: ibcs2_util.h,v 1.6 2000/06/16 01:56:37 matt Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -70,10 +70,9 @@
#include <compat/common/compat_util.h>
-#ifdef DEBUG_IBCS2
-#define DPRINTF(a) printf a;
-#else
-#define DPRINTF(a)
+#ifdef _KERNEL
+extern int ibcs2_debug;
+#define DPRINTF(a) do { if (ibcs2_debug) printf a; } while (0)
#endif
extern const char ibcs2_emul_path[];
Home |
Main Index |
Thread Index |
Old Index