summaryrefslogtreecommitdiff
path: root/trans/symlink.c
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2002-03-26 19:11:46 +0000
committerNeal H. Walfield <neal@gnu.org>2002-03-26 19:11:46 +0000
commit3303f2a113384db1d7cbb785a5acc64bd260afba (patch)
tree9a3a3c31048e13ce86678d5d1d022c77eec66f83 /trans/symlink.c
parente581cc5d90e80f713c9636bcb4a47cf9bbb73c23 (diff)
2002-03-23 James A. Morrison <ja2morri@uwaterloo.ca>
* ifsock.c (main): Use ERR, not errno. * symlink.c: Include <error.h> and <errno.h>. (main): Use err, not fprintf and exit. Use error, not perror and exit. Use err, not error. Check for MACH_PORT_NULL explicitly. Check for proper usage of symlink before checking if symlink is started as a translator.
Diffstat (limited to 'trans/symlink.c')
-rw-r--r--trans/symlink.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/trans/symlink.c b/trans/symlink.c
index bacf6f03..cc937e52 100644
--- a/trans/symlink.c
+++ b/trans/symlink.c
@@ -1,5 +1,5 @@
/* Translator for S_IFLNK nodes
- Copyright (C) 1994, 2000, 2001 Free Software Foundation
+ Copyright (C) 1994, 2000, 2001, 2002 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -21,6 +21,8 @@
#include <string.h>
#include <hurd/fsys.h>
#include <fcntl.h>
+#include <errno.h>
+#include <error.h>
#include "fsys_S.h"
mach_port_t realnode;
@@ -38,14 +40,7 @@ main (int argc, char **argv)
{
mach_port_t bootstrap;
mach_port_t control;
- error_t error;
-
- task_get_bootstrap_port (mach_task_self (), &bootstrap);
- if (bootstrap == MACH_PORT_NULL)
- {
- fprintf (stderr, "%s must be started as a translator\n", argv[0]);
- exit (1);
- }
+ error_t err;
if (argc != 2)
{
@@ -53,21 +48,23 @@ main (int argc, char **argv)
exit (1);
}
+ task_get_bootstrap_port (mach_task_self (), &bootstrap);
+ if (bootstrap == MACH_PORT_NULL)
+ error (1, 0, "Must be started as a translator");
+
linktarget = argv[1];
/* Reply to our parent */
mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &control);
mach_port_insert_right (mach_task_self (), control, control,
MACH_MSG_TYPE_MAKE_SEND);
- error =
+ err =
fsys_startup (bootstrap, 0, control, MACH_MSG_TYPE_COPY_SEND, &realnode);
mach_port_deallocate (mach_task_self (), control);
mach_port_deallocate (mach_task_self (), bootstrap);
- if (error)
- {
- perror ("Starting up translator");
- exit (1);
- }
+ if (err)
+ error (1, err, "Starting up translator");
+
io_restrict_auth (realnode, &realnodenoauth, 0, 0, 0, 0);
mach_port_deallocate (mach_task_self (), realnode);
@@ -75,9 +72,9 @@ main (int argc, char **argv)
while (1)
{
/* The timeout here is 10 minutes */
- error = mach_msg_server_timeout (fsys_server, 0, control,
- MACH_RCV_TIMEOUT, 1000 * 60 * 10);
- if (error == MACH_RCV_TIMED_OUT)
+ err = mach_msg_server_timeout (fsys_server, 0, control,
+ MACH_RCV_TIMEOUT, 1000 * 60 * 10);
+ if (err == MACH_RCV_TIMED_OUT)
exit (0);
}
}