From d2e60e82f8777401d288b9fa94ef86e791aa6f97 Mon Sep 17 00:00:00 2001 From: manu Date: Sat, 23 Feb 2002 22:35:15 +0000 Subject: [PATCH] Fixed various sysconf() commands --- sys/compat/irix/irix_syssgi.c | 43 +++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/sys/compat/irix/irix_syssgi.c b/sys/compat/irix/irix_syssgi.c index 784b7e9e4a77..aa11efc1defc 100644 --- a/sys/compat/irix/irix_syssgi.c +++ b/sys/compat/irix/irix_syssgi.c @@ -1,4 +1,4 @@ -/* $NetBSD: irix_syssgi.c,v 1.16 2002/02/17 20:44:17 manu Exp $ */ +/* $NetBSD: irix_syssgi.c,v 1.17 2002/02/23 22:35:15 manu Exp $ */ /*- * Copyright (c) 2001-2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.16 2002/02/17 20:44:17 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.17 2002/02/23 22:35:15 manu Exp $"); #include "opt_ddb.h" @@ -58,6 +58,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.16 2002/02/17 20:44:17 manu Exp $" #include #include #include +#include #include #include #include @@ -66,6 +67,8 @@ __KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.16 2002/02/17 20:44:17 manu Exp $" #include +#include + #include #include @@ -371,6 +374,8 @@ irix_syssgi_sysconf(name, p, retval) int error = 0; int mib[2], value; int len = sizeof(value); + struct sys___sysctl_args cup; + caddr_t sg = stackgap_init(p->p_emul); switch (name) { case IRIX_SC_ARG_MAX: @@ -378,8 +383,8 @@ irix_syssgi_sysconf(name, p, retval) mib[1] = KERN_ARGMAX; break; case IRIX_SC_CHILD_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_MAXPROC; + *retval = (register_t)p->p_rlimit[RLIMIT_NPROC].rlim_cur; + return 0; break; case IRIX_SC_CLK_TCK: *retval = hz; @@ -390,16 +395,16 @@ irix_syssgi_sysconf(name, p, retval) mib[1] = KERN_NGROUPS; break; case IRIX_SC_OPEN_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_MAXFILES; + *retval = (register_t)p->p_rlimit[RLIMIT_NOFILE].rlim_cur; + return 0; break; case IRIX_SC_JOB_CONTROL: - *retval = 1; - return 0; + mib[0] = CTL_KERN; + mib[1] = KERN_JOB_CONTROL; break; case IRIX_SC_SAVED_IDS: - *retval = 1; - return 0; + mib[0] = CTL_KERN; + mib[1] = KERN_SAVED_IDS; break; /* Trusted IRIX capabilities are unsupported */ case IRIX_SC_ACL: /* ACcess Lists */ @@ -424,8 +429,18 @@ irix_syssgi_sysconf(name, p, retval) break; } - error = kern_sysctl(mib, 2, &value, &len, NULL, 0, p); - if (error == 0) - *retval = (register_t)value; - return error; + SCARG(&cup, name) = stackgap_alloc(&sg, sizeof(mib)); + if ((error = copyout(&mib, SCARG(&cup, name), sizeof(mib))) != 0) + return error; + SCARG(&cup, namelen) = sizeof(mib); + SCARG(&cup, old) = stackgap_alloc(&sg, sizeof(value)); + if ((copyout(&value, SCARG(&cup, old), sizeof(value))) != 0) + return error; + SCARG(&cup, oldlenp) = stackgap_alloc(&sg, sizeof(len)); + if ((copyout(&len, SCARG(&cup, oldlenp), sizeof(len))) != 0) + return error; + SCARG(&cup, new) = NULL; + SCARG(&cup, newlen) = 0; + + return sys___sysctl(p, &cup, retval); }