]>
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 | * | |
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 | ||
9bccf70c | 34 | #include <sys/appleapiopts.h> |
1c79356b A |
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 | ||
9bccf70c | 46 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
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 { | |
0b4e3aa0 A |
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 */ | |
b4c24cb9 | 63 | void *ui_owner; /* for recursive ubc_busy */ |
1c79356b A |
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 */ | |
b4c24cb9 A |
73 | #define UI_BUSY 0x00000020 /* for VM synchronization */ |
74 | #define UI_WANTED 0x00000040 /* for VM synchronization */ | |
1c79356b | 75 | |
9bccf70c A |
76 | #endif /* __APPLE_API_PRIVATE */ |
77 | ||
78 | #ifdef __APPLE_API_EVOLVING | |
1c79356b A |
79 | /* |
80 | * exported primitives for loadable file systems. | |
81 | */ | |
82 | ||
83 | __BEGIN_DECLS | |
84 | int ubc_info_init __P((struct vnode *)); | |
0b4e3aa0 | 85 | void ubc_info_deallocate __P((struct ubc_info *)); |
1c79356b A |
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 *)); | |
0b4e3aa0 A |
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)); | |
1c79356b A |
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 *)); | |
0b4e3aa0 | 103 | int ubc_pushdirty_range __P((struct vnode *, off_t, off_t)); |
1c79356b A |
104 | int ubc_hold __P((struct vnode *)); |
105 | void ubc_rele __P((struct vnode *)); | |
106 | void ubc_map __P((struct vnode *)); | |
0b4e3aa0 A |
107 | int ubc_destroy_named __P((struct vnode *)); |
108 | int ubc_release_named __P((struct vnode *)); | |
1c79356b A |
109 | int ubc_invalidate __P((struct vnode *, off_t, size_t)); |
110 | int ubc_isinuse __P((struct vnode *, int)); | |
111 | ||
0b4e3aa0 A |
112 | int ubc_page_op __P((struct vnode *, off_t, int, vm_offset_t *, int *)); |
113 | ||
1c79356b A |
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_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
121 | off_t, int, int)); | |
122 | int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int, | |
123 | off_t, int, int)); | |
124 | int cluster_bp __P((struct buf *)); | |
0b4e3aa0 A |
125 | |
126 | /* UPL routines */ | |
127 | int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *, | |
128 | upl_page_info_t **, int)); | |
129 | int ubc_upl_map __P((upl_t, vm_offset_t *)); | |
130 | int ubc_upl_unmap __P((upl_t)); | |
131 | int ubc_upl_commit __P((upl_t)); | |
132 | int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int)); | |
133 | int ubc_upl_abort __P((upl_t, int)); | |
134 | int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int)); | |
135 | upl_page_info_t *ubc_upl_pageinfo __P((upl_t)); | |
1c79356b A |
136 | __END_DECLS |
137 | ||
138 | #define UBCINFOMISSING(vp) \ | |
139 | ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL)) | |
140 | ||
141 | #define UBCINFORECLAIMED(vp) \ | |
142 | ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO)) | |
143 | ||
144 | #define UBCINFOEXISTS(vp) \ | |
145 | ((vp) && ((vp)->v_type == VREG) && \ | |
146 | ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO)) | |
147 | ||
148 | #define UBCISVALID(vp) \ | |
149 | ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM)) | |
150 | ||
151 | #define UBCINVALID(vp) \ | |
152 | (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \ | |
153 | || ((vp) && ((vp)->v_flag & VSYSTEM))) | |
154 | ||
155 | #define UBCINFOCHECK(fun, vp) \ | |
156 | if ((vp) && ((vp)->v_type == VREG) && \ | |
157 | (((vp)->v_ubcinfo == UBC_INFO_NULL) \ | |
158 | || ((vp)->v_ubcinfo == UBC_NOINFO))) \ | |
159 | panic("%s: lost ubc_info", (fun)); | |
160 | ||
161 | /* Flags for ubc_getobject() */ | |
0b4e3aa0 | 162 | #define UBC_FLAGS_NONE 0x0000 |
1c79356b | 163 | #define UBC_HOLDOBJECT 0x0001 |
1c79356b | 164 | |
9bccf70c A |
165 | #endif /* __APPLE_API_EVOLVING */ |
166 | ||
1c79356b A |
167 | #endif /* _SYS_UBC_H_ */ |
168 |