]>
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 | ||
55e303ae | 115 | int ubc_page_op __P((struct vnode *, off_t, int, ppnum_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 *)); | |
55e303ae | 123 | int cluster_release __P((struct vnode *)); |
1c79356b A |
124 | int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int, |
125 | off_t, int, int)); | |
126 | int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
127 | off_t, int, int)); | |
128 | int cluster_bp __P((struct buf *)); | |
55e303ae A |
129 | int cluster_copy_upl_data __P((struct uio *, upl_t, int, int)); |
130 | int cluster_copy_ubc_data __P((struct vnode *, struct uio *, int *, int)); | |
0b4e3aa0 A |
131 | |
132 | /* UPL routines */ | |
133 | int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *, | |
134 | upl_page_info_t **, int)); | |
135 | int ubc_upl_map __P((upl_t, vm_offset_t *)); | |
136 | int ubc_upl_unmap __P((upl_t)); | |
137 | int ubc_upl_commit __P((upl_t)); | |
138 | int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int)); | |
139 | int ubc_upl_abort __P((upl_t, int)); | |
140 | int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int)); | |
141 | upl_page_info_t *ubc_upl_pageinfo __P((upl_t)); | |
1c79356b A |
142 | __END_DECLS |
143 | ||
144 | #define UBCINFOMISSING(vp) \ | |
145 | ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL)) | |
146 | ||
147 | #define UBCINFORECLAIMED(vp) \ | |
148 | ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO)) | |
149 | ||
150 | #define UBCINFOEXISTS(vp) \ | |
151 | ((vp) && ((vp)->v_type == VREG) && \ | |
152 | ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO)) | |
153 | ||
154 | #define UBCISVALID(vp) \ | |
155 | ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM)) | |
156 | ||
157 | #define UBCINVALID(vp) \ | |
158 | (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \ | |
159 | || ((vp) && ((vp)->v_flag & VSYSTEM))) | |
160 | ||
161 | #define UBCINFOCHECK(fun, vp) \ | |
162 | if ((vp) && ((vp)->v_type == VREG) && \ | |
163 | (((vp)->v_ubcinfo == UBC_INFO_NULL) \ | |
164 | || ((vp)->v_ubcinfo == UBC_NOINFO))) \ | |
165 | panic("%s: lost ubc_info", (fun)); | |
166 | ||
167 | /* Flags for ubc_getobject() */ | |
0b4e3aa0 | 168 | #define UBC_FLAGS_NONE 0x0000 |
1c79356b | 169 | #define UBC_HOLDOBJECT 0x0001 |
55e303ae | 170 | #define UBC_FOR_PAGEOUT 0x0002 |
1c79356b | 171 | |
9bccf70c A |
172 | #endif /* __APPLE_API_EVOLVING */ |
173 | ||
1c79356b A |
174 | #endif /* _SYS_UBC_H_ */ |
175 |