Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/gen/gethostname.3,v rcsdiff: /ftp/cvs/cvsroot/src/lib/libc/gen/gethostname.3,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.5 retrieving revision 1.18 diff -u -p -r1.5 -r1.18 --- src/lib/libc/gen/gethostname.3 1998/02/05 18:46:43 1.5 +++ src/lib/libc/gen/gethostname.3 2015/09/03 04:05:38 1.18 @@ -1,4 +1,4 @@ -.\" $NetBSD: gethostname.3,v 1.5 1998/02/05 18:46:43 perry Exp $ +.\" $NetBSD: gethostname.3,v 1.18 2015/09/03 04:05:38 jnemeth Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -11,11 +11,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" @@ -33,9 +29,9 @@ .\" .\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 .\" -.Dd June 4, 1993 +.Dd September 2, 2015 .Dt GETHOSTNAME 3 -.Os BSD 4.2 +.Os .Sh NAME .Nm gethostname , .Nm sethostname @@ -43,24 +39,25 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.Fd #include +.In unistd.h .Ft int -.Fn gethostname "char *name" "int namelen" +.Fn gethostname "char *name" "size_t namelen" .Ft int -.Fn sethostname "const char *name" "int namelen" +.Fn sethostname "const char *name" "size_t namelen" .Sh DESCRIPTION -.Fn Gethostname -returns the standard host name for the current processor, as +.Fn gethostname +returns the standard host name for the current machine, as previously set by .Fn sethostname . The parameter .Fa namelen -specifies the size of the +specifies the size of the .Fa name -array. The returned name is null-terminated unless insufficient +array. +The returned name is null-terminated unless insufficient space is provided. .Pp -.Fn Sethostname +.Fn sethostname sets the name of the host machine to be .Fa name , which has length @@ -68,35 +65,37 @@ which has length This call is restricted to the super-user and is normally used only when the system is bootstrapped. .Sh RETURN VALUES -If the call succeeds a value of 0 is returned. If the call -fails, a value of -1 is returned and an error code is +If the call succeeds a value of 0 is returned. +If the call fails, a value of \-1 is returned and an error code is placed in the global location .Va errno . .Sh ERRORS -The following errors may be returned by these calls: -.Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa name +If the +.Fn gethostname or -.Fa namelen -parameter gave an -invalid address. -.It Bq Er EPERM -The caller tried to set the hostname and was not the super-user. -.El +.Fn sethostname +functions fail, +they will set +.Va errno +for any of the errors specified for the routine +.Xr sysctl 3 . .Sh SEE ALSO -.Xr sysctl 3 , .Xr gethostid 3 , +.Xr sysctl 3 , .Xr sysctl 8 -.Sh BUGS -Host names are limited to -.Dv MAXHOSTNAMELEN -(from -.Ao Pa sys/param.h Ac ) -characters, currently 256. +.Sh STANDARDS +The +.Fn gethostname +function conforms to +.St -xpg4.2 . .Sh HISTORY The .Nm function call appeared in .Bx 4.2 . +.Sh BUGS +Host names are limited to +.Dv MAXHOSTNAMELEN +(from +.Ao Pa sys/param.h Ac ) +characters including null-termination, currently 256.