make shadow records really work
[unix-history] / usr / src / lib / libc / gen / gethostname.3
CommitLineData
931b8415 1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
88b3ccf2 2.\" All rights reserved.
6712d93b 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
88b3ccf2 5.\"
c68b668d 6.\" @(#)gethostname.3 6.8 (Berkeley) %G%
6712d93b 7.\"
931b8415
CL
8.Dd
9.Dt GETHOSTNAME 2
10.Os BSD 4.2
11.Sh NAME
12.Nm gethostname ,
13.Nm sethostname
14.Nd get/set name of current host
15.Sh SYNOPSIS
16.Fd #include <unistd.h>
17.Ft int
18.Fn gethostname "char *name" "int namelen"
19.Ft int
20.Fn sethostname "const char *name" "int namelen"
21.Sh DESCRIPTION
22.Fn Gethostname
6712d93b
KM
23returns the standard host name for the current processor, as
24previously set by
931b8415 25.Fn sethostname .
6712d93b 26The parameter
931b8415 27.Fa namelen
6712d93b 28specifies the size of the
931b8415 29.Fa name
6712d93b
KM
30array. The returned name is null-terminated unless insufficient
31space is provided.
931b8415
CL
32.Pp
33.Fn Sethostname
6712d93b 34sets the name of the host machine to be
931b8415 35.Fa name ,
6712d93b 36which has length
931b8415 37.Fa namelen .
6712d93b
KM
38This call is restricted to the super-user and
39is normally used only when the system is bootstrapped.
931b8415 40.Sh RETURN VALUES
6712d93b 41If the call succeeds a value of 0 is returned. If the call
931b8415
CL
42fails, a value of -1 is returned and an error code is
43placed in the global location
44.Va errno .
45.Sh ERRORS
6712d93b 46The following errors may be returned by these calls:
931b8415
CL
47.Bl -tag -width Er
48.It Bq Er EFAULT
49The
50.Fa name
51or
52.Fa namelen
53parameter gave an
6712d93b 54invalid address.
931b8415 55.It Bq Er EPERM
fd690c8b 56The caller tried to set the hostname and was not the super-user.
931b8415
CL
57.El
58.Sh SEE ALSO
59.Xr gethostid 2
60.Sh BUGS
61Host names are limited to
62.Dv MAXHOSTNAMELEN
63(from
64.Ao Pa sys/param.h Ac )
c68b668d 65characters, currently 256.
931b8415
CL
66.Sh HISTORY
67The
68.Nm
69function call appeared in
70.Bx 4.2 .