/*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <sys/vnode_internal.h>
#include <sys/namei.h>
#include <sys/ubc_internal.h>
-#include <sys/mount_internal.h>
#include <sys/malloc.h>
+#include <sys/user.h>
+#if CONFIG_PROTECT
+#include <sys/cprotect.h>
+#endif
#include <default_pager/default_pager_types.h>
#include <default_pager/default_pager_object.h>
/*
* Get a vnode for the paging area.
*/
- NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1,
+ NDINIT(ndp, LOOKUP, OP_LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1,
((IS_64BIT_PROCESS(p)) ? UIO_USERSPACE64 : UIO_USERSPACE32),
(user_addr_t) args->filename, ctx);
if ((file_size < (off_t)size) && ((error = vnode_setsize(vp, (off_t)size, 0, ctx)) != 0))
goto swapon_bailout;
+#if CONFIG_PROTECT
+ {
+ /* initialize content protection keys manually */
+ if ((error = cp_handle_vnop(vp, CP_WRITE_ACCESS, 0)) != 0) {
+ goto swapon_bailout;
+ }
+ }
+#endif
+
+
if (default_pager_init_flag == 0) {
start_def_pager(NULL);
default_pager_init_flag = 1;
goto swapon_bailout;
}
- if (vp->v_mount->mnt_kern_flag & MNTK_SSD) {
+#if CONFIG_EMBEDDED
+ dp_cluster_size = 1 * PAGE_SIZE;
+#else
+ if ((dp_isssd = vnode_pager_isSSD(vp)) == TRUE) {
/*
* keep the cluster size small since the
* seek cost is effectively 0 which means
* we don't care much about fragmentation
*/
- dp_isssd = TRUE;
dp_cluster_size = 2 * PAGE_SIZE;
} else {
/*
* use the default cluster size
*/
- dp_isssd = FALSE;
dp_cluster_size = 0;
}
+#endif
kr = default_pager_backing_store_create(default_pager,
-1, /* default priority */
dp_cluster_size,
}
(void) thread_funnel_set(kernel_flock, FALSE);
AUDIT_MACH_SYSCALL_EXIT(error);
+
+ if (error)
+ printf("macx_swapon FAILED - %d\n", error);
+ else
+ printf("macx_swapon SUCCESS\n");
+
return(error);
}
int error;
boolean_t funnel_state;
vfs_context_t ctx = vfs_context_current();
+ struct uthread *ut;
+ int orig_iopol_disk;
AUDIT_MACH_SYSCALL_ENTER(AUE_SWAPOFF);
/*
* Get the vnode for the paging area.
*/
- NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1,
+ NDINIT(ndp, LOOKUP, OP_LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1,
((IS_64BIT_PROCESS(p)) ? UIO_USERSPACE64 : UIO_USERSPACE32),
(user_addr_t) args->filename, ctx);
}
backing_store = (mach_port_t)bs_port_table[i].bs;
+ ut = get_bsdthread_info(current_thread());
+
+ orig_iopol_disk = proc_get_thread_selfdiskacc();
+ proc_apply_thread_selfdiskacc(IOPOL_THROTTLE);
+
kr = default_pager_backing_store_delete(backing_store);
+
+ proc_apply_thread_selfdiskacc(orig_iopol_disk);
+
switch (kr) {
case KERN_SUCCESS:
error = 0;
(void) thread_funnel_set(kernel_flock, FALSE);
AUDIT_MACH_SYSCALL_EXIT(error);
+
+ if (error)
+ printf("macx_swapoff FAILED - %d\n", error);
+ else
+ printf("macx_swapoff SUCCESS\n");
+
return(error);
}