error_t err; char *buf = name; mach_msg_type_number_t buflen = len; if (err = __USEPORT (PROC, __proc_gethostname (port, &buf, &buflen))) return __hurd_fail (err); if (buf != name) { memcpy (name, buf, len < buflen ? len : buflen); __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen); } if (buflen > len) return __hurd_fail (ENAMETOOLONG); return 0;
ssize_t n = _hurd_get_host_config ("/etc/hostname", name, len); return n < 0 ? -1 : 0;
DEFUN(__gethostname, (name, len),      char *name AND size_t len){  error_t err;  char *buf = name;  mach_msg_type_number_t buflen = len;  if (err = __USEPORT (PROC, __proc_gethostname (port, &buf, &buflen)))    return __hurd_fail (err);  if (buf != name)    {      memcpy (name, buf, len < buflen ? len : buflen);      __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);    }  if (buflen > len)    return __hurd_fail (ENAMETOOLONG);  return 0;}