/*
- * Copyright (c) 1999, 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2007 Apple Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
- * File: ubc.h
- * Author: Umesh Vaishampayan [umeshv@apple.com]
- * 05-Aug-1999 umeshv Created.
- *
* Header file for Unified Buffer Cache.
*
*/
#define _SYS_UBC_H_
#include <sys/appleapiopts.h>
-#include <sys/types.h>
-#include <sys/ucred.h>
-#include <sys/vnode.h>
-
#include <sys/cdefs.h>
-
+#include <sys/kernel_types.h>
+#include <kern/locks.h>
#include <mach/memory_object_types.h>
-#define UBC_INFO_NULL ((struct ubc_info *) 0)
-#define UBC_NOINFO ((struct ubc_info *)0xDEADD1ED)
-#ifdef __APPLE_API_PRIVATE
-extern struct zone *ubc_info_zone;
+/* defns for ubc_sync_range() and ubc_msync */
-/*
- * The following data structure keeps the information to associate
- * a vnode to the correspondig VM objects.
- */
-
-struct ubc_info {
- memory_object_t ui_pager; /* pager */
- memory_object_control_t ui_control; /* VM control for the pager */
- long ui_flags; /* flags */
- struct vnode *ui_vnode; /* The vnode for this ubc_info */
- struct ucred *ui_ucred; /* holds credentials for NFS paging */
- int ui_refcount;/* ref count on the ubc_info */
- off_t ui_size; /* file size for the vnode */
- long ui_mapped; /* is it currently mapped */
-};
-
-/* Defines for ui_flags */
-#define UI_NONE 0x00000000 /* none */
-#define UI_HASPAGER 0x00000001 /* has a pager associated */
-#define UI_INITED 0x00000002 /* newly initialized vnode */
-#define UI_HASOBJREF 0x00000004 /* hold a reference on object */
-#define UI_WASMAPPED 0x00000008 /* vnode was mapped */
-#define UI_DONTCACHE 0x00000010 /* do not cache object */
-
-#endif /* __APPLE_API_PRIVATE */
-
-#ifdef __APPLE_API_EVOLVING
-/*
- * exported primitives for loadable file systems.
- */
+#define UBC_PUSHDIRTY 0x01 /* clean any dirty pages in the specified range to the backing store */
+#define UBC_PUSHALL 0x02 /* push both dirty and precious pages to the backing store */
+#define UBC_INVALIDATE 0x04 /* invalidate pages in the specified range... may be used with UBC_PUSHDIRTY/ALL */
+#define UBC_SYNC 0x08 /* wait for I/Os generated by UBC_PUSHDIRTY to complete */
__BEGIN_DECLS
-int ubc_info_init __P((struct vnode *));
-void ubc_info_deallocate __P((struct ubc_info *));
-int ubc_setsize __P((struct vnode *, off_t));
-off_t ubc_getsize __P((struct vnode *));
-int ubc_uncache __P((struct vnode *));
-int ubc_umount __P((struct mount *));
-void ubc_unmountall __P(());
-int ubc_setcred __P((struct vnode *, struct proc *));
-struct ucred *ubc_getcred __P((struct vnode *));
-memory_object_t ubc_getpager __P((struct vnode *));
-memory_object_control_t ubc_getobject __P((struct vnode *, int));
-int ubc_setpager __P((struct vnode *, memory_object_t));
-int ubc_setflags __P((struct vnode *, int));
-int ubc_clearflags __P((struct vnode *, int));
-int ubc_issetflags __P((struct vnode *, int));
-off_t ubc_blktooff __P((struct vnode *, daddr_t));
-daddr_t ubc_offtoblk __P((struct vnode *, off_t));
-int ubc_clean __P((struct vnode *, int));
-int ubc_pushdirty __P((struct vnode *));
-int ubc_pushdirty_range __P((struct vnode *, off_t, off_t));
-int ubc_hold __P((struct vnode *));
-void ubc_rele __P((struct vnode *));
-void ubc_map __P((struct vnode *));
-int ubc_destroy_named __P((struct vnode *));
-int ubc_release_named __P((struct vnode *));
-int ubc_invalidate __P((struct vnode *, off_t, size_t));
-int ubc_isinuse __P((struct vnode *, int));
-
-int ubc_page_op __P((struct vnode *, off_t, int, vm_offset_t *, int *));
+
+off_t ubc_blktooff(struct vnode *, daddr64_t);
+daddr64_t ubc_offtoblk(struct vnode *, off_t);
+off_t ubc_getsize(struct vnode *);
+int ubc_setsize(struct vnode *, off_t);
+
+kauth_cred_t ubc_getcred(struct vnode *);
+struct thread;
+int ubc_setthreadcred(struct vnode *, struct proc *, struct thread *);
+
+int ubc_sync_range(vnode_t, off_t, off_t, int);
+errno_t ubc_msync(vnode_t, off_t, off_t, off_t *, int);
+int ubc_pages_resident(vnode_t);
+int ubc_page_op(vnode_t, off_t, int, ppnum_t *, int *);
+int ubc_range_op(vnode_t, off_t, off_t, int, int *);
+
+#ifdef KERNEL_PRIVATE
+/* This API continues to exist only until <rdar://4714366> is resolved */
+int ubc_setcred(struct vnode *, struct proc *) __deprecated;
+/* code signing */
+struct cs_blob;
+struct cs_blob *ubc_cs_blob_get(vnode_t, cpu_type_t, off_t);
+int cs_entitlements_blob_get(proc_t p, void **, size_t *);
+#endif
/* cluster IO routines */
-int cluster_read __P((struct vnode *, struct uio *, off_t, int, int));
-int advisory_read __P((struct vnode *, off_t, off_t, int, int));
-int cluster_write __P((struct vnode *, struct uio*, off_t, off_t,
- off_t, off_t, int, int));
-int cluster_push __P((struct vnode *));
-int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
- off_t, int, int));
-int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
- off_t, int, int));
-int cluster_bp __P((struct buf *));
+int advisory_read(vnode_t, off_t, off_t, int);
+int advisory_read_ext(vnode_t, off_t, off_t, int, int (*)(buf_t, void *), void *, int);
-/* UPL routines */
-int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *,
- upl_page_info_t **, int));
-int ubc_upl_map __P((upl_t, vm_offset_t *));
-int ubc_upl_unmap __P((upl_t));
-int ubc_upl_commit __P((upl_t));
-int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int));
-int ubc_upl_abort __P((upl_t, int));
-int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int));
-upl_page_info_t *ubc_upl_pageinfo __P((upl_t));
-__END_DECLS
+int cluster_read(vnode_t, struct uio *, off_t, int);
+int cluster_read_ext(vnode_t, struct uio *, off_t, int, int (*)(buf_t, void *), void *);
-#define UBCINFOMISSING(vp) \
- ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL))
+int cluster_write(vnode_t, struct uio *, off_t, off_t, off_t, off_t, int);
+int cluster_write_ext(vnode_t, struct uio *, off_t, off_t, off_t, off_t, int, int (*)(buf_t, void *), void *);
-#define UBCINFORECLAIMED(vp) \
- ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO))
+int cluster_pageout(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int);
+int cluster_pageout_ext(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int, int (*)(buf_t, void *), void *);
-#define UBCINFOEXISTS(vp) \
- ((vp) && ((vp)->v_type == VREG) && \
- ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO))
+int cluster_pagein(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int);
+int cluster_pagein_ext(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int, int (*)(buf_t, void *), void *);
-#define UBCISVALID(vp) \
- ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM))
+int cluster_push(vnode_t, int);
+int cluster_push_ext(vnode_t, int, int (*)(buf_t, void *), void *);
-#define UBCINVALID(vp) \
- (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \
- || ((vp) && ((vp)->v_flag & VSYSTEM)))
+int cluster_bp(buf_t);
+int cluster_bp_ext(buf_t, int (*)(buf_t, void *), void *);
-#define UBCINFOCHECK(fun, vp) \
- if ((vp) && ((vp)->v_type == VREG) && \
- (((vp)->v_ubcinfo == UBC_INFO_NULL) \
- || ((vp)->v_ubcinfo == UBC_NOINFO))) \
- panic("%s: lost ubc_info", (fun));
+void cluster_zero(upl_t, upl_offset_t, int, buf_t);
-/* Flags for ubc_getobject() */
-#define UBC_FLAGS_NONE 0x0000
-#define UBC_HOLDOBJECT 0x0001
+int cluster_copy_upl_data(uio_t, upl_t, int, int *);
+int cluster_copy_ubc_data(vnode_t, uio_t, int *, int);
-#endif /* __APPLE_API_EVOLVING */
+
+/* UPL routines */
+int ubc_create_upl(vnode_t, off_t, int, upl_t *, upl_page_info_t **, int);
+int ubc_upl_map(upl_t, vm_offset_t *);
+int ubc_upl_unmap(upl_t);
+int ubc_upl_commit(upl_t);
+int ubc_upl_commit_range(upl_t, upl_offset_t, upl_size_t, int);
+int ubc_upl_abort(upl_t, int);
+int ubc_upl_abort_range(upl_t, upl_offset_t, upl_size_t, int);
+
+upl_page_info_t *ubc_upl_pageinfo(upl_t);
+upl_size_t ubc_upl_maxbufsize(void);
+
+int is_file_clean(vnode_t, off_t);
+
+__END_DECLS
#endif /* _SYS_UBC_H_ */