[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/23] libports: add ports_lookup_payload
From: |
Justus Winter |
Subject: |
[PATCH 03/23] libports: add ports_lookup_payload |
Date: |
Fri, 29 Nov 2013 01:03:31 +0100 |
* libports/lookup-payload.c: New file.
* libports/ports.h (ports_lookup_payload): Add declaration.
* libports/Makefile (SRCS): Add lookup-payload.c.
---
libports/Makefile | 2 +-
libports/lookup-payload.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
libports/ports.h | 6 ++++++
3 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 libports/lookup-payload.c
diff --git a/libports/Makefile b/libports/Makefile
index 767ee73..934b151 100644
--- a/libports/Makefile
+++ b/libports/Makefile
@@ -36,7 +36,7 @@ SRCS = create-bucket.c create-class.c \
interrupt-operation.c interrupt-on-notify.c interrupt-notified-rpcs.c \
dead-name.c create-port.c import-port.c default-uninhibitable-rpcs.c \
claim-right.c transfer-right.c create-port-noinstall.c create-internal.c \
- interrupted.c
+ interrupted.c lookup-payload.c
installhdrs = ports.h
diff --git a/libports/lookup-payload.c b/libports/lookup-payload.c
new file mode 100644
index 0000000..92f54b6
--- /dev/null
+++ b/libports/lookup-payload.c
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ Written by Justus Winter <4winter@informatik.uni-hamburg.de>
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "ports.h"
+
+void *
+ports_lookup_payload (struct port_bucket *bucket,
+ unsigned long payload,
+ struct port_class *class)
+{
+ struct port_info *pi = (struct port_info *) payload;
+
+ if (pi && bucket && pi->bucket != bucket)
+ pi = NULL;
+
+ if (pi && class && pi->class != class)
+ pi = NULL;
+
+ if (pi)
+ {
+ pthread_mutex_lock (&_ports_lock);
+ pi->refcnt++;
+ pthread_mutex_unlock (&_ports_lock);
+ }
+
+ return pi;
+}
diff --git a/libports/ports.h b/libports/ports.h
index 0791841..2f63142 100644
--- a/libports/ports.h
+++ b/libports/ports.h
@@ -232,6 +232,12 @@ mach_port_t ports_get_send_right (void *port);
void *ports_lookup_port (struct port_bucket *bucket,
mach_port_t port, struct port_class *class);
+/* Like ports_lookup_port, but uses PAYLOAD to look up the object. If
+ this function is used, PAYLOAD must be a pointer to the port
+ structure. */
+void *ports_lookup_payload (struct port_bucket *bucket,
+ unsigned long payload, struct port_class *class);
+
/* Allocate another reference to PORT. */
void ports_port_ref (void *port);
--
1.7.10.4
- [PATCH 8/8] XXX fix the size of ipc_port structs, (continued)
- [PATCH 1/5] Advise flex not to generate the input function, Justus Winter, 2013/11/28
- [PATCH] Drop the auto keyword, Justus Winter, 2013/11/28
- [PATCH 4/5] Clean up generated sources, Justus Winter, 2013/11/28
- [PATCH 2/5] Avoid a compiler warning in WriteDefines, Justus Winter, 2013/11/28
- [PATCH 3/5] Add inTransPayload, Justus Winter, 2013/11/28
- [PATCH 5/5] Use inTransPayload, Justus Winter, 2013/11/28
- [PATCH 01/23] trans: fix the receiver lookup in password, Justus Winter, 2013/11/28
- [PATCH 02/23] proc: fix the receiver lookup in S_proc_exception_raise, Justus Winter, 2013/11/28
- [PATCH 03/23] libports: add ports_lookup_payload,
Justus Winter <=
- [PATCH 04/23] proc: add a payload-aware intrans function, Justus Winter, 2013/11/28
- [PATCH 05/23] console: add a payload-aware intrans function, Justus Winter, 2013/11/28
- [PATCH 07/23] libnetfs: add a payload-aware intrans function, Justus Winter, 2013/11/28
- [PATCH 06/23] libdiskfs: add a payload-aware intrans function, Justus Winter, 2013/11/28
- [PATCH 10/23] exec: add intranspayload, Justus Winter, 2013/11/28
- [PATCH 08/23] libtrivfs: add a payload-aware intrans functions, Justus Winter, 2013/11/28
- [PATCH 09/23] libcons: add a payload-aware intrans function, Justus Winter, 2013/11/28
- [PATCH 11/23] pfinet: add a payload-aware intrans functions, Justus Winter, 2013/11/28
- [PATCH 13/23] auth: add a payload-aware intrans function, Justus Winter, 2013/11/28
- [PATCH 12/23] pflocal: add a payload-aware intrans functions, Justus Winter, 2013/11/28