]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/ubc.h
xnu-517.3.15.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
55e303ae 115int ubc_page_op __P((struct vnode *, off_t, int, ppnum_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 *));
55e303ae 123int cluster_release __P((struct vnode *));
1c79356b
A
124int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
125 off_t, int, int));
126int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
127 off_t, int, int));
128int cluster_bp __P((struct buf *));
55e303ae
A
129int cluster_copy_upl_data __P((struct uio *, upl_t, int, int));
130int cluster_copy_ubc_data __P((struct vnode *, struct uio *, int *, int));
0b4e3aa0
A
131
132/* UPL routines */
133int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *,
134 upl_page_info_t **, int));
135int ubc_upl_map __P((upl_t, vm_offset_t *));
136int ubc_upl_unmap __P((upl_t));
137int ubc_upl_commit __P((upl_t));
138int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int));
139int ubc_upl_abort __P((upl_t, int));
140int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int));
141upl_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