From 49a7096110050c42ba8dc6aeff1d41c171be660e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 12 Aug 1995 01:03:02 +0000 Subject: (trivfs_S_io_duplicate): Allow trivfs_protid_create_hook to return an error code. (trivfs_S_io_duplicate): Guts moved into trivfs_protid_dup. --- libtrivfs/io-duplicate.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'libtrivfs') diff --git a/libtrivfs/io-duplicate.c b/libtrivfs/io-duplicate.c index 74525447..4b20bb99 100644 --- a/libtrivfs/io-duplicate.c +++ b/libtrivfs/io-duplicate.c @@ -30,37 +30,20 @@ trivfs_S_io_duplicate (struct trivfs_protid *cred, mach_port_t *newport, mach_msg_type_name_t *newporttype) { + error_t err; struct trivfs_protid *newcred; if (!cred) return EOPNOTSUPP; - newcred = ports_allocate_port (cred->po->cntl->protid_bucket, - sizeof (struct trivfs_protid), - cred->po->cntl->protid_class); - newcred->realnode = cred->realnode; - newcred->isroot = cred->isroot; - mutex_lock (&cred->po->cntl->lock); - newcred->po = cred->po; - newcred->po->refcnt++; - mutex_unlock (&cred->po->cntl->lock); - newcred->uids = malloc (cred->nuids * sizeof (uid_t)); - newcred->gids = malloc (cred->ngids * sizeof (gid_t)); - bcopy (cred->uids, newcred->uids, cred->nuids * sizeof (uid_t)); - bcopy (cred->gids, newcred->gids, cred->ngids * sizeof (uid_t)); - newcred->nuids = cred->nuids; - newcred->ngids = cred->ngids; - mach_port_mod_refs (mach_task_self (), newcred->realnode, - MACH_PORT_RIGHT_SEND, 1); - - newcred->hook = cred->hook; - - if (trivfs_protid_create_hook) - (*trivfs_protid_create_hook) (newcred); - - *newport = ports_get_right (newcred); - *newporttype = MACH_MSG_TYPE_MAKE_SEND; - ports_port_deref (newcred); - return 0; + err = trivfs_protid_dup (cred, &newcred); + if (!err) + { + *newport = ports_get_right (newcred); + *newporttype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (newcred); + } + + return err; } -- cgit v1.2.3