#include <kern/kern_types.h>
+#include <kern/thread_group.h>
#include <mach/mach_types.h>
#include <mach/boolean.h>
uint64_t cid;
coalition_t coal;
int type = COALITION_CREATE_FLAGS_GET_TYPE(flags);
+ int role = COALITION_CREATE_FLAGS_GET_ROLE(flags);
boolean_t privileged = !!(flags & COALITION_CREATE_FLAGS_PRIVILEGED);
if ((flags & (~COALITION_CREATE_FLAGS_MASK)) != 0)
if (type < 0 || type > COALITION_TYPE_MAX)
return EINVAL;
- kr = coalition_create_internal(type, privileged, &coal);
+ kr = coalition_create_internal(type, role, privileged, &coal);
if (kr != KERN_SUCCESS) {
/* for now, the only kr is KERN_RESOURCE_SHORTAGE */
error = ENOMEM;
* Request the kernel to deallocate the coalition identified by ID, which
* must be both terminated and empty. This balances the reference taken
* in coalition_create.
- * The memory containig the coalition object may not be freed just yet, if
+ * The memory containing the coalition object may not be freed just yet, if
* other kernel operations still hold references to it.
*
* Returns:
return copyout(&cru, buffer, MIN(bufsize, sizeof(cru)));
}
+#define coalition_info_set_name_internal(...) 0
+
+static int
+coalition_info_efficiency(coalition_t coal, user_addr_t buffer, user_size_t bufsize)
+{
+ int error = 0;
+ if (coalition_type(coal) != COALITION_TYPE_JETSAM)
+ return EINVAL;
+ uint64_t flags = 0;
+ error = copyin(buffer, &flags, MIN(bufsize, sizeof(flags)));
+ if (error)
+ return error;
+ if ((flags & COALITION_EFFICIENCY_VALID_FLAGS) == 0)
+ return EINVAL;
+ if (flags & COALITION_FLAGS_EFFICIENT) {
+ coalition_set_efficient(coal);
+ }
+ return error;
+}
+
int coalition_info(proc_t p, struct coalition_info_args *uap, __unused int32_t *retval)
{
user_addr_t cidp = uap->cid;
case COALITION_INFO_RESOURCE_USAGE:
error = coalition_info_resource_usage(coal, buffer, bufsize);
break;
+ case COALITION_INFO_SET_NAME:
+ error = coalition_info_set_name_internal(coal, buffer, bufsize);
+ break;
+ case COALITION_INFO_SET_EFFICIENCY:
+ error = coalition_info_efficiency(coal, buffer, bufsize);
+ break;
default:
error = EINVAL;
}
return error;
}
-#if defined(DEVELOPMENT) || defined(DEBUG)
+#if DEVELOPMENT || DEBUG
static int sysctl_coalition_get_ids SYSCTL_HANDLER_ARGS
{
#pragma unused(oidp, arg1, arg2)
out:
proc_rele(tproc);
+ if (npids < 0) {
+ /* npids is a negative errno */
+ return -npids;
+ }
+
if (npids == 0)
return ENOENT;