]>
Commit | Line | Data |
---|---|---|
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 |
50 | extern 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 | ||
57 | struct 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 | |
87 | int ubc_info_init __P((struct vnode *)); | |
0b4e3aa0 | 88 | void ubc_info_deallocate __P((struct ubc_info *)); |
1c79356b A |
89 | int ubc_setsize __P((struct vnode *, off_t)); |
90 | off_t ubc_getsize __P((struct vnode *)); | |
91 | int ubc_uncache __P((struct vnode *)); | |
92 | int ubc_umount __P((struct mount *)); | |
93 | void ubc_unmountall __P(()); | |
94 | int ubc_setcred __P((struct vnode *, struct proc *)); | |
95 | struct ucred *ubc_getcred __P((struct vnode *)); | |
0b4e3aa0 A |
96 | memory_object_t ubc_getpager __P((struct vnode *)); |
97 | memory_object_control_t ubc_getobject __P((struct vnode *, int)); | |
98 | int ubc_setpager __P((struct vnode *, memory_object_t)); | |
1c79356b A |
99 | int ubc_setflags __P((struct vnode *, int)); |
100 | int ubc_clearflags __P((struct vnode *, int)); | |
101 | int ubc_issetflags __P((struct vnode *, int)); | |
102 | off_t ubc_blktooff __P((struct vnode *, daddr_t)); | |
103 | daddr_t ubc_offtoblk __P((struct vnode *, off_t)); | |
104 | int ubc_clean __P((struct vnode *, int)); | |
105 | int ubc_pushdirty __P((struct vnode *)); | |
0b4e3aa0 | 106 | int ubc_pushdirty_range __P((struct vnode *, off_t, off_t)); |
1c79356b A |
107 | int ubc_hold __P((struct vnode *)); |
108 | void ubc_rele __P((struct vnode *)); | |
109 | void ubc_map __P((struct vnode *)); | |
0b4e3aa0 A |
110 | int ubc_destroy_named __P((struct vnode *)); |
111 | int ubc_release_named __P((struct vnode *)); | |
1c79356b A |
112 | int ubc_invalidate __P((struct vnode *, off_t, size_t)); |
113 | int ubc_isinuse __P((struct vnode *, int)); | |
114 | ||
de355530 | 115 | int ubc_page_op __P((struct vnode *, off_t, int, vm_offset_t *, int *)); |
0b4e3aa0 | 116 | |
1c79356b A |
117 | /* cluster IO routines */ |
118 | int cluster_read __P((struct vnode *, struct uio *, off_t, int, int)); | |
119 | int advisory_read __P((struct vnode *, off_t, off_t, int, int)); | |
120 | int cluster_write __P((struct vnode *, struct uio*, off_t, off_t, | |
121 | off_t, off_t, int, int)); | |
122 | int cluster_push __P((struct vnode *)); | |
123 | int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
124 | off_t, int, int)); | |
125 | int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
126 | off_t, int, int)); | |
127 | int cluster_bp __P((struct buf *)); | |
0b4e3aa0 A |
128 | |
129 | /* UPL routines */ | |
130 | int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *, | |
131 | upl_page_info_t **, int)); | |
132 | int ubc_upl_map __P((upl_t, vm_offset_t *)); | |
133 | int ubc_upl_unmap __P((upl_t)); | |
134 | int ubc_upl_commit __P((upl_t)); | |
135 | int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int)); | |
136 | int ubc_upl_abort __P((upl_t, int)); | |
137 | int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int)); | |
138 | upl_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 |