[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/11] ipc: implement mach_port_set_protected_payload
From: |
Justus Winter |
Subject: |
[PATCH 03/11] ipc: implement mach_port_set_protected_payload |
Date: |
Mon, 17 Feb 2014 18:20:53 +0100 |
* include/mach/mach_port.defs: Add mach_port_set_protected_payload.
* ipc/mach_port.c: Implement mach_port_set_protected_payload.
---
include/mach/mach_port.defs | 9 +++++++++
ipc/mach_port.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs
index 769d892..96a5987 100644
--- a/include/mach/mach_port.defs
+++ b/include/mach/mach_port.defs
@@ -349,3 +349,12 @@ skip; /* mach_port_create_act */
#endif /* MIGRATING_THREADS */
+/*
+ * Only valid for receive rights.
+ * Set the protected payload for this right to the given value.
+ */
+
+routine mach_port_set_protected_payload(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ payload : natural_t);
diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index 13572a1..14c3653 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -1564,3 +1564,40 @@ mach_port_set_syscall_right(task, name)
}
#endif
#endif /* MIGRATING_THREADS */
+
+/*
+ * Routine: mach_port_set_protected_payload [kernel call]
+ * Purpose:
+ * Changes a receive right's protected payload.
+ * Conditions:
+ * Nothing locked.
+ * Returns:
+ * KERN_SUCCESS Set protected payload.
+ * KERN_INVALID_TASK The space is null.
+ * KERN_INVALID_TASK The space is dead.
+ * KERN_INVALID_NAME The name doesn't denote a right.
+ * KERN_INVALID_RIGHT Name doesn't denote receive rights.
+ */
+
+kern_return_t
+mach_port_set_protected_payload(
+ ipc_space_t space,
+ mach_port_t name,
+ unsigned long payload)
+{
+ ipc_port_t port;
+ kern_return_t kr;
+
+ if (space == IS_NULL)
+ return KERN_INVALID_TASK;
+
+ kr = ipc_port_translate_receive(space, name, &port);
+ if (kr != KERN_SUCCESS)
+ return kr;
+ /* port is locked and active */
+
+ ipc_port_set_protected_payload(port, payload);
+
+ ip_unlock(port);
+ return KERN_SUCCESS;
+}
--
1.8.5.2
- protected payloads for GNU Mach, Justus Winter, 2014/02/17
- [PATCH 01/11] include: skip routines related to migrating threads, Justus Winter, 2014/02/17
- [PATCH 04/11] doc: document mach_port_set_protected_payload, Justus Winter, 2014/02/17
- [PATCH 02/11] ipc: add protected payload, Justus Winter, 2014/02/17
- [PATCH 03/11] ipc: implement mach_port_set_protected_payload,
Justus Winter <=
- [PATCH 07/11] include: define MACH_MSG_TYPE_PROTECTED_PAYLOAD, Justus Winter, 2014/02/17
- [PATCH 08/11] doc: document MACH_MSG_TYPE_PROTECTED_PAYLOAD, Justus Winter, 2014/02/17
- [PATCH 06/11] doc: document msgh_protected_payload, Justus Winter, 2014/02/17
- [PATCH 10/11] ipc: clear the payload when moving a receive port, Justus Winter, 2014/02/17
- [PATCH 05/11] include: add msgh_protected_payload to mach_msg_header_t, Justus Winter, 2014/02/17
- [PATCH 11/11] doc: document message semantics with protected payloads, Justus Winter, 2014/02/17
- [PATCH 09/11] ipc: provide the protected payload in ipc_kmsg_copyout_header, Justus Winter, 2014/02/17
- Re: protected payloads for GNU Mach, Samuel Thibault, 2014/02/19