1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#ifndef _SYS_UBC_INTERNAL_H_
32#define _SYS_UBC_INTERNAL_H_
33
34#include <sys/appleapiopts.h>
35#include <sys/types.h>
36#include <sys/kernel_types.h>
37#include <sys/ucred.h>
38#include <sys/vnode.h>
39#include <sys/ubc.h>
40#include <sys/mman.h>
41
42#include <sys/cdefs.h>
43
44#include <kern/locks.h>
45#include <mach/memory_object_types.h>
46
47
48#define UBC_INFO_NULL ((struct ubc_info *) 0)
49
50
51extern struct zone *ubc_info_zone;
52
53
54#define MAX_CLUSTERS 4
55
56struct cl_extent {
57 daddr64_t b_addr;
58 daddr64_t e_addr;
59};
60
61struct cl_wextent {
62 daddr64_t b_addr;
63 daddr64_t e_addr;
64 int io_nocache;
65};
66
67struct cl_readahead {
68 lck_mtx_t cl_lockr;
69 daddr64_t cl_lastr;
70 daddr64_t cl_maxra;
71 int cl_ralen;
72};
73
74struct cl_writebehind {
75 lck_mtx_t cl_lockw;
76 int cl_hasbeenpaged;
77 void * cl_scmap;
78 int cl_scdirty;
79 int cl_number;
80 struct cl_wextent cl_clusters[MAX_CLUSTERS];
81};
82
83
84
85
86
87
88struct ubc_info {
89 memory_object_t ui_pager;
90 memory_object_control_t ui_control;
91 long ui_flags;
92 vnode_t *ui_vnode;
93 ucred_t *ui_ucred;
94 off_t ui_size;
95
96 struct cl_readahead *cl_rahead;
97 struct cl_writebehind *cl_wbehind;
98};
99
100
101#define UI_NONE 0x00000000
102#define UI_HASPAGER 0x00000001
103#define UI_INITED 0x00000002
104#define UI_HASOBJREF 0x00000004
105#define UI_WASMAPPED 0x00000008
106#define UI_ISMAPPED 0x00000010
107
108
109
110
111
112__BEGIN_DECLS
113__private_extern__ int ubc_umount(struct mount *mp);
114__private_extern__ void ubc_unmountall(void);
115__private_extern__ memory_object_t ubc_getpager(struct vnode *);
116__private_extern__ int ubc_map(struct vnode *, int);
117__private_extern__ int ubc_destroy_named(struct vnode *);
118
119
120__private_extern__ void cluster_release(struct ubc_info *);
121
122
123
124#define UBC_FLAGS_NONE 0x0000
125#define UBC_HOLDOBJECT 0x0001
126#define UBC_FOR_PAGEOUT 0x0002
127
128memory_object_control_t ubc_getobject(struct vnode *, int);
129
130int ubc_info_init(struct vnode *);
131void ubc_info_deallocate (struct ubc_info *);
132
133int ubc_isinuse(struct vnode *, int);
134
135int ubc_page_op(vnode_t, off_t, int, ppnum_t *, int *);
136int ubc_range_op(vnode_t, off_t, off_t, int, int *);
137
138
139int cluster_copy_upl_data(struct uio *, upl_t, int, int);
140int cluster_copy_ubc_data(vnode_t, struct uio *, int *, int);
141
142
143int UBCINFOMISSING(vnode_t);
144int UBCINFORECLAIMED(vnode_t);
145int UBCINFOEXISTS(vnode_t);
146int UBCISVALID(vnode_t);
147int UBCINVALID(vnode_t);
148int UBCINFOCHECK(const char *, vnode_t);
149
150__END_DECLS
151
152
153#endif
154
155