From owner-freebsd-hackers Wed Nov 15 00:09:23 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id AAA04671 for hackers-outgoing; Wed, 15 Nov 1995 00:09:23 -0800 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id AAA04655 for ; Wed, 15 Nov 1995 00:09:16 -0800 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id TAA25412; Wed, 15 Nov 1995 19:06:56 +1100 Date: Wed, 15 Nov 1995 19:06:56 +1100 From: Bruce Evans Message-Id: <199511150806.TAA25412@godzilla.zeta.org.au> To: davidg@Root.COM, peter@haywire.dialix.com Subject: Re: Can't NFS mount with latest -current Cc: freebsd-hackers@freebsd.org Sender: owner-hackers@freebsd.org Precedence: bulk >>Anyway, Poul-Henning has created two sysctl types.. one is a >>null-terminated "C-style" string, and the other is an "opaque" chunk >>of byte counted memory. IMHO, the string version should always return >>the correct amount of characters that the string actually uses. If >>the whole block is to be returned, that's what the opaque type is for. > Yes, the "size" argument should be used to limit the copy, not prevent it >from happening. We should be using copyoutstr() for this. We shouldn't be using copyoutstr() for this. It returns ENAMETOOLONG, which would need to be converted to ENOMEM. Together with managing the indirect count, this would take about the same amount of code as calling strlen() and calculating the amount that fits. I think sysctl_handle_string() essentially does this. Does it have bugs? Why does it return E2BIG? This errno isn't documented for sysctl(). The current (i386) implementation of copyoutstr() is poor. strlen() followed by copyout() would be much faster. strlen() followed by memcpy() is close to the fastest method of implementing strcpy() on the i386. copyoutstr() is the most complicated routine in support.s, but is currently unused. Bruce