diff options
author | Miles Bader <miles@gnu.org> | 1995-08-12 01:03:02 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1995-08-12 01:03:02 +0000 |
commit | 49a7096110050c42ba8dc6aeff1d41c171be660e (patch) | |
tree | 84a4a1b390817fd94fd192ecad444e47c081af61 /libtrivfs | |
parent | b01c8972e93e0afe3a742bdac2021c258beb709b (diff) |
(trivfs_S_io_duplicate): Allow trivfs_protid_create_hook to return an error
code.
(trivfs_S_io_duplicate): Guts moved into trivfs_protid_dup.
Diffstat (limited to 'libtrivfs')
-rw-r--r-- | libtrivfs/io-duplicate.c | 37 |
1 files changed, 10 insertions, 27 deletions
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; } |