#ifndef _SYS_UBC_H_
#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 <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;
struct ubc_info {
memory_object_t ui_pager;
memory_object_control_t ui_control;
long ui_flags;
struct vnode *ui_vnode;
struct ucred *ui_ucred;
int ui_refcount;
off_t ui_size;
long ui_mapped;
void *ui_owner;
};
#define UI_NONE 0x00000000
#define UI_HASPAGER 0x00000001
#define UI_INITED 0x00000002
#define UI_HASOBJREF 0x00000004
#define UI_WASMAPPED 0x00000008
#define UI_DONTCACHE 0x00000010
#define UI_BUSY 0x00000020
#define UI_WANTED 0x00000040
#endif
#ifdef __APPLE_API_EVOLVING
__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, ppnum_t *, int *));
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_release __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 cluster_copy_upl_data __P((struct uio *, upl_t, int, int));
int cluster_copy_ubc_data __P((struct vnode *, struct uio *, int *, int));
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
#define UBCINFOMISSING(vp) \
((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL))
#define UBCINFORECLAIMED(vp) \
((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO))
#define UBCINFOEXISTS(vp) \
((vp) && ((vp)->v_type == VREG) && \
((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO))
#define UBCISVALID(vp) \
((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM))
#define UBCINVALID(vp) \
(((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \
|| ((vp) && ((vp)->v_flag & VSYSTEM)))
#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));
#define UBC_FLAGS_NONE 0x0000
#define UBC_HOLDOBJECT 0x0001
#define UBC_FOR_PAGEOUT 0x0002
#endif
#endif