]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 1999, 2000-2002 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * File: ubc.h | |
24 | * Author: Umesh Vaishampayan [umeshv@apple.com] | |
25 | * 05-Aug-1999 umeshv Created. | |
26 | * | |
27 | * Header file for Unified Buffer Cache. | |
28 | * | |
29 | */ | |
30 | ||
31 | #ifndef _SYS_UBC_H_ | |
32 | #define _SYS_UBC_H_ | |
33 | ||
34 | #include <sys/appleapiopts.h> | |
35 | #include <sys/types.h> | |
36 | #include <sys/ucred.h> | |
37 | #include <sys/vnode.h> | |
38 | ||
39 | #include <sys/cdefs.h> | |
40 | ||
41 | #include <mach/memory_object_types.h> | |
42 | ||
43 | #define UBC_INFO_NULL ((struct ubc_info *) 0) | |
44 | #define UBC_NOINFO ((struct ubc_info *)0xDEADD1ED) | |
45 | ||
46 | #ifdef __APPLE_API_PRIVATE | |
47 | extern struct zone *ubc_info_zone; | |
48 | ||
49 | /* | |
50 | * The following data structure keeps the information to associate | |
51 | * a vnode to the correspondig VM objects. | |
52 | */ | |
53 | ||
54 | struct ubc_info { | |
55 | memory_object_t ui_pager; /* pager */ | |
56 | memory_object_control_t ui_control; /* VM control for the pager */ | |
57 | long ui_flags; /* flags */ | |
58 | struct vnode *ui_vnode; /* The vnode for this ubc_info */ | |
59 | struct ucred *ui_ucred; /* holds credentials for NFS paging */ | |
60 | int ui_refcount;/* ref count on the ubc_info */ | |
61 | off_t ui_size; /* file size for the vnode */ | |
62 | long ui_mapped; /* is it currently mapped */ | |
63 | void *ui_owner; /* for recursive ubc_busy */ | |
64 | }; | |
65 | ||
66 | /* Defines for ui_flags */ | |
67 | #define UI_NONE 0x00000000 /* none */ | |
68 | #define UI_HASPAGER 0x00000001 /* has a pager associated */ | |
69 | #define UI_INITED 0x00000002 /* newly initialized vnode */ | |
70 | #define UI_HASOBJREF 0x00000004 /* hold a reference on object */ | |
71 | #define UI_WASMAPPED 0x00000008 /* vnode was mapped */ | |
72 | #define UI_DONTCACHE 0x00000010 /* do not cache object */ | |
73 | #define UI_BUSY 0x00000020 /* for VM synchronization */ | |
74 | #define UI_WANTED 0x00000040 /* for VM synchronization */ | |
75 | ||
76 | #endif /* __APPLE_API_PRIVATE */ | |
77 | ||
78 | #ifdef __APPLE_API_EVOLVING | |
79 | /* | |
80 | * exported primitives for loadable file systems. | |
81 | */ | |
82 | ||
83 | __BEGIN_DECLS | |
84 | int ubc_info_init __P((struct vnode *)); | |
85 | void ubc_info_deallocate __P((struct ubc_info *)); | |
86 | int ubc_setsize __P((struct vnode *, off_t)); | |
87 | off_t ubc_getsize __P((struct vnode *)); | |
88 | int ubc_uncache __P((struct vnode *)); | |
89 | int ubc_umount __P((struct mount *)); | |
90 | void ubc_unmountall __P(()); | |
91 | int ubc_setcred __P((struct vnode *, struct proc *)); | |
92 | struct ucred *ubc_getcred __P((struct vnode *)); | |
93 | memory_object_t ubc_getpager __P((struct vnode *)); | |
94 | memory_object_control_t ubc_getobject __P((struct vnode *, int)); | |
95 | int ubc_setpager __P((struct vnode *, memory_object_t)); | |
96 | int ubc_setflags __P((struct vnode *, int)); | |
97 | int ubc_clearflags __P((struct vnode *, int)); | |
98 | int ubc_issetflags __P((struct vnode *, int)); | |
99 | off_t ubc_blktooff __P((struct vnode *, daddr_t)); | |
100 | daddr_t ubc_offtoblk __P((struct vnode *, off_t)); | |
101 | int ubc_clean __P((struct vnode *, int)); | |
102 | int ubc_pushdirty __P((struct vnode *)); | |
103 | int ubc_pushdirty_range __P((struct vnode *, off_t, off_t)); | |
104 | int ubc_hold __P((struct vnode *)); | |
105 | void ubc_rele __P((struct vnode *)); | |
106 | void ubc_map __P((struct vnode *)); | |
107 | int ubc_destroy_named __P((struct vnode *)); | |
108 | int ubc_release_named __P((struct vnode *)); | |
109 | int ubc_invalidate __P((struct vnode *, off_t, size_t)); | |
110 | int ubc_isinuse __P((struct vnode *, int)); | |
111 | ||
112 | int ubc_page_op __P((struct vnode *, off_t, int, ppnum_t *, int *)); | |
113 | ||
114 | /* cluster IO routines */ | |
115 | int cluster_read __P((struct vnode *, struct uio *, off_t, int, int)); | |
116 | int advisory_read __P((struct vnode *, off_t, off_t, int, int)); | |
117 | int cluster_write __P((struct vnode *, struct uio*, off_t, off_t, | |
118 | off_t, off_t, int, int)); | |
119 | int cluster_push __P((struct vnode *)); | |
120 | int cluster_release __P((struct vnode *)); | |
121 | int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
122 | off_t, int, int)); | |
123 | int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
124 | off_t, int, int)); | |
125 | int cluster_bp __P((struct buf *)); | |
126 | int cluster_copy_upl_data __P((struct uio *, upl_t, int, int)); | |
127 | int cluster_copy_ubc_data __P((struct vnode *, struct uio *, int *, int)); | |
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)); | |
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() */ | |
165 | #define UBC_FLAGS_NONE 0x0000 | |
166 | #define UBC_HOLDOBJECT 0x0001 | |
167 | #define UBC_FOR_PAGEOUT 0x0002 | |
168 | ||
169 | #endif /* __APPLE_API_EVOLVING */ | |
170 | ||
171 | #endif /* _SYS_UBC_H_ */ | |
172 |