about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-04-26 13:37:43 +0000
committerRoland McGrath <roland@gnu.org>1999-04-26 13:37:43 +0000
commit1d721dae86d18b9d79ed36e82519708eea552d79 (patch)
treee5a831646a5cb3f0da1e25513d45928ffb5da887
parentfc549258a1d9d88eaa87fbd003761d37c50f1845 (diff)
downloadglibc-1d721dae86d18b9d79ed36e82519708eea552d79.tar.gz
glibc-1d721dae86d18b9d79ed36e82519708eea552d79.tar.xz
glibc-1d721dae86d18b9d79ed36e82519708eea552d79.zip
1999-04-26 Roland McGrath <roland@baalperazim.frob.com>
* hurd/get-host.c (_hurd_get_host_config): If ENOENT opening file, 
return success with empty value.
-rw-r--r--hurd/get-host.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/hurd/get-host.c b/hurd/get-host.c
index e57de6aa5c..7310d27196 100644
--- a/hurd/get-host.c
+++ b/hurd/get-host.c
@@ -1,5 +1,5 @@
 /* Get a host configuration item kept as the whole contents of a file.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -27,9 +27,26 @@ _hurd_get_host_config (const char *item, char *buf, size_t buflen)
   error_t err;
   char *data;
   mach_msg_type_number_t nread, more;
-  file_t config = __file_name_lookup (item, O_RDONLY, 0);
-  if (config == MACH_PORT_NULL)
-    return -1;
+  file_t config;
+
+  err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport, 0,
+				 item, O_RDONLY, 0, &config);
+  switch (err)
+    {
+    case 0:			/* Success; read file contents below.  */
+      break;
+
+    case ENOENT:		/* ? Others?  All errors? */
+      /* The file does not exist, so no value has been set.  Rather than
+	 causing gethostname et al to fail with ENOENT, give an empty value
+	 as other systems do before sethostname has been called.  */
+      if (buflen != 0)
+	*buf = '\0';
+      return 0;
+
+    default:
+      return __hurd_fail (err);
+    }
 
   data = buf;
   err = __io_read (config, &data, &nread, -1, buflen);