Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 1995 11:01:48 +0100
From:      Poul-Henning Kamp <phk@critter.tfs.com>
To:        Peter Wemm <peter@jhome.dialix.com>
Cc:        Poul-Henning Kamp <phk@freefall.freebsd.org>, CVS-commiters@freefall.freebsd.org, cvs-sys@freefall.freebsd.org
Subject:   Re: cvs commit: src/sys/kern kern_sysctl.c 
Message-ID:  <570.816343308@critter.tfs.com>
In-Reply-To: Your message of "Tue, 14 Nov 1995 04:48:24 %2B0800." <Pine.BSF.3.91.951114041815.243B-100000@jhome.DIALix.COM> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Yep. You missed this one:
Well, maybe...

> + #if 0
>   	if (arg2)
>   		error = SYSCTL_OUT(req, arg1, arg2);
>   	else
> + #endif

> This is necessary for sysctl_handle_string (a string by definition is 
> null terminated.  use the sysctl_handle_opaque for a fixed block of 
> memory.  the hostname buffer is a string, not a 256 byte chunk)
> 
> If you dont do the above change, gethostname(buf, 64) will fail with 
> ENOMEM, and cause gated, amd and mountd to fail.

Well, what if the hostname actually WAS 255 bytes long then ?

I would rather it fail all the time and we can get the code fixed,
than having a mismatch between expectations like this...

> I've been using the following hack regression check program while 
> fiddling.  It's probably not entirely right, but it demonstrates the 
> results of the above breakage.
got it.

> BTW: it seems like the old sysctl() does not behave as documented.. It 
> doesn't seem like it will return an estimate of the KERN_HOSTNAME size on 
> a very old 2.2-current (27 september).  The manpage explicitly says 
> "returns 0 on success and -1 on failure".  Old -current and -stable may 
> need the first assert() commented out.

The interface is badly designed, how about this one:

	get some variable
		old buffer too small,
		new buffer correct.

it should return ENOMEM because it cannot copyout, but should the
new value be installed ?

I'm seriously considering allowing only a "get" or a "set" per syscall,
not both.

But then again, that is too draconian isn't it ?

--
Poul-Henning Kamp           | phk@FreeBSD.ORG       FreeBSD Core-team.
http://www.freebsd.org/~phk | phk@login.dknet.dk    Private mailbox.
whois: [PHK]                | phk@ref.tfs.com       TRW Financial Systems, Inc.
Future will arrive by its own means, progress not so.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?570.816343308>