summaryrefslogtreecommitdiff
path: root/trans/firmlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'trans/firmlink.c')
-rw-r--r--trans/firmlink.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/trans/firmlink.c b/trans/firmlink.c
index 48211308..087e19d0 100644
--- a/trans/firmlink.c
+++ b/trans/firmlink.c
@@ -1,8 +1,7 @@
/* A translator for `firmlinks'
- Copyright (C) 1997 Free Software Foundation, Inc.
-
- Written by Miles Bader <miles@gnu.ai.mit.edu>
+ Copyright (C) 1997,98,99,2001,02 Free Software Foundation, Inc.
+ Written by Miles Bader <miles@gnu.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -18,13 +17,16 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <argp.h>
#include <error.h>
+#include <sys/mman.h>
#include <hurd/trivfs.h>
@@ -38,8 +40,8 @@ static const struct argp_option options[] =
};
static const char args_doc[] = "TARGET";
-static const char doc[] = "A translator for firmlinks"
-"\vA firmlink is sort of half-way between a symbolic link and a hard link;"
+static const char doc[] = "A translator for firmlinks."
+"\vA firmlink is sort of half-way between a symbolic link and a hard link:"
"\n"
"\nLike a symbolic link, it is `by name', and contains no actual reference to"
" the target. However, the lookup returns a node which will redirect parent"
@@ -65,7 +67,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
static struct argp argp = { options, parse_opt, args_doc, doc };
-void
+int
main (int argc, char **argv)
{
error_t err;
@@ -81,14 +83,15 @@ main (int argc, char **argv)
/* Reply to our parent */
err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
+ mach_port_deallocate (mach_task_self (), bootstrap);
if (err)
error (2, err, "Contacting parent");
/* Launch. */
ports_manage_port_operations_multithread (fsys->pi.bucket, trivfs_demuxer,
- 2 * 60 * 1000, 0, 0, 0);
+ 2 * 60 * 1000, 0, 0);
- exit (0);
+ return 0;
}
/* Return in LINK the node that TARGET_NAME resolves to, with its parent
@@ -200,8 +203,8 @@ trivfs_goaway (struct trivfs_control *cntl, int flags)
error_t
trivfs_S_io_read (struct trivfs_protid *cred,
mach_port_t reply, mach_msg_type_name_t reply_type,
- vm_address_t *data, mach_msg_type_number_t *data_len,
- off_t offs, mach_msg_type_number_t amount)
+ char **data, mach_msg_type_number_t *data_len,
+ loff_t offs, mach_msg_type_number_t amount)
{
error_t err = 0;
@@ -211,17 +214,18 @@ trivfs_S_io_read (struct trivfs_protid *cred,
err = EBADF;
else
{
- off_t max = strlen (target);
- off_t start = offs >= 0 ? offs : (off_t)cred->po->hook;
+ size_t max = strlen (target);
+ intptr_t start = offs >= 0 ? offs : (intptr_t)cred->po->hook;
if (start < 0)
return EINVAL;
if (start + amount > max)
amount = max - start;
if (amount > *data_len)
- err = vm_allocate (mach_task_self (), data, amount, 1);
+ *data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ err = (*data == MAP_FAILED) ? errno : 0;
if (!err && amount > 0)
{
- memcpy ((char *)(*data + start), target, amount);
+ memcpy (*data, target + start, amount);
if (offs < 0)
cred->po->hook = (void *)(start + amount); /* Update PO offset. */
}
@@ -243,10 +247,10 @@ trivfs_S_io_readable (struct trivfs_protid *cred,
return EOPNOTSUPP;
else if (! (cred->po->openmodes & O_READ))
return EBADF;
- else if ((off_t)cred->po->hook < 0)
+ else if ((intptr_t)cred->po->hook < 0)
return EINVAL;
else
- *amount = strlen (target) - (off_t)cred->po->hook;
+ *amount = strlen (target) - (intptr_t)cred->po->hook;
return 0;
}
@@ -267,7 +271,7 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
error_t
trivfs_S_io_select (struct trivfs_protid *cred,
mach_port_t reply, mach_msg_type_name_t reply_type,
- int *type, int *tag)
+ int *type)
{
return EOPNOTSUPP;
}