summaryrefslogtreecommitdiff
path: root/nfsd
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2002-03-26 19:09:34 +0000
committerNeal H. Walfield <neal@gnu.org>2002-03-26 19:09:34 +0000
commit4ba5bfd888ec829ea12a2334fd29c3fe7046fba2 (patch)
treea4848ef3bb21239e7b9cb6086912b946474c4be2 /nfsd
parent113f86089440d1d87fac1962432f40edcc57248e (diff)
2002-03-23 James A. Morrison <ja2morri@uwaterloo.ca>
* fsys.c (init_filesystems): Use error, not fprintf. Use MACH_PORT_NULL explicitly. (write_filesystems): Use error, not fprintf. Use ERR, not errno. * main.c (main): Use error, not perror and exit.
Diffstat (limited to 'nfsd')
-rw-r--r--nfsd/fsys.c33
-rw-r--r--nfsd/main.c11
2 files changed, 17 insertions, 27 deletions
diff --git a/nfsd/fsys.c b/nfsd/fsys.c
index 97137455..8a2cd03b 100644
--- a/nfsd/fsys.c
+++ b/nfsd/fsys.c
@@ -1,5 +1,5 @@
/* Filesystem management for NFS server
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -65,8 +65,7 @@ init_filesystems (void)
index_file = fopen (index_file_name, "r");
if (!index_file)
{
- fprintf (stderr, "%s: Cannot open `%s': %s\n",
- program_invocation_name, index_file_name, strerror (errno));
+ error (0, errno, "Cannot open `%s'", index_file_name);
return;
}
@@ -81,17 +80,15 @@ init_filesystems (void)
if (nitems != 2)
{
- fprintf (stderr, "%s:%s:%d Bad syntax\n",
- program_invocation_name, index_file_name, line);
+ error (0, 0, "%s:%d Bad syntax", index_file_name, line);
continue;
}
root = file_name_lookup (name, 0, 0);
- if (!root)
+ if (root == MACH_PORT_NULL)
{
- fprintf (stderr, "%s:%s:%d Filesystem `%s': %s\n",
- program_invocation_name, index_file_name, line,
- name, strerror (errno));
+ error (0, errno, "%s:%d Filesystem `%s'",
+ index_file_name, line, name);
free (name);
continue;
}
@@ -123,6 +120,7 @@ write_filesystems (void)
{
file_t newindex;
FILE *f;
+ error_t err;
int i;
if (!index_file_name)
@@ -133,19 +131,17 @@ write_filesystems (void)
index_file_dir = file_name_split (index_file_name, &index_file_compname);
if (index_file_dir == MACH_PORT_NULL)
{
- fprintf (stderr, "%s: `%s': %s\n",
- program_invocation_name, index_file_name, strerror (errno));
+ error (0, errno, "`%s'", index_file_name);
index_file_name = 0;
return;
}
}
/* Create an anonymous file in the same directory */
- errno = dir_mkfile (index_file_dir, O_WRONLY, 0666, &newindex);
- if (errno)
+ err = dir_mkfile (index_file_dir, O_WRONLY, 0666, &newindex);
+ if (err)
{
- fprintf (stderr, "%s: `%s': %s\n",
- program_invocation_name, index_file_name, strerror (errno));
+ error (0, err, "`%s'", index_file_name);
index_file_name = 0;
mach_port_deallocate (mach_task_self (), index_file_dir);
index_file_dir = MACH_PORT_NULL;
@@ -159,10 +155,9 @@ write_filesystems (void)
fprintf (f, "%d %s\n", i, fsystable[i].name);
/* Link it in */
- errno = dir_link (index_file_dir, newindex, index_file_compname, 0);
- if (errno)
- fprintf (stderr, "%s: `%s': %s\n",
- program_invocation_name, index_file_name, strerror (errno));
+ err = dir_link (index_file_dir, newindex, index_file_compname, 0);
+ if (err)
+ error (0, err, "`%s'", index_file_name);
fflush (f);
file_sync (newindex, 1, 0);
fclose (f);
diff --git a/nfsd/main.c b/nfsd/main.c
index d4d040c6..2e5df1c2 100644
--- a/nfsd/main.c
+++ b/nfsd/main.c
@@ -63,17 +63,12 @@ main (int argc, char **argv)
fail = bind (main_udp_socket, (struct sockaddr *)&main_address,
sizeof (struct sockaddr_in));
if (fail)
- {
- perror ("Binding NFS socket");
- exit (1);
- }
+ error (1, errno, "Binding NFS socket");
+
fail = bind (pmap_udp_socket, (struct sockaddr *)&pmap_address,
sizeof (struct sockaddr_in));
if (fail)
- {
- perror ("Binding PMAP socket");
- exit (1);
- }
+ error (1, errno, "Binding PMAP socket");
init_filesystems ();