From 1d721dae86d18b9d79ed36e82519708eea552d79 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 26 Apr 1999 13:37:43 +0000 Subject: 1999-04-26 Roland McGrath * hurd/get-host.c (_hurd_get_host_config): If ENOENT opening file, return success with empty value. --- hurd/get-host.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'hurd/get-host.c') 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); -- cgit v1.2.3