- error = handle_resourceuse(scope, action, policy, policy_subtype, attrp, proc, target_threadid);
- break;
- case PROC_POLICY_APPTYPE:
- error = handle_apptype(scope, action, policy, policy_subtype, attrp, proc, target_threadid);
- break;
- default:
- error = EINVAL;
- break;
- }
-
-out:
- proc_rele(proc);
- kauth_cred_unref(&my_cred);
-#if CONFIG_EMBEDDED
- kauth_cred_unref(&target_cred);
-#endif
- return(error);
-}
-
-
-/* darwin background handling code */
-static int
-handle_background(int scope, int action, __unused int policy, __unused int policy_subtype, user_addr_t attrp, proc_t proc, uint64_t target_threadid)
-{
- int intval, error = 0;
-
-
- switch (action) {
- case PROC_POLICY_ACTION_GET:
- if (scope == PROC_POLICY_SCOPE_PROCESS) {
- intval = proc_get_task_bg_policy(proc->task);
- } else {
- /* thread scope */
- intval = proc_get_thread_bg_policy(proc->task, target_threadid);
- }
- error = copyout((int *)&intval, (user_addr_t)attrp, sizeof(int));
- break;
-
- case PROC_POLICY_ACTION_SET:
- error = copyin((user_addr_t)attrp, (int *)&intval, sizeof(int));
- if (error != 0)
- goto out;
- if (intval > PROC_POLICY_BG_ALL) {
- error = EINVAL;
- goto out;
- }
- if (scope == PROC_POLICY_SCOPE_PROCESS) {
- error = proc_set_bgtaskpolicy(proc->task, intval);
- } else {
- /* thread scope */
- error = proc_set_bgthreadpolicy(proc->task, target_threadid, intval);
- }
- break;
-
- case PROC_POLICY_ACTION_ADD:
- error = copyin((user_addr_t)attrp, (int *)&intval, sizeof(int));
- if (error != 0)
- goto out;
- if (intval > PROC_POLICY_BG_ALL) {
- error = EINVAL;
- goto out;
- }
- if (scope == PROC_POLICY_SCOPE_PROCESS) {
- error = proc_add_bgtaskpolicy(proc->task, intval);
- } else {
- /* thread scope */
- error = proc_add_bgthreadpolicy(proc->task, target_threadid, intval);
+ switch(policy_subtype) {
+ case PROC_POLICY_RUSAGE_NONE:
+ case PROC_POLICY_RUSAGE_WIREDMEM:
+ case PROC_POLICY_RUSAGE_VIRTMEM:
+ case PROC_POLICY_RUSAGE_DISK:
+ case PROC_POLICY_RUSAGE_NETWORK:
+ case PROC_POLICY_RUSAGE_POWER:
+ error = ENOTSUP;
+ goto out;
+ default:
+ error = EINVAL;
+ goto out;
+ case PROC_POLICY_RUSAGE_CPU:
+ break;