/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <sys/namei.h>
#include <sys/ubc.h>
+#include <bsm/audit_kernel.h>
+#include <bsm/audit_kevents.h>
+
#include <mach/mach_types.h>
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
#include <kern/assert.h>
+/*
+ * Routine: macx_backing_store_recovery
+ * Function:
+ * Syscall interface to set a tasks privilege
+ * level so that it is not subject to
+ * macx_backing_store_suspend
+ */
+int
+macx_backing_store_recovery(
+ int pid)
+{
+ int error;
+ struct proc *p = current_proc();
+ boolean_t funnel_state;
+
+ funnel_state = thread_funnel_set(kernel_flock, TRUE);
+ if ((error = suser(p->p_ucred, &p->p_acflag)))
+ goto backing_store_recovery_return;
+
+ /* for now restrict backing_store_recovery */
+ /* usage to only present task */
+ if(pid != p->p_pid) {
+ error = EINVAL;
+ goto backing_store_recovery_return;
+ }
+
+ task_backing_store_privileged(p->task);
+
+backing_store_recovery_return:
+ (void) thread_funnel_set(kernel_flock, FALSE);
+ return(error);
+}
+
+/*
+ * Routine: macx_backing_store_suspend
+ * Function:
+ * Syscall interface to stop new demand for
+ * backing store when backing store is low
+ */
+
+int
+macx_backing_store_suspend(
+ boolean_t suspend)
+{
+ int error;
+ struct proc *p = current_proc();
+ boolean_t funnel_state;
+
+ funnel_state = thread_funnel_set(kernel_flock, TRUE);
+ if ((error = suser(p->p_ucred, &p->p_acflag)))
+ goto backing_store_suspend_return;
+
+ vm_backing_store_disable(suspend);
+
+backing_store_suspend_return:
+ (void) thread_funnel_set(kernel_flock, FALSE);
+ return(error);
+}
+
/*
* Routine: macx_swapon
* Function:
struct vattr vattr;
+ AUDIT_MACH_SYSCALL_ENTER(AUE_SWAPON);
+ AUDIT_ARG(value, priority);
+
funnel_state = thread_funnel_set(kernel_flock, TRUE);
ndp = &nd;
/*
* Get a vnode for the paging area.
*/
- NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1, UIO_USERSPACE,
filename, p);
if ((error = namei(ndp)))
/* Mark this vnode as being used for swapfile */
SET(vp->v_flag, VSWAP);
+ ubc_setcred(vp, p);
+
/*
* take an extra reference on the vnode to keep
* vnreclaim() away from this vnode.
vrele(vp);
}
(void) thread_funnel_set(kernel_flock, FALSE);
+ AUDIT_MACH_SYSCALL_EXIT(error);
return(error);
}
int error;
boolean_t funnel_state;
+ AUDIT_MACH_SYSCALL_ENTER(AUE_SWAPOFF);
funnel_state = thread_funnel_set(kernel_flock, TRUE);
backing_store = NULL;
ndp = &nd;
/*
* Get the vnode for the paging area.
*/
- NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1, UIO_USERSPACE,
filename, p);
if ((error = namei(ndp)))
vrele(vp);
(void) thread_funnel_set(kernel_flock, FALSE);
+ AUDIT_MACH_SYSCALL_EXIT(error);
return(error);
}