]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/ubc.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / bsd / sys / ubc.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 1999-2007 Apple Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
0a7de745 28/*
1c79356b
A
29 * Header file for Unified Buffer Cache.
30 *
0a7de745 31 */
1c79356b 32
0a7de745
A
33#ifndef _SYS_UBC_H_
34#define _SYS_UBC_H_
1c79356b 35
9bccf70c 36#include <sys/appleapiopts.h>
1c79356b 37#include <sys/cdefs.h>
91447636
A
38#include <sys/kernel_types.h>
39#include <kern/locks.h>
d9a64523 40#include <mach/machine.h>
1c79356b 41#include <mach/memory_object_types.h>
39236c6e 42#include <sys/ucred.h>
1c79356b 43
39037602
A
44#ifdef KERNEL_PRIVATE
45#include <sys/imgact.h>
46#endif // KERNEL_PRIVATE
47
fe8ab488 48/* defns for ubc_msync() and ubc_msync */
1c79356b 49
0a7de745
A
50#define UBC_PUSHDIRTY 0x01 /* clean any dirty pages in the specified range to the backing store */
51#define UBC_PUSHALL 0x02 /* push both dirty and precious pages to the backing store */
52#define UBC_INVALIDATE 0x04 /* invalidate pages in the specified range... may be used with UBC_PUSHDIRTY/ALL */
53#define UBC_SYNC 0x08 /* wait for I/Os generated by UBC_PUSHDIRTY to complete */
1c79356b
A
54
55__BEGIN_DECLS
0b4e3aa0 56
0a7de745
A
57off_t ubc_blktooff(struct vnode *, daddr64_t);
58daddr64_t ubc_offtoblk(struct vnode *, off_t);
59off_t ubc_getsize(struct vnode *);
60int ubc_setsize(struct vnode *, off_t);
0b4e3aa0 61
fe8ab488
A
62#ifdef KERNEL_PRIVATE
63
64enum {
65 UBC_SETSIZE_NO_FS_REENTRY = 1
66};
67typedef uint32_t ubc_setsize_opts_t;
68
69errno_t ubc_setsize_ex(vnode_t vp, off_t nsize, ubc_setsize_opts_t opts);
70
71#endif // KERNEL_PRIVATE
72
2d21ac55 73kauth_cred_t ubc_getcred(struct vnode *);
13fec989 74struct thread;
0a7de745 75int ubc_setthreadcred(struct vnode *, struct proc *, struct thread *);
1c79356b 76
91447636 77errno_t ubc_msync(vnode_t, off_t, off_t, off_t *, int);
0a7de745
A
78int ubc_pages_resident(vnode_t);
79int ubc_page_op(vnode_t, off_t, int, ppnum_t *, int *);
80int ubc_range_op(vnode_t, off_t, off_t, int, int *);
1c79356b 81
b0d623f7
A
82#ifdef KERNEL_PRIVATE
83/* This API continues to exist only until <rdar://4714366> is resolved */
0a7de745 84int ubc_setcred(struct vnode *, struct proc *) __deprecated;
2d21ac55
A
85/* code signing */
86struct cs_blob;
f427ee49
A
87struct cs_blob *ubc_cs_blob_get(vnode_t, cpu_type_t, cpu_subtype_t, off_t);
88struct cs_blob *ubc_cs_blob_get_supplement(vnode_t, off_t);
fe8ab488
A
89
90/* apis to handle generation count for cs blob */
91void cs_blob_reset_cache(void);
f427ee49 92int ubc_cs_blob_revalidate(vnode_t, struct cs_blob *, struct image_params *, int, uint32_t);
fe8ab488
A
93int ubc_cs_generation_check(vnode_t);
94
39236c6e
A
95int cs_entitlements_blob_get(proc_t, void **, size_t *);
96int cs_blob_get(proc_t, void **, size_t *);
97const char *cs_identity_get(proc_t);
3e170ce0 98
b0d623f7 99#endif
1c79356b 100
91447636 101/* cluster IO routines */
d9a64523
A
102void cluster_update_state(vnode_t, vm_object_offset_t, vm_object_offset_t, boolean_t);
103
0a7de745
A
104int advisory_read(vnode_t, off_t, off_t, int);
105int advisory_read_ext(vnode_t, off_t, off_t, int, int (*)(buf_t, void *), void *, int);
1c79356b 106
0a7de745
A
107int cluster_read(vnode_t, struct uio *, off_t, int);
108int cluster_read_ext(vnode_t, struct uio *, off_t, int, int (*)(buf_t, void *), void *);
2d21ac55 109
0a7de745
A
110int cluster_write(vnode_t, struct uio *, off_t, off_t, off_t, off_t, int);
111int cluster_write_ext(vnode_t, struct uio *, off_t, off_t, off_t, off_t, int, int (*)(buf_t, void *), void *);
2d21ac55 112
0a7de745
A
113int cluster_pageout(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int);
114int cluster_pageout_ext(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int, int (*)(buf_t, void *), void *);
2d21ac55 115
0a7de745
A
116int cluster_pagein(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int);
117int cluster_pagein_ext(vnode_t, upl_t, upl_offset_t, off_t, int, off_t, int, int (*)(buf_t, void *), void *);
2d21ac55 118
0a7de745
A
119int cluster_push(vnode_t, int);
120int cluster_push_ext(vnode_t, int, int (*)(buf_t, void *), void *);
121int cluster_push_err(vnode_t, int, int (*)(buf_t, void *), void *, int *);
2d21ac55 122
0a7de745
A
123int cluster_bp(buf_t);
124int cluster_bp_ext(buf_t, int (*)(buf_t, void *), void *);
2d21ac55 125
0a7de745 126void cluster_zero(upl_t, upl_offset_t, int, buf_t);
2d21ac55 127
0a7de745
A
128int cluster_copy_upl_data(uio_t, upl_t, int, int *);
129int cluster_copy_ubc_data(vnode_t, uio_t, int *, int);
1c79356b 130
3e170ce0
A
131typedef struct cl_direct_read_lock cl_direct_read_lock_t;
132cl_direct_read_lock_t *cluster_lock_direct_read(vnode_t vp, lck_rw_type_t exclusive);
133void cluster_unlock_direct_read(cl_direct_read_lock_t *lck);
1c79356b 134
91447636 135/* UPL routines */
5ba3f43e 136#ifndef XNU_KERNEL_PRIVATE
0a7de745 137int ubc_create_upl(vnode_t, off_t, int, upl_t *, upl_page_info_t **, int);
5ba3f43e 138#endif /* XNU_KERNEL_PRIVATE */
0a7de745
A
139int ubc_upl_map(upl_t, vm_offset_t *);
140int ubc_upl_unmap(upl_t);
141int ubc_upl_commit(upl_t);
142int ubc_upl_commit_range(upl_t, upl_offset_t, upl_size_t, int);
143int ubc_upl_abort(upl_t, int);
144int ubc_upl_abort_range(upl_t, upl_offset_t, upl_size_t, int);
145void ubc_upl_range_needed(upl_t, int, int);
1c79356b 146
91447636 147upl_page_info_t *ubc_upl_pageinfo(upl_t);
2d21ac55 148upl_size_t ubc_upl_maxbufsize(void);
1c79356b 149
0a7de745 150int is_file_clean(vnode_t, off_t);
b0d623f7 151
3e170ce0
A
152errno_t mach_to_bsd_errno(kern_return_t mach_err);
153
39037602
A
154#ifdef KERNEL_PRIVATE
155
0a7de745
A
156int ubc_create_upl_external(vnode_t, off_t, int, upl_t *, upl_page_info_t **, int);
157#ifdef XNU_KERNEL_PRIVATE
158int ubc_create_upl_kernel(vnode_t, off_t, int, upl_t *, upl_page_info_t **, int, vm_tag_t);
5ba3f43e
A
159#endif /* XNU_KERNEL_PRIVATE */
160
cb323159 161boolean_t ubc_is_mapped(const struct vnode *, boolean_t *writable);
39037602
A
162__attribute__((pure)) boolean_t ubc_is_mapped_writable(const struct vnode *);
163
164uint32_t cluster_max_io_size(mount_t, int);
165
166#endif
167
91447636 168__END_DECLS
9bccf70c 169
0a7de745 170#endif /* _SYS_UBC_H_ */