If NIS is in use, provide the NIS domain name. Note that this is not the same as the domain name which provides the domain portion of a fully qualified domain name (for example, in DNS). If NIS is not in use, provide the string "(none)".
If the string which is provided is strictly less than namelen characters in length, getdomainname places it in the array pointed to by name followed by a terminating null character. If not, getdomainname may either truncate it to namelen characters and place it in name (without a terminating null character), or may fail with EINVAL.
getdomainname returns 0 if successful; -1 if not (in which case errno is set to indicate the error).