If the Network Information System (NIS) is in use,
getdomainname
shall
copy the NIS domain name to the supplied buffer identified by
name,
with maximum length namelen.
If the NIS domain name is not currently set,
getdomainname
shall
copy the string "(none)" to the name.
If namelen is less
the length of the string
to be copied, getdomainname
may either truncate the string to namelen
characters and place it in name
(without a terminating null character),
or may fail with EINVAL.
Note that the NIS domain name is not the same as the domain portion of a fully qualified domain name (for example, in DNS).
On success,
getdomainname
shall return
0. Otherwise, it shall return
-1 and set errno
to indicate the error).
name was a null pointer.
The buffer identified by name and namelen is of insufficient size to store the NIS domain name string, and the implementation considers this an error.