summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-05-14 18:29:34 +0000
committerMiles Bader <miles@gnu.org>1996-05-14 18:29:34 +0000
commita23ce72042f18724e072de12adbcd5a4f2fbed45 (patch)
treea5c3f1ec320a3e0906f9ab9da7b25eb023a2dbba /pflocal
parentbe8f477739c8e2666641ecf3ff84ca22a19f8508 (diff)
(S_io_identity): New function.
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/io.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/pflocal/io.c b/pflocal/io.c
index bdf09100..5f6348d2 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -452,6 +452,53 @@ S_io_pathconf (struct sock_user *user, int name, int *value)
else
return EINVAL;
}
+
+error_t
+S_io_identity (struct sock_user *user,
+ mach_port_t *id, mach_msg_type_name_t *id_type,
+ mach_port_t *fsys_id, mach_msg_type_name_t *fsys_id_type,
+ int *fileno)
+{
+ static mach_port_t server_id = MACH_PORT_NULL;
+ error_t err = 0;
+ struct sock *sock;
+
+ if (! user)
+ return EOPNOTSUPP;
+
+ if (server_id == MACH_PORT_NULL)
+ {
+ static struct mutex server_id_lock = MUTEX_INITIALIZER;
+
+ mutex_lock (&server_id_lock);
+ if (server_id == MACH_PORT_NULL) /* Recheck with the lock held. */
+ err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
+ &server_id);
+ mutex_unlock (&server_id_lock);
+
+ if (err)
+ return err;
+ }
+
+ sock = user->sock;
+
+ mutex_lock (&sock->lock);
+ if (sock->id == MACH_PORT_NULL)
+ err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
+ &sock->id);
+ mutex_unlock (&sock->lock);
+
+ if (! err)
+ {
+ *id = sock->id;
+ *id_type = MACH_MSG_TYPE_MAKE_SEND;
+ *fsys_id = server_id;
+ *fsys_id_type = MACH_MSG_TYPE_MAKE_SEND;
+ *fileno = sock->id; /* Might as well */
+ }
+
+ return err;
+}
/* Stubs for currently unsupported rpcs. */