Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 1995 11:16:03 -0500
From:      "Garrett A. Wollman" <wollman@lcs.mit.edu>
To:        Poul-Henning Kamp <phk@critter.tfs.com>
Cc:        current@freebsd.org
Subject:   Re: cvs commit: src/sys/kern kern_sysctl.c 
Message-ID:  <9511141616.AA23508@halloran-eldar.lcs.mit.edu>
In-Reply-To: <570.816343308@critter.tfs.com>
References:  <Pine.BSF.3.91.951114041815.243B-100000@jhome.DIALix.COM> <570.816343308@critter.tfs.com>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Tue, 14 Nov 1995 11:01:48 +0100, Poul-Henning Kamp <phk@critter.tfs.com> said:

>> 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 ?

Then you return an error.

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

I would prefer for it to obey the standard.

Digital UNIX 3.2:
  The gethostname() function retrieves the standard host name of the local
  host.  If sufficient space is provided, the returned address parameter is
  null-terminated.

  System hostnames are limited to MAXHOSTNAMELEN as defined in the
  /usr/include/sys/param.h file.

Ultrix 4.2:
     The gethostname system call returns the standard host name for the
     current processor, as previously set by sethostname.  The namelen param-
     eter specifies the size of the name array.  The returned name is null-
     terminated unless insufficient space is provided.

SunOS 4.1.1:
     gethostname() returns the standard host name for the current
     processor,  as previously set by sethostname().  The parame-
     ter namelen specifies the size of the array  pointed  to  by
     name.   The returned name is null-terminated unless insuffi-
     cient space is provided.

FreeBSD 2.2:
     Gethostname() returns the standard host name for the current processor,
     as previously set by sethostname().  The parameter namelen specifies the
     size of the name array.  The returned name is null-terminated unless in-
     sufficient space is provided.


> 	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 ?

No.

> 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 ?

Yes.  It defeats the whole purpose of having `new' and `old'
parameters in one call, which presently allow you to atomically
get-and-set the value of a variable.

-GAWollman

--
Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
wollman@lcs.mit.edu  | Shashish is the bonding of hearts in spite of distance.
Opinions not those of| It is a bond more powerful than absence.  We like people
MIT, LCS, ANA, or NSA| who like Shashish.  - Claude McKenzie + Florent Vollant



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