]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/ubc.h
xnu-344.49.tar.gz
[apple/xnu.git] / bsd / sys / ubc.h
CommitLineData
1c79356b 1/*
9bccf70c 2 * Copyright (c) 1999, 2000-2002 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * File: ubc.h
27 * Author: Umesh Vaishampayan [umeshv@apple.com]
28 * 05-Aug-1999 umeshv Created.
29 *
30 * Header file for Unified Buffer Cache.
31 *
32 */
33
34#ifndef _SYS_UBC_H_
35#define _SYS_UBC_H_
36
9bccf70c 37#include <sys/appleapiopts.h>
1c79356b
A
38#include <sys/types.h>
39#include <sys/ucred.h>
40#include <sys/vnode.h>
41
42#include <sys/cdefs.h>
43
44#include <mach/memory_object_types.h>
45
46#define UBC_INFO_NULL ((struct ubc_info *) 0)
47#define UBC_NOINFO ((struct ubc_info *)0xDEADD1ED)
48
9bccf70c 49#ifdef __APPLE_API_PRIVATE
1c79356b
A
50extern struct zone *ubc_info_zone;
51
52/*
53 * The following data structure keeps the information to associate
54 * a vnode to the correspondig VM objects.
55 */
56
57struct ubc_info {
0b4e3aa0
A
58 memory_object_t ui_pager; /* pager */
59 memory_object_control_t ui_control; /* VM control for the pager */
60 long ui_flags; /* flags */
61 struct vnode *ui_vnode; /* The vnode for this ubc_info */
62 struct ucred *ui_ucred; /* holds credentials for NFS paging */
63 int ui_refcount;/* ref count on the ubc_info */
64 off_t ui_size; /* file size for the vnode */
65 long ui_mapped; /* is it currently mapped */
b4c24cb9 66 void *ui_owner; /* for recursive ubc_busy */
1c79356b
A
67};
68
69/* Defines for ui_flags */
70#define UI_NONE 0x00000000 /* none */
71#define UI_HASPAGER 0x00000001 /* has a pager associated */
72#define UI_INITED 0x00000002 /* newly initialized vnode */
73#define UI_HASOBJREF 0x00000004 /* hold a reference on object */
74#define UI_WASMAPPED 0x00000008 /* vnode was mapped */
75#define UI_DONTCACHE 0x00000010 /* do not cache object */
b4c24cb9
A
76#define UI_BUSY 0x00000020 /* for VM synchronization */
77#define UI_WANTED 0x00000040 /* for VM synchronization */
1c79356b 78
9bccf70c
A
79#endif /* __APPLE_API_PRIVATE */
80
81#ifdef __APPLE_API_EVOLVING
1c79356b
A
82/*
83 * exported primitives for loadable file systems.
84 */
85
86__BEGIN_DECLS
87int ubc_info_init __P((struct vnode *));
0b4e3aa0 88void ubc_info_deallocate __P((struct ubc_info *));
1c79356b
A
89int ubc_setsize __P((struct vnode *, off_t));
90off_t ubc_getsize __P((struct vnode *));
91int ubc_uncache __P((struct vnode *));
92int ubc_umount __P((struct mount *));
93void ubc_unmountall __P(());
94int ubc_setcred __P((struct vnode *, struct proc *));
95struct ucred *ubc_getcred __P((struct vnode *));
0b4e3aa0
A
96memory_object_t ubc_getpager __P((struct vnode *));
97memory_object_control_t ubc_getobject __P((struct vnode *, int));
98int ubc_setpager __P((struct vnode *, memory_object_t));
1c79356b
A
99int ubc_setflags __P((struct vnode *, int));
100int ubc_clearflags __P((struct vnode *, int));
101int ubc_issetflags __P((struct vnode *, int));
102off_t ubc_blktooff __P((struct vnode *, daddr_t));
103daddr_t ubc_offtoblk __P((struct vnode *, off_t));
104int ubc_clean __P((struct vnode *, int));
105int ubc_pushdirty __P((struct vnode *));
0b4e3aa0 106int ubc_pushdirty_range __P((struct vnode *, off_t, off_t));
1c79356b
A
107int ubc_hold __P((struct vnode *));
108void ubc_rele __P((struct vnode *));
109void ubc_map __P((struct vnode *));
0b4e3aa0
A
110int ubc_destroy_named __P((struct vnode *));
111int ubc_release_named __P((struct vnode *));
1c79356b
A
112int ubc_invalidate __P((struct vnode *, off_t, size_t));
113int ubc_isinuse __P((struct vnode *, int));
114
de355530 115int ubc_page_op __P((struct vnode *, off_t, int, vm_offset_t *, int *));
0b4e3aa0 116
1c79356b
A
117/* cluster IO routines */
118int cluster_read __P((struct vnode *, struct uio *, off_t, int, int));
119int advisory_read __P((struct vnode *, off_t, off_t, int, int));
120int cluster_write __P((struct vnode *, struct uio*, off_t, off_t,
121 off_t, off_t, int, int));
122int cluster_push __P((struct vnode *));
123int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
124 off_t, int, int));
125int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
126 off_t, int, int));
127int cluster_bp __P((struct buf *));
0b4e3aa0
A
128
129/* UPL routines */
130int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *,
131 upl_page_info_t **, int));
132int ubc_upl_map __P((upl_t, vm_offset_t *));
133int ubc_upl_unmap __P((upl_t));
134int ubc_upl_commit __P((upl_t));
135int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int));
136int ubc_upl_abort __P((upl_t, int));
137int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int));
138upl_page_info_t *ubc_upl_pageinfo __P((upl_t));
1c79356b
A
139__END_DECLS
140
141#define UBCINFOMISSING(vp) \
142 ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL))
143
144#define UBCINFORECLAIMED(vp) \
145 ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO))
146
147#define UBCINFOEXISTS(vp) \
148 ((vp) && ((vp)->v_type == VREG) && \
149 ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO))
150
151#define UBCISVALID(vp) \
152 ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM))
153
154#define UBCINVALID(vp) \
155 (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \
156 || ((vp) && ((vp)->v_flag & VSYSTEM)))
157
158#define UBCINFOCHECK(fun, vp) \
159 if ((vp) && ((vp)->v_type == VREG) && \
160 (((vp)->v_ubcinfo == UBC_INFO_NULL) \
161 || ((vp)->v_ubcinfo == UBC_NOINFO))) \
162 panic("%s: lost ubc_info", (fun));
163
164/* Flags for ubc_getobject() */
0b4e3aa0 165#define UBC_FLAGS_NONE 0x0000
1c79356b 166#define UBC_HOLDOBJECT 0x0001
1c79356b 167
9bccf70c
A
168#endif /* __APPLE_API_EVOLVING */
169
1c79356b
A
170#endif /* _SYS_UBC_H_ */
171