]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/fsctl.h
xnu-6153.121.1.tar.gz
[apple/xnu.git] / bsd / sys / fsctl.h
CommitLineData
1c79356b 1/*
fe8ab488 2 * Copyright (c) 2000-2014 Apple Computer, Inc. All rights reserved.
5d5c5d0d 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
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
0a7de745
A
69#ifndef _SYS_FSCTL_H_
70#define _SYS_FSCTL_H_
1c79356b
A
71
72#include <sys/ioccom.h>
6d2010ae 73#include <sys/mount.h>
1c79356b 74
6d2010ae 75#ifdef XNU_KERNEL_PRIVATE
b0d623f7 76
39236c6e 77/* Userland structs for namespace handler */
6d2010ae
A
78typedef struct user64_namespace_handler_info {
79 user64_addr_t token;
80 user64_addr_t flags;
81 user64_addr_t fdptr;
82} user64_namespace_handler_info;
83
84typedef struct user32_namespace_handler_info {
85 user32_addr_t token;
86 user32_addr_t flags;
87 user32_addr_t fdptr;
88} user32_namespace_handler_info;
89
39236c6e
A
90
91/* Kernel-internal of namespace handler info */
6d2010ae
A
92typedef struct namespace_handler_info {
93 user_addr_t token;
94 user_addr_t flags;
95 user_addr_t fdptr;
96} namespace_handler_info;
97
39236c6e
A
98
99/* Userland structs for extended namespace handler */
6d2010ae
A
100typedef struct user64_namespace_handler_info_ext {
101 user64_addr_t token;
102 user64_addr_t flags;
103 user64_addr_t fdptr;
104 user64_addr_t infoptr;
105} user64_namespace_handler_info_ext;
106
107typedef struct user32_namespace_handler_info_ext {
108 user32_addr_t token;
109 user32_addr_t flags;
110 user32_addr_t fdptr;
111 user32_addr_t infoptr;
112} user32_namespace_handler_info_ext;
113
39236c6e
A
114
115/* Kernel-internal of extended namespace handler */
6d2010ae
A
116typedef struct namespace_handler_info_ext {
117 user_addr_t token;
118 user_addr_t flags;
119 user_addr_t fdptr;
120 user_addr_t infoptr;
121} namespace_handler_info_ext;
122
39236c6e
A
123/* Size-Augmented namespace_handler_info */
124/* 64 bit userland*/
125typedef struct user64_namespace_handler_data {
126 user64_addr_t token;
127 user64_addr_t flags;
128 user64_addr_t fdptr;
129 user64_addr_t infoptr;
130 user64_addr_t objid;
131 user64_addr_t reserved1;
132 user64_addr_t reserved2;
133 user64_addr_t reserved3;
134} user64_namespace_handler_data;
135
136/*32 bit userland*/
137typedef struct user32_namespace_handler_data {
138 user32_addr_t token;
139 user32_addr_t flags;
140 user32_addr_t fdptr;
141 user32_addr_t infoptr;
142 user32_addr_t objid;
143 user32_addr_t reserved1;
144 user32_addr_t reserved2;
145 user32_addr_t reserved3;
146} user32_namespace_handler_data;
147
148/* kernel-internal */
149typedef struct namespace_handler_data {
150 user_addr_t token;
151 user_addr_t flags;
152 user_addr_t fdptr;
153 user_addr_t infoptr;
154 user_addr_t objid;
155 user_addr_t reserved1;
156 user_addr_t reserved2;
157 user_addr_t reserved3;
158} namespace_handler_data;
159
160
6d2010ae 161extern int resolve_nspace_item_ext(struct vnode *vp, uint64_t op, void *arg);
6d2010ae
A
162
163#else
164
165typedef struct namespace_handler_info {
166 int32_t *token;
167 int64_t *flags;
168 int32_t *fdptr;
169} namespace_handler_info;
170
171typedef struct namespace_handler_info_ext {
172 int32_t *token;
173 int64_t *flags;
174 int32_t *fdptr;
175 int64_t *infoptr; // for snapshot write events, the kernel puts an offset/length pair here
176} namespace_handler_info_ext;
177
39236c6e
A
178typedef struct namespace_handler_data {
179 int32_t *token;
180 int64_t *flags;
181 int32_t *fdptr;
182 int64_t *infoptr; // for snapshot write events, the kernel puts an offset/length pair here
183 int64_t *objid;
184 uint32_t *reserved1;
185 uint32_t *reserved2;
186 uint32_t *reserved3;
187} namespace_handler_data;
6d2010ae
A
188
189#endif /* XNU_KERNEL_PRIVATE */
190
39037602
A
191#ifdef KERNEL_PRIVATE
192
193#define NSPACE_REARM_NO_ARG ((void *)1)
194int resolve_nspace_item(struct vnode *vp, uint64_t op);
195int nspace_snapshot_event(vnode_t vp, time_t ctime, uint64_t op_type, void *arg);
196
197#endif // defined(KERNEL_PRIVATE)
198
6d2010ae
A
199#define NAMESPACE_HANDLER_READ_OP 0x0001
200#define NAMESPACE_HANDLER_WRITE_OP 0x0002
201#define NAMESPACE_HANDLER_DELETE_OP 0x0004
202#define NAMESPACE_HANDLER_TRUNCATE_OP 0x0008
203#define NAMESPACE_HANDLER_RENAME_OP 0x0010
204#define NAMESPACE_HANDLER_METADATA_WRITE_OP 0x0020
205#define NAMESPACE_HANDLER_METADATA_DELETE_OP 0x0040
206#define NAMESPACE_HANDLER_METADATA_MOD 0x0080
39236c6e 207// #define NAMESPACE_HANDLER_OP_DO_NOT_USE 0x0100 // SNAPSHOT_EVENT uses this value
6d2010ae 208#define NAMESPACE_HANDLER_LINK_CREATE 0x0200
39236c6e
A
209#define NAMESPACE_HANDLER_RENAME_SUCCESS_OP 0x0400
210#define NAMESPACE_HANDLER_RENAME_FAILED_OP 0x0800
6d2010ae
A
211
212#define NAMESPACE_HANDLER_NSPACE_EVENT 0x1000
213#define NAMESPACE_HANDLER_SNAPSHOT_EVENT 0x0100
214#define NAMESPACE_HANDLER_TRACK_EVENT 0x2000
215
216#define NAMESPACE_HANDLER_EVENT_TYPE_MASK (NAMESPACE_HANDLER_NSPACE_EVENT | NAMESPACE_HANDLER_SNAPSHOT_EVENT | NAMESPACE_HANDLER_TRACK_EVENT)
217
b0d623f7 218
6d2010ae
A
219typedef int32_t nspace_handler_info[2];
220typedef char fstypename_t[MFSTYPENAMELEN];
221
222#ifdef KERNEL
223
224typedef struct user64_package_ext_info {
0a7de745
A
225 user64_addr_t strings;
226 uint32_t num_entries;
227 uint32_t max_width;
6d2010ae
A
228} user64_package_ext_info;
229
230typedef struct user32_package_ext_info {
0a7de745
A
231 user32_addr_t strings;
232 uint32_t num_entries;
233 uint32_t max_width;
6d2010ae
A
234} user32_package_ext_info;
235
236#endif // KERNEL
237
b0d623f7 238typedef struct package_ext_info {
0a7de745
A
239 const char *strings;
240 uint32_t num_entries;
241 uint32_t max_width;
b0d623f7
A
242} package_ext_info;
243
5ba3f43e
A
244/* Disk conditioner configuration */
245typedef struct disk_conditioner_info {
0a7de745
A
246 int enabled;
247 uint64_t access_time_usec; // maximum latency until transfer begins
248 uint64_t read_throughput_mbps; // maximum throughput for reads
249 uint64_t write_throughput_mbps; // maximum throughput for writes
250 int is_ssd; // behave like an SSD
251
252 /* revision 2 */
253 uint32_t ioqueue_depth;
254 uint32_t maxreadcnt;
255 uint32_t maxwritecnt;
256 uint32_t segreadcnt;
257 uint32_t segwritecnt;
5ba3f43e
A
258} disk_conditioner_info;
259
cb323159
A
260/*
261 * BSD flags manipulation arguments.
262 *
263 * This provides a safe way to update the BSD flags field of an inode,
264 * which has some user components as well as some system components.
265 * What it provides is a compare-and-swap operation, whereby the caller
266 * fetches what the expected flags are, computes the new set, and then
267 * provides the old along with the new. If the old that's provided matches
268 * what's actually in the inode, the new value is set. The actual inode
269 * value is returned to the caller, and expected == actual is how the
270 * caller can determine that the operation succeeded.
271 *
272 * Some BSD flags (e.g. UF_COMPRESSED) can only be manipulated via this
273 * safe mechanism.
274 */
275struct fsioc_cas_bsdflags {
276 uint32_t expected_flags; /* [IN] expected flags */
277 uint32_t new_flags; /* [IN] new value to set */
278 uint32_t actual_flags; /* [OUT] the actual flags in inode */
279};
280
0a7de745
A
281#define FSCTL_SYNC_FULLSYNC (1<<0) /* Flush the data fully to disk, if supported by the filesystem */
282#define FSCTL_SYNC_WAIT (1<<1) /* Wait for the sync to complete */
6d2010ae
A
283
284
0a7de745
A
285#define FSIOC_SYNC_VOLUME _IOW('A', 1, uint32_t)
286#define FSCTL_SYNC_VOLUME IOCBASECMD(FSIOC_SYNC_VOLUME)
6d2010ae 287
0a7de745
A
288#define FSIOC_SET_PACKAGE_EXTS _IOW('A', 2, struct package_ext_info)
289#define FSCTL_SET_PACKAGE_EXTS IOCBASECMD(FSIOC_SET_PACKAGE_EXTS)
6d2010ae 290
39236c6e 291/* Unsupported - previously FSIOC_WAIT_FOR_SYNC */
0a7de745 292#define FSIOC_UNSUPPORTED _IOR('A', 3, int32_t)
6d2010ae 293
cb323159
A
294/* 4 - 9 was used for NAMESPACE handler operation to support dataless file faults
295 * no and no longer user */
6d2010ae 296
0a7de745
A
297#define FSIOC_SET_FSTYPENAME_OVERRIDE _IOW('A', 10, fstypename_t)
298#define FSCTL_SET_FSTYPENAME_OVERRIDE IOCBASECMD(FSIOC_SET_FSTYPENAME_OVERRIDE)
6d2010ae 299
fe8ab488 300/* 12 was used for TRACKED_HANDLER_GET which has now been removed
0a7de745 301 * as it is no longer used. */
6d2010ae 302
cb323159 303/* 13 was used for FSIOC_SNAPSHOT_HANDLER_GET_EXT and now been removed */
6d2010ae 304
fe8ab488 305/* 14 was used for NAMESPACE_HANDLER_GETDATA which has now been
0a7de745 306 * removed as it is no longer used. */
39236c6e 307
0a7de745
A
308#define FSIOC_ROUTEFS_SETROUTEID _IO('A', 15)
309#define FSCTL_ROUTEFS_SETROUTEID IOCBASECMD(FSIOC_ROUTEFS_SETROUTEID)
490019cf 310
813fb2f6 311/* ioctls to support SEEK_HOLE SEEK_DATA */
0a7de745
A
312#define FSIOC_FIOSEEKHOLE _IOWR('A', 16, off_t)
313#define FSCTL_FIOSEEKHOLE IOCBASECMD(FSIOC_FIOSEEKHOLE)
314#define FSIOC_FIOSEEKDATA _IOWR('A', 17, off_t)
315#define FSCTL_FIOSEEKDATA IOCBASECMD(FSIOC_FIOSEEKDATA)
813fb2f6 316
5ba3f43e 317/* Disk conditioner */
0a7de745
A
318#define DISK_CONDITIONER_IOC_GET _IOR('A', 18, disk_conditioner_info)
319#define DISK_CONDITIONER_FSCTL_GET IOCBASECMD(DISK_CONDITIONER_IOC_GET)
320#define DISK_CONDITIONER_IOC_SET _IOW('A', 19, disk_conditioner_info)
321#define DISK_CONDITIONER_FSCTL_SET IOCBASECMD(DISK_CONDITIONER_IOC_SET)
322
cb323159
A
323/* Set the value of a file's BSD flags in a safe way. */
324#define FSIOC_CAS_BSDFLAGS _IOWR('A', 20, struct fsioc_cas_bsdflags)
325
0a7de745
A
326/* Check if a file is only open once (pass zero for the extra arg) */
327#define FSIOC_FD_ONLY_OPEN_ONCE _IOWR('A', 21, uint32_t)
b0d623f7
A
328
329//
0a7de745
A
330// Spotlight and fseventsd use these fsctl()'s to find out
331// the mount time of a volume and the last time it was
5ba3f43e 332// unmounted. Both HFS and APFS support these calls.
b0d623f7
A
333//
334// NOTE: the values for these defines should _not_ be changed
335// or else it will break binary compatibility with mds
336// and fseventsd.
337//
0a7de745
A
338#define SPOTLIGHT_IOC_GET_MOUNT_TIME _IOR('h', 18, u_int32_t)
339#define SPOTLIGHT_FSCTL_GET_MOUNT_TIME IOCBASECMD(SPOTLIGHT_IOC_GET_MOUNT_TIME)
340#define SPOTLIGHT_IOC_GET_LAST_MTIME _IOR('h', 19, u_int32_t)
341#define SPOTLIGHT_FSCTL_GET_LAST_MTIME IOCBASECMD(SPOTLIGHT_IOC_GET_LAST_MTIME)
b0d623f7 342
d9a64523 343/* Mark file's extents as "frozen" because someone has references to physical address */
0a7de745
A
344#define FSIOC_FREEZE_EXTENTS _IO('h', 20)
345#define FSCTL_FREEZE_EXTENTS IOCBASECMD(FSIOC_FREEZE_EXTENTS)
d9a64523
A
346
347/* Clear the "frozen" status of file's extents */
0a7de745
A
348#define FSIOC_THAW_EXTENTS _IO('h', 21)
349#define FSCTL_THAW_EXTENTS IOCBASECMD(FSIOC_THAW_EXTENTS)
d9a64523 350
cb323159
A
351/* this FSCTL selector is duplicated in XNU with the intent of making the VFS/generic one the only one eventually */
352#define FIRMLINK_STRUCT_LEN 1032
353typedef struct generic_firmlink {
354 uint8_t array[FIRMLINK_STRUCT_LEN];
355} generic_firmlink_t;
356
357#define FSIOC_FIRMLINK_CTL _IOWR ('J', 60, generic_firmlink_t)
358
1c79356b
A
359#ifndef KERNEL
360
361#include <sys/cdefs.h>
362
363__BEGIN_DECLS
b0d623f7 364
0a7de745
A
365int fsctl(const char *, unsigned long, void*, unsigned int);
366int ffsctl(int, unsigned long, void*, unsigned int);
b0d623f7 367
1c79356b
A
368__END_DECLS
369
370#endif /* !KERNEL */
371#endif /* !_SYS_FSCTL_H_ */