]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/fsctl.h
xnu-1699.26.8.tar.gz
[apple/xnu.git] / bsd / sys / fsctl.h
CommitLineData
1c79356b 1/*
5d5c5d0d
A
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 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.
8f6c56a5 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.
17 *
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29/*-
30 * Copyright (c) 1982, 1986, 1990, 1993, 1994
31 * The Regents of the University of California. All rights reserved.
32 * (c) UNIX System Laboratories, Inc.
33 * All or some portions of this file are derived from material licensed
34 * to the University of California by American Telephone and Telegraph
35 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36 * the permission of UNIX System Laboratories, Inc.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)fsctl.h 8.6 (Berkeley) 3/28/94
67 */
68
69#ifndef _SYS_FSCTL_H_
70#define _SYS_FSCTL_H_
71
72#include <sys/ioccom.h>
6d2010ae 73#include <sys/mount.h>
1c79356b 74
6d2010ae 75#ifdef XNU_KERNEL_PRIVATE
b0d623f7 76
6d2010ae
A
77typedef struct user64_namespace_handler_info {
78 user64_addr_t token;
79 user64_addr_t flags;
80 user64_addr_t fdptr;
81} user64_namespace_handler_info;
82
83typedef struct user32_namespace_handler_info {
84 user32_addr_t token;
85 user32_addr_t flags;
86 user32_addr_t fdptr;
87} user32_namespace_handler_info;
88
89typedef struct namespace_handler_info {
90 user_addr_t token;
91 user_addr_t flags;
92 user_addr_t fdptr;
93} namespace_handler_info;
94
95typedef struct user64_namespace_handler_info_ext {
96 user64_addr_t token;
97 user64_addr_t flags;
98 user64_addr_t fdptr;
99 user64_addr_t infoptr;
100} user64_namespace_handler_info_ext;
101
102typedef struct user32_namespace_handler_info_ext {
103 user32_addr_t token;
104 user32_addr_t flags;
105 user32_addr_t fdptr;
106 user32_addr_t infoptr;
107} user32_namespace_handler_info_ext;
108
109typedef struct namespace_handler_info_ext {
110 user_addr_t token;
111 user_addr_t flags;
112 user_addr_t fdptr;
113 user_addr_t infoptr;
114} namespace_handler_info_ext;
115
116extern int resolve_nspace_item(struct vnode *vp, uint64_t op);
117extern int resolve_nspace_item_ext(struct vnode *vp, uint64_t op, void *arg);
118extern int get_nspace_item_status(struct vnode *vp, int32_t *status);
119
120#else
121
122typedef struct namespace_handler_info {
123 int32_t *token;
124 int64_t *flags;
125 int32_t *fdptr;
126} namespace_handler_info;
127
128typedef struct namespace_handler_info_ext {
129 int32_t *token;
130 int64_t *flags;
131 int32_t *fdptr;
132 int64_t *infoptr; // for snapshot write events, the kernel puts an offset/length pair here
133} namespace_handler_info_ext;
134
135
136#endif /* XNU_KERNEL_PRIVATE */
137
138#define NAMESPACE_HANDLER_READ_OP 0x0001
139#define NAMESPACE_HANDLER_WRITE_OP 0x0002
140#define NAMESPACE_HANDLER_DELETE_OP 0x0004
141#define NAMESPACE_HANDLER_TRUNCATE_OP 0x0008
142#define NAMESPACE_HANDLER_RENAME_OP 0x0010
143#define NAMESPACE_HANDLER_METADATA_WRITE_OP 0x0020
144#define NAMESPACE_HANDLER_METADATA_DELETE_OP 0x0040
145#define NAMESPACE_HANDLER_METADATA_MOD 0x0080
146#define NAMESPACE_HANDLER_LINK_CREATE 0x0200
147
148#define NAMESPACE_HANDLER_NSPACE_EVENT 0x1000
149#define NAMESPACE_HANDLER_SNAPSHOT_EVENT 0x0100
150#define NAMESPACE_HANDLER_TRACK_EVENT 0x2000
151
152#define NAMESPACE_HANDLER_EVENT_TYPE_MASK (NAMESPACE_HANDLER_NSPACE_EVENT | NAMESPACE_HANDLER_SNAPSHOT_EVENT | NAMESPACE_HANDLER_TRACK_EVENT)
153
154#define DATALESS_CMPFS_TYPE 0x80000001
b0d623f7
A
155
156
6d2010ae
A
157typedef int32_t nspace_handler_info[2];
158typedef char fstypename_t[MFSTYPENAMELEN];
159
160#ifdef KERNEL
161
162typedef struct user64_package_ext_info {
163 user64_addr_t strings;
164 uint32_t num_entries;
165 uint32_t max_width;
166} user64_package_ext_info;
167
168typedef struct user32_package_ext_info {
169 user32_addr_t strings;
170 uint32_t num_entries;
171 uint32_t max_width;
172} user32_package_ext_info;
173
174#endif // KERNEL
175
b0d623f7
A
176typedef struct package_ext_info {
177 const char *strings;
178 uint32_t num_entries;
179 uint32_t max_width;
180} package_ext_info;
181
6d2010ae
A
182#define FSCTL_SYNC_FULLSYNC (1<<0) /* Flush the data fully to disk, if supported by the filesystem */
183#define FSCTL_SYNC_WAIT (1<<1) /* Wait for the sync to complete */
184
185
186#define FSIOC_SYNC_VOLUME _IOW('A', 1, uint32_t)
187#define FSCTL_SYNC_VOLUME IOCBASECMD(FSIOC_SYNC_VOLUME)
188
189#define FSIOC_SET_PACKAGE_EXTS _IOW('A', 2, struct package_ext_info)
190#define FSCTL_SET_PACKAGE_EXTS IOCBASECMD(FSIOC_SET_PACKAGE_EXTS)
191
192#define FSIOC_WAIT_FOR_SYNC _IOR('A', 3, int32_t)
193#define FSCTL_WAIT_FOR_SYNC IOCBASECMD(FSIOC_WAIT_FOR_SYNC)
194
195#define FSIOC_NAMESPACE_HANDLER_GET _IOW('A', 4, struct namespace_handler_info)
196#define FSCTL_NAMESPACE_HANDLER_GET IOCBASECMD(FSIOC_NAMESPACE_HANDLER_GET)
197
198#define FSIOC_NAMESPACE_HANDLER_UPDATE _IOW('A', 5, nspace_handler_info)
199#define FSCTL_NAMESPACE_HANDLER_UPDATE IOCBASECMD(FSIOC_NAMESPACE_HANDLER_UPDATE)
200
201#define FSIOC_NAMESPACE_HANDLER_UNBLOCK _IOW('A', 6, nspace_handler_info)
202#define FSCTL_NAMESPACE_HANDLER_UNBLOCK IOCBASECMD(FSIOC_NAMESPACE_HANDLER_UNBLOCK)
b0d623f7 203
6d2010ae
A
204#define FSIOC_NAMESPACE_HANDLER_CANCEL _IOW('A', 7, nspace_handler_info)
205#define FSCTL_NAMESPACE_HANDLER_CANCEL IOCBASECMD(FSIOC_NAMESPACE_HANDLER_CANCEL)
b0d623f7 206
6d2010ae
A
207#define FSIOC_NAMESPACE_HANDLER_SET_SNAPSHOT_TIME _IOW('A', 8, int32_t)
208#define FSCTL_NAMESPACE_HANDLER_SET_SNAPSHOT_TIME IOCBASECMD(FSIOC_NAMESPACE_HANDLER_SET_SNAPSHOT_TIME)
209
210#define FSIOC_OLD_SNAPSHOT_HANDLER_GET _IOW('A', 9, struct namespace_handler_info)
211#define FSCTL_OLD_SNAPSHOT_HANDLER_GET IOCBASECMD(FSIOC_OLD_SNAPSHOT_HANDLER_GET)
212
213#define FSIOC_SET_FSTYPENAME_OVERRIDE _IOW('A', 10, fstypename_t)
214#define FSCTL_SET_FSTYPENAME_OVERRIDE IOCBASECMD(FSIOC_SET_FSTYPENAME_OVERRIDE)
215
216#define FSIOC_NAMESPACE_ALLOW_DMG_SNAPSHOT_EVENTS _IOW('A', 11, int32_t)
217#define FSCTL_NAMESPACE_ALLOW_DMG_SNAPSHOT_EVENTS IOCBASECMD(FSIOC_NAMESPACE_ALLOW_DMG_SNAPSHOT_EVENTS)
218
219#define FSIOC_TRACKED_HANDLER_GET _IOW('A', 12, struct namespace_handler_info)
220#define FSCTL_TRACKED_HANDLER_GET IOCBASECMD(FSIOC_TRACKED_HANDLER_GET)
221
222#define FSIOC_SNAPSHOT_HANDLER_GET_EXT _IOW('A', 13, struct namespace_handler_info_ext)
223#define FSCTL_SNAPSHOT_HANDLER_GET_EXT IOCBASECMD(FSIOC_SNAPSHOT_HANDLER_GET_EXT)
224
225//
226// IO commands 14, 15, 16, and 17 are currently unused
227//
b0d623f7
A
228
229//
230// Spotlight and fseventsd use these fsctl()'s to find out
231// the mount time of a volume and the last time it was
232// unmounted. Both HFS and ZFS support these calls.
233//
234// User space code should pass the "_IOC_" macros while the
235// kernel should test for the "_FSCTL_" variant of the macro
236// in its vnop_ioctl function.
237//
238// NOTE: the values for these defines should _not_ be changed
239// or else it will break binary compatibility with mds
240// and fseventsd.
241//
6d2010ae
A
242#define SPOTLIGHT_IOC_GET_MOUNT_TIME _IOR('h', 18, u_int32_t)
243#define SPOTLIGHT_FSCTL_GET_MOUNT_TIME IOCBASECMD(SPOTLIGHT_IOC_GET_MOUNT_TIME)
244#define SPOTLIGHT_IOC_GET_LAST_MTIME _IOR('h', 19, u_int32_t)
245#define SPOTLIGHT_FSCTL_GET_LAST_MTIME IOCBASECMD(SPOTLIGHT_IOC_GET_LAST_MTIME)
b0d623f7
A
246
247
1c79356b
A
248#ifndef KERNEL
249
250#include <sys/cdefs.h>
251
252__BEGIN_DECLS
b0d623f7
A
253
254int fsctl(const char *,unsigned long,void*,unsigned int);
255int ffsctl(int,unsigned long,void*,unsigned int);
256
1c79356b
A
257__END_DECLS
258
259#endif /* !KERNEL */
260#endif /* !_SYS_FSCTL_H_ */