| 1 | /* |
| 2 | * Copyright (c) 2000-2016 Apple Computer, Inc. All rights reserved. |
| 3 | * |
| 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
| 5 | * |
| 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. |
| 14 | * |
| 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 |
| 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
| 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
| 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. |
| 25 | * |
| 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
| 27 | */ |
| 28 | /* |
| 29 | * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved |
| 30 | * Copyright (c) 1992, 1993, 1994, 1995 |
| 31 | * The Regents of the University of California. All rights reserved. |
| 32 | * |
| 33 | * Redistribution and use in source and binary forms, with or without |
| 34 | * modification, are permitted provided that the following conditions |
| 35 | * are met: |
| 36 | * 1. Redistributions of source code must retain the above copyright |
| 37 | * notice, this list of conditions and the following disclaimer. |
| 38 | * 2. Redistributions in binary form must reproduce the above copyright |
| 39 | * notice, this list of conditions and the following disclaimer in the |
| 40 | * documentation and/or other materials provided with the distribution. |
| 41 | * 3. All advertising materials mentioning features or use of this software |
| 42 | * must display the following acknowledgement: |
| 43 | * This product includes software developed by the University of |
| 44 | * California, Berkeley and its contributors. |
| 45 | * 4. Neither the name of the University nor the names of its contributors |
| 46 | * may be used to endorse or promote products derived from this software |
| 47 | * without specific prior written permission. |
| 48 | * |
| 49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS AND |
| 50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 59 | * SUCH DAMAGE. |
| 60 | */ |
| 61 | /* |
| 62 | * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce |
| 63 | * support for mandatory and extensible security protections. This notice |
| 64 | * is included in support of clause 2.2 (b) of the Apple Public License, |
| 65 | * Version 2.0. |
| 66 | */ |
| 67 | |
| 68 | /* |
| 69 | * Warning: This file is generated automatically. |
| 70 | * (Modifications made here may easily be lost!) |
| 71 | * |
| 72 | * Created by the script: |
| 73 | * @(#)vnode_if.sh 8.7 (Berkeley) 5/11/95 |
| 74 | */ |
| 75 | |
| 76 | |
| 77 | #ifndef _SYS_VNODE_IF_H_ |
| 78 | #define _SYS_VNODE_IF_H_ |
| 79 | |
| 80 | #include <sys/appleapiopts.h> |
| 81 | #include <sys/cdefs.h> |
| 82 | #include <sys/kernel_types.h> |
| 83 | #include <sys/buf.h> |
| 84 | #ifdef BSD_KERNEL_PRIVATE |
| 85 | #include <sys/vm.h> |
| 86 | #endif |
| 87 | #include <mach/memory_object_types.h> |
| 88 | |
| 89 | |
| 90 | #ifdef KERNEL |
| 91 | |
| 92 | extern struct vnodeop_desc vnop_default_desc; |
| 93 | extern struct vnodeop_desc vnop_lookup_desc; |
| 94 | #ifdef KERNEL_PRIVATE |
| 95 | extern struct vnodeop_desc vnop_compound_open_desc; |
| 96 | extern struct vnodeop_desc vnop_compound_remove_desc; |
| 97 | extern struct vnodeop_desc vnop_compound_rename_desc; |
| 98 | extern struct vnodeop_desc vnop_compound_mkdir_desc; |
| 99 | extern struct vnodeop_desc vnop_compound_rmdir_desc; |
| 100 | #endif /* KERNEL_PRIVATE */ |
| 101 | extern struct vnodeop_desc vnop_create_desc; |
| 102 | extern struct vnodeop_desc vnop_whiteout_desc; // obsolete |
| 103 | extern struct vnodeop_desc vnop_mknod_desc; |
| 104 | extern struct vnodeop_desc vnop_open_desc; |
| 105 | extern struct vnodeop_desc vnop_close_desc; |
| 106 | extern struct vnodeop_desc vnop_access_desc; |
| 107 | extern struct vnodeop_desc vnop_getattr_desc; |
| 108 | extern struct vnodeop_desc vnop_setattr_desc; |
| 109 | extern struct vnodeop_desc vnop_read_desc; |
| 110 | extern struct vnodeop_desc vnop_write_desc; |
| 111 | extern struct vnodeop_desc vnop_ioctl_desc; |
| 112 | extern struct vnodeop_desc vnop_select_desc; |
| 113 | extern struct vnodeop_desc vnop_exchange_desc; |
| 114 | extern struct vnodeop_desc vnop_revoke_desc; |
| 115 | extern struct vnodeop_desc vnop_mmap_desc; |
| 116 | extern struct vnodeop_desc vnop_mnomap_desc; |
| 117 | extern struct vnodeop_desc vnop_fsync_desc; |
| 118 | extern struct vnodeop_desc vnop_remove_desc; |
| 119 | extern struct vnodeop_desc vnop_link_desc; |
| 120 | extern struct vnodeop_desc vnop_rename_desc; |
| 121 | extern struct vnodeop_desc vnop_renamex_desc; |
| 122 | extern struct vnodeop_desc vnop_mkdir_desc; |
| 123 | extern struct vnodeop_desc vnop_rmdir_desc; |
| 124 | extern struct vnodeop_desc vnop_symlink_desc; |
| 125 | extern struct vnodeop_desc vnop_readdir_desc; |
| 126 | extern struct vnodeop_desc vnop_readdirattr_desc; |
| 127 | extern struct vnodeop_desc vnop_getattrlistbulk_desc; |
| 128 | extern struct vnodeop_desc vnop_readlink_desc; |
| 129 | extern struct vnodeop_desc vnop_inactive_desc; |
| 130 | extern struct vnodeop_desc vnop_reclaim_desc; |
| 131 | extern struct vnodeop_desc vnop_print_desc; |
| 132 | extern struct vnodeop_desc vnop_pathconf_desc; |
| 133 | extern struct vnodeop_desc vnop_advlock_desc; |
| 134 | extern struct vnodeop_desc vnop_truncate_desc; |
| 135 | extern struct vnodeop_desc vnop_allocate_desc; |
| 136 | extern struct vnodeop_desc vnop_pagein_desc; |
| 137 | extern struct vnodeop_desc vnop_pageout_desc; |
| 138 | extern struct vnodeop_desc vnop_searchfs_desc; |
| 139 | extern struct vnodeop_desc vnop_copyfile_desc; |
| 140 | extern struct vnodeop_desc vnop_clonefile_desc; |
| 141 | extern struct vnodeop_desc vnop_blktooff_desc; |
| 142 | extern struct vnodeop_desc vnop_offtoblk_desc; |
| 143 | extern struct vnodeop_desc vnop_blockmap_desc; |
| 144 | extern struct vnodeop_desc vnop_strategy_desc; |
| 145 | extern struct vnodeop_desc vnop_bwrite_desc; |
| 146 | |
| 147 | #ifdef __APPLE_API_UNSTABLE |
| 148 | |
| 149 | #if NAMEDSTREAMS |
| 150 | extern struct vnodeop_desc vnop_getnamedstream_desc; |
| 151 | extern struct vnodeop_desc vnop_makenamedstream_desc; |
| 152 | extern struct vnodeop_desc vnop_removenamedstream_desc; |
| 153 | #endif |
| 154 | |
| 155 | #endif |
| 156 | |
| 157 | #ifdef KERNEL_PRIVATE |
| 158 | /* |
| 159 | * This pair of functions register and unregister callout with |
| 160 | * buffer_cache_gc() code path. This callout enables underlying |
| 161 | * fs to kick off any memory reclamation that would be otherwise |
| 162 | * satisfied by buffer_cache_gc(). callout() will be called in the |
| 163 | * vm_pageout code path, so precautions should be taken to not |
| 164 | * allocate memory or take any locks which might have memory |
| 165 | * allocation behind them. callout() can be called with first parameter |
| 166 | * set to false, in which case memory reclamation should be |
| 167 | * limited in scope. In case of the first parameter set to true, fs |
| 168 | * MUST free some memory if possible. Second parameter to the |
| 169 | * register function will be passed as a second parameter to the |
| 170 | * callout() as is. |
| 171 | * fs_buffer_cache_gc_unregister() second parameter will be used |
| 172 | * to distinguish between same callout() and this parameter should |
| 173 | * match the one passed during registration. It will unregister all |
| 174 | * instances of the matching callout() and argument from the callout |
| 175 | * list. |
| 176 | */ |
| 177 | |
| 178 | |
| 179 | extern int fs_buffer_cache_gc_register(void (* callout)(int, void *), void *); |
| 180 | extern int fs_buffer_cache_gc_unregister(void (* callout)(int, void *), void *); |
| 181 | #endif |
| 182 | |
| 183 | __BEGIN_DECLS |
| 184 | |
| 185 | struct vnop_lookup_args { |
| 186 | struct vnodeop_desc *a_desc; |
| 187 | vnode_t a_dvp; |
| 188 | vnode_t *a_vpp; |
| 189 | struct componentname *a_cnp; |
| 190 | vfs_context_t a_context; |
| 191 | }; |
| 192 | |
| 193 | /*! |
| 194 | @function VNOP_LOOKUP |
| 195 | @abstract Call down to a filesystem to look for a directory entry by name. |
| 196 | @discussion VNOP_LOOKUP is the key pathway through which VFS asks a filesystem to find a file. The vnode |
| 197 | should be returned with an iocount to be dropped by the caller. A VNOP_LOOKUP() calldown can come without |
| 198 | a preceding VNOP_OPEN(). |
| 199 | @param dvp Directory in which to look up file. |
| 200 | @param vpp Destination for found vnode. |
| 201 | @param cnp Structure describing filename to find, reason for lookup, and various other data. |
| 202 | @param ctx Context against which to authenticate lookup request. |
| 203 | @return 0 for success or a filesystem-specific error. |
| 204 | */ |
| 205 | #ifdef XNU_KERNEL_PRIVATE |
| 206 | extern errno_t VNOP_LOOKUP(vnode_t, vnode_t *, struct componentname *, vfs_context_t); |
| 207 | #endif /* XNU_KERNEL_PRIVATE */ |
| 208 | |
| 209 | struct vnop_create_args { |
| 210 | struct vnodeop_desc *a_desc; |
| 211 | vnode_t a_dvp; |
| 212 | vnode_t *a_vpp; |
| 213 | struct componentname *a_cnp; |
| 214 | struct vnode_attr *a_vap; |
| 215 | vfs_context_t a_context; |
| 216 | }; |
| 217 | |
| 218 | /*! |
| 219 | @function VNOP_CREATE |
| 220 | @abstract Call down to a filesystem to create a regular file (VREG). |
| 221 | @discussion If file creation succeeds, "vpp" should be returned with an iocount to be dropped by the caller. |
| 222 | A VNOP_CREATE() calldown can come without a preceding VNOP_OPEN(). |
| 223 | @param dvp Directory in which to create file. |
| 224 | @param vpp Destination for vnode for newly created file. |
| 225 | @param cnp Description of filename to create. |
| 226 | @param vap File creation properties, as seen in vnode_getattr(). Manipulated with VATTR_ISACTIVE, VATTR_RETURN, |
| 227 | VATTR_SET_SUPPORTED, and so forth. |
| 228 | @param ctx Context against which to authenticate file creation. |
| 229 | @return 0 for success or a filesystem-specific error. |
| 230 | */ |
| 231 | #ifdef XNU_KERNEL_PRIVATE |
| 232 | extern errno_t VNOP_CREATE(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t); |
| 233 | #endif /* XNU_KERNEL_PRIVATE */ |
| 234 | |
| 235 | struct vnop_whiteout_args { |
| 236 | struct vnodeop_desc *a_desc; |
| 237 | vnode_t a_dvp; |
| 238 | struct componentname *a_cnp; |
| 239 | int a_flags; |
| 240 | vfs_context_t a_context; |
| 241 | }; |
| 242 | |
| 243 | /*! |
| 244 | @function VNOP_WHITEOUT |
| 245 | @abstract Obsolete - no longer supported. |
| 246 | @discussion Whiteouts are used to support the union filesystem, whereby one filesystem is mounted "transparently" |
| 247 | on top of another. A whiteout in the upper layer of a union mount is a "deletion" of a file in the lower layer; |
| 248 | lookups will catch the whiteout and fail, setting ISWHITEOUT in the componentname structure, even if an underlying |
| 249 | file of the same name exists. The whiteout vnop is used for creation, deletion, and checking whether a directory |
| 250 | supports whiteouts (see flags). |
| 251 | also support the LOOKUP flag, which is used to test whether a directory supports whiteouts. |
| 252 | @param dvp Directory in which to create. |
| 253 | @param cnp Name information for whiteout. |
| 254 | @param flags CREATE: create a whiteout. LOOKUP: check whether a directory supports whiteouts, DELETE: remove a whiteout. |
| 255 | @param ctx Context against which to authenticate whiteout creation. |
| 256 | @return 0 for success or a filesystem-specific error. Returning 0 for LOOKUP indicates that a directory does support whiteouts. |
| 257 | */ |
| 258 | #ifdef XNU_KERNEL_PRIVATE |
| 259 | extern errno_t VNOP_WHITEOUT(vnode_t, struct componentname *, int, vfs_context_t); |
| 260 | #endif /* XNU_KERNEL_PRIVATE */ |
| 261 | |
| 262 | struct vnop_mknod_args { |
| 263 | struct vnodeop_desc *a_desc; |
| 264 | vnode_t a_dvp; |
| 265 | vnode_t *a_vpp; |
| 266 | struct componentname *a_cnp; |
| 267 | struct vnode_attr *a_vap; |
| 268 | vfs_context_t a_context; |
| 269 | }; |
| 270 | |
| 271 | /*! |
| 272 | @function VNOP_MKNOD |
| 273 | @abstract Call down to a filesystem to create a special file. |
| 274 | @discussion The mknod vnop is used to create character and block device files, named pipe (FIFO) files, and named sockets. |
| 275 | The newly created file should be returned with an iocount which will be dropped by the caller. A VNOP_MKNOD() call |
| 276 | can come down without a preceding VNOP_OPEN(). |
| 277 | @param dvp Directory in which to create the special file. |
| 278 | @param vpp Destination for newly created vnode. |
| 279 | @param cnp Name information for new file. |
| 280 | @param vap Attributes for new file, including type. |
| 281 | @param ctx Context against which to authenticate node creation. |
| 282 | @return 0 for success or a filesystem-specific error. |
| 283 | */ |
| 284 | #ifdef XNU_KERNEL_PRIVATE |
| 285 | extern errno_t VNOP_MKNOD(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t); |
| 286 | #endif /* XNU_KERNEL_PRIVATE */ |
| 287 | |
| 288 | struct vnop_open_args { |
| 289 | struct vnodeop_desc *a_desc; |
| 290 | vnode_t a_vp; |
| 291 | int a_mode; |
| 292 | vfs_context_t a_context; |
| 293 | }; |
| 294 | |
| 295 | #ifdef KERNEL_PRIVATE |
| 296 | struct vnop_compound_open_args { |
| 297 | struct vnodeop_desc *a_desc; |
| 298 | |
| 299 | vnode_t a_dvp; /* Directory in which to open/create */ |
| 300 | vnode_t *a_vpp; /* Resulting vnode */ |
| 301 | int a_fmode; /* Open mode */ |
| 302 | struct componentname *a_cnp; /* Path to look up */ |
| 303 | struct vnode_attr *a_vap; /* Attributes with which to create, if appropriate */ |
| 304 | uint32_t a_flags; /* VNOP-control flags */ |
| 305 | uint32_t *a_status; /* Information about results */ |
| 306 | |
| 307 | vfs_context_t a_context; /* Authorization context */ |
| 308 | |
| 309 | int (*a_open_create_authorizer)( /* Authorizer for create case */ |
| 310 | vnode_t dvp, /* Directory in which to create */ |
| 311 | struct componentname *cnp, /* As passed to VNOP */ |
| 312 | struct vnode_attr *vap, /* As passed to VNOP */ |
| 313 | vfs_context_t ctx, /* Context */ |
| 314 | void *reserved); /* Who knows */ |
| 315 | |
| 316 | int (*a_open_existing_authorizer)( /* Authorizer for preexisting case */ |
| 317 | vnode_t vp, /* vp to open */ |
| 318 | struct componentname *cnp, /* Lookup state */ |
| 319 | int fmode, /* As passed to VNOP */ |
| 320 | vfs_context_t ctx, /* Context */ |
| 321 | void *reserved); /* Who knows */ |
| 322 | |
| 323 | void *a_reserved; |
| 324 | }; |
| 325 | |
| 326 | /* Results */ |
| 327 | #define COMPOUND_OPEN_STATUS_DID_CREATE 0x00000001 |
| 328 | #endif /* KERNEL_PRIVATE */ |
| 329 | |
| 330 | /*! |
| 331 | @function VNOP_OPEN |
| 332 | @abstract Call down to a filesystem to open a file. |
| 333 | @discussion The open vnop gives a filesystem a chance to initialize a file for |
| 334 | operations like reading, writing, and ioctls. VFS promises to send down exactly one VNOP_CLOSE() |
| 335 | for each VNOP_OPEN(). |
| 336 | @param vp File to open. |
| 337 | @param mode FREAD and/or FWRITE. |
| 338 | @param ctx Context against which to authenticate open. |
| 339 | @return 0 for success or a filesystem-specific error. |
| 340 | */ |
| 341 | #ifdef XNU_KERNEL_PRIVATE |
| 342 | extern errno_t VNOP_OPEN(vnode_t, int, vfs_context_t); |
| 343 | #endif /* XNU_KERNEL_PRIVATE */ |
| 344 | |
| 345 | #ifdef BSD_KERNEL_PRIVATE |
| 346 | struct nameidata; |
| 347 | extern int VNOP_COMPOUND_OPEN(vnode_t dvp, vnode_t *vpp, struct nameidata *ndp, int32_t flags, int32_t fmode, uint32_t *status, struct vnode_attr *vap, vfs_context_t ctx); |
| 348 | #endif |
| 349 | |
| 350 | struct vnop_close_args { |
| 351 | struct vnodeop_desc *a_desc; |
| 352 | vnode_t a_vp; |
| 353 | int a_fflag; |
| 354 | vfs_context_t a_context; |
| 355 | }; |
| 356 | |
| 357 | /*! |
| 358 | @function VNOP_CLOSE |
| 359 | @abstract Call down to a filesystem to close a file. |
| 360 | @discussion The close vnop gives a filesystem a chance to release state set up |
| 361 | by a VNOP_OPEN(). VFS promises to send down exactly one VNOP_CLOSE() for each VNOP_OPEN(). |
| 362 | @param vp File to close. |
| 363 | @param fflag FREAD and/or FWRITE; in the case of a file opened with open(2), fflag corresponds |
| 364 | to how the file was opened. |
| 365 | @param ctx Context against which to authenticate close. |
| 366 | @return 0 for success or a filesystem-specific error. |
| 367 | */ |
| 368 | #ifdef XNU_KERNEL_PRIVATE |
| 369 | extern errno_t VNOP_CLOSE(vnode_t, int, vfs_context_t); |
| 370 | #endif /* XNU_KERNEL_PRIVATE */ |
| 371 | |
| 372 | struct vnop_access_args { |
| 373 | struct vnodeop_desc *a_desc; |
| 374 | vnode_t a_vp; |
| 375 | int a_action; |
| 376 | vfs_context_t a_context; |
| 377 | }; |
| 378 | |
| 379 | /*! |
| 380 | @function VNOP_ACCESS |
| 381 | @abstract Call down to a filesystem to see if a kauth-style operation is permitted. |
| 382 | @discussion VNOP_ACCESS is currently only called on filesystems which mark themselves |
| 383 | as doing their authentication remotely (vfs_setauthopaque(), vfs_authopaque()). A VNOP_ACCESS() |
| 384 | calldown may come without any preceding VNOP_OPEN(). |
| 385 | @param vp File to authorize action for. |
| 386 | @param action kauth-style action to be checked for permissions, e.g. KAUTH_VNODE_DELETE. |
| 387 | @param ctx Context against which to authenticate action. |
| 388 | @return 0 for success or a filesystem-specific error. |
| 389 | */ |
| 390 | #ifdef XNU_KERNEL_PRIVATE |
| 391 | extern errno_t VNOP_ACCESS(vnode_t, int, vfs_context_t); |
| 392 | #endif /* XNU_KERNEL_PRIVATE */ |
| 393 | |
| 394 | struct vnop_getattr_args { |
| 395 | struct vnodeop_desc *a_desc; |
| 396 | vnode_t a_vp; |
| 397 | struct vnode_attr *a_vap; |
| 398 | vfs_context_t a_context; |
| 399 | }; |
| 400 | |
| 401 | /*! |
| 402 | @function VNOP_GETATTR |
| 403 | @abstract Call down to a filesystem to get vnode attributes. |
| 404 | @discussion Supported attributes ("Yes, I am returning this information") are set with VATTR_SET_SUPPORTED. |
| 405 | Which attributes have been requested is checked with VATTR_IS_ACTIVE. Attributes |
| 406 | are returned with VATTR_RETURN. It is through VNOP_GETATTR that routines like stat() get their information. |
| 407 | A VNOP_GETATTR() calldown may come without any preceding VNOP_OPEN(). |
| 408 | @param vp The vnode whose attributes to get. |
| 409 | @param vap Container for which attributes are requested, which attributes are supported by the filesystem, and attribute values. |
| 410 | @param ctx Context against which to authenticate request for attributes. |
| 411 | @return 0 for success or a filesystem-specific error. VNOP_GETATTR() can return success even if not |
| 412 | all requested attributes were returned; returning an error-value should indicate that something went wrong, rather than that |
| 413 | some attribute is not supported. |
| 414 | */ |
| 415 | #ifdef XNU_KERNEL_PRIVATE |
| 416 | extern errno_t VNOP_GETATTR(vnode_t, struct vnode_attr *, vfs_context_t); |
| 417 | #endif /* XNU_KERNEL_PRIVATE */ |
| 418 | |
| 419 | struct vnop_setattr_args { |
| 420 | struct vnodeop_desc *a_desc; |
| 421 | vnode_t a_vp; |
| 422 | struct vnode_attr *a_vap; |
| 423 | vfs_context_t a_context; |
| 424 | }; |
| 425 | |
| 426 | /*! |
| 427 | @function VNOP_SETATTR |
| 428 | @abstract Call down to a filesystem to set vnode attributes. |
| 429 | @discussion Supported attributes ("Yes, I am setting this attribute.") are set with VATTR_SET_SUPPORTED. |
| 430 | Requested attributes are checked with VATTR_IS_ACTIVE. Attribute values are accessed directly through |
| 431 | structure fields. VNOP_SETATTR() is the core of the KPI function vnode_setattr(), which is used by chmod(), |
| 432 | chown(), truncate(), and many others. A VNOP_SETATTR() call may come without any preceding VNOP_OPEN(). |
| 433 | @param vp The vnode whose attributes to set. |
| 434 | @param vap Container for which attributes are to be set and their desired values, as well as for the filesystem to |
| 435 | return information about which attributes were successfully set. |
| 436 | @param ctx Context against which to authenticate request for attribute change. |
| 437 | @return 0 for success or a filesystem-specific error. VNOP_SETATTR() can return success even if not |
| 438 | all requested attributes were set; returning an error-value should indicate that something went wrong, rather than that |
| 439 | some attribute is not supported. |
| 440 | */ |
| 441 | #ifdef XNU_KERNEL_PRIVATE |
| 442 | extern errno_t VNOP_SETATTR(vnode_t, struct vnode_attr *, vfs_context_t); |
| 443 | #endif /* XNU_KERNEL_PRIVATE */ |
| 444 | |
| 445 | struct vnop_read_args { |
| 446 | struct vnodeop_desc *a_desc; |
| 447 | vnode_t a_vp; |
| 448 | struct uio *a_uio; |
| 449 | int a_ioflag; |
| 450 | vfs_context_t a_context; |
| 451 | }; |
| 452 | |
| 453 | /*! |
| 454 | @function VNOP_READ |
| 455 | @abstract Call down to a filesystem to read file data. |
| 456 | @discussion VNOP_READ() is where the hard work of of the read() system call happens. The filesystem may use |
| 457 | the buffer cache, the cluster layer, or an alternative method to get its data; uio routines will be used to see that data |
| 458 | is copied to the correct virtual address in the correct address space and will update its uio argument |
| 459 | to indicate how much data has been moved. |
| 460 | @param vp The vnode to read from. |
| 461 | @param uio Description of request, including file offset, amount of data requested, destination address for data, |
| 462 | and whether that destination is in kernel or user space. |
| 463 | @param ctx Context against which to authenticate read request. |
| 464 | @return 0 for success or a filesystem-specific error. VNOP_READ() can return success even if less data was |
| 465 | read than originally requested; returning an error value should indicate that something actually went wrong. |
| 466 | */ |
| 467 | extern errno_t VNOP_READ(vnode_t vp, struct uio *uio, int, vfs_context_t ctx); |
| 468 | |
| 469 | struct vnop_write_args { |
| 470 | struct vnodeop_desc *a_desc; |
| 471 | vnode_t a_vp; |
| 472 | struct uio *a_uio; |
| 473 | int a_ioflag; |
| 474 | vfs_context_t a_context; |
| 475 | }; |
| 476 | |
| 477 | /*! |
| 478 | @function VNOP_WRITE |
| 479 | @abstract Call down to the filesystem to write file data. |
| 480 | @discussion VNOP_WRITE() is to write() as VNOP_READ() is to read(). The filesystem may use |
| 481 | the buffer cache, the cluster layer, or an alternative method to write its data; uio routines will be used to see that data |
| 482 | is copied to the correct virtual address in the correct address space and will update its uio argument |
| 483 | to indicate how much data has been moved. |
| 484 | @param vp The vnode to write to. |
| 485 | @param uio Description of request, including file offset, amount of data to write, source address for data, |
| 486 | and whether that destination is in kernel or user space. |
| 487 | @param ctx Context against which to authenticate write request. |
| 488 | @return 0 for success or a filesystem-specific error. VNOP_WRITE() can return success even if less data was |
| 489 | written than originally requested; returning an error value should indicate that something actually went wrong. |
| 490 | */ |
| 491 | extern errno_t VNOP_WRITE(vnode_t vp, struct uio *uio, int ioflag, vfs_context_t ctx); |
| 492 | |
| 493 | struct vnop_ioctl_args { |
| 494 | struct vnodeop_desc *a_desc; |
| 495 | vnode_t a_vp; |
| 496 | u_long a_command; |
| 497 | caddr_t a_data; |
| 498 | int a_fflag; |
| 499 | vfs_context_t a_context; |
| 500 | }; |
| 501 | |
| 502 | /*! |
| 503 | @function VNOP_IOCTL |
| 504 | @abstract Call down to a filesystem or device driver to execute various control operations on or request data about a file. |
| 505 | @discussion Ioctl controls are typically associated with devices, but they can in fact be passed |
| 506 | down for any file; they are used to implement any of a wide range of controls and information requests. |
| 507 | fcntl() calls VNOP_IOCTL for several commands, and will attempt a VNOP_IOCTL if it is passed an unknown command, |
| 508 | though no copyin or copyout of arguments can occur in this case--the "arg" must be an integer value. |
| 509 | Filesystems can define their own fcntls using this mechanism. How ioctl commands are structured |
| 510 | is slightly complicated; see the manual page for ioctl(2). |
| 511 | @param vp The vnode to execute the command on. |
| 512 | @param command Identifier for action to take. |
| 513 | @param data Pointer to data; this can be an integer constant (of 32 bits only) or an address to be read from or written to, |
| 514 | depending on "command." If it is an address, it is valid and resides in the kernel; callers of VNOP_IOCTL() are |
| 515 | responsible for copying to and from userland. |
| 516 | @param ctx Context against which to authenticate ioctl request. |
| 517 | @return 0 for success or a filesystem-specific error. |
| 518 | */ |
| 519 | extern errno_t VNOP_IOCTL(vnode_t vp, u_long command, caddr_t data, int fflag, vfs_context_t ctx); |
| 520 | |
| 521 | struct vnop_select_args { |
| 522 | struct vnodeop_desc *a_desc; |
| 523 | vnode_t a_vp; |
| 524 | int a_which; |
| 525 | int a_fflags; |
| 526 | void *a_wql; |
| 527 | vfs_context_t a_context; |
| 528 | }; |
| 529 | |
| 530 | /*! |
| 531 | @function VNOP_SELECT |
| 532 | @abstract Call down to a filesystem or device to check if a file is ready for I/O and request later notification if it is not currently ready. |
| 533 | @discussion In general, regular are always "ready for I/O" and their select vnops simply return "1." |
| 534 | Devices, though, may or may not be read; they keep track of who is selecting on them and send notifications |
| 535 | when they become ready. xnu provides structures and routines for tracking threads waiting for I/O and waking up |
| 536 | those threads: see selrecord(), selthreadclear(), seltrue(), selwait(), selwakeup(), and the selinfo structure (sys/select.h). |
| 537 | @param vp The vnode to check for I/O readiness. |
| 538 | @param which What kind of I/O is desired: FREAD, FWRITE. |
| 539 | @param fflags Flags from fileglob as seen in fcntl.h, e.g. O_NONBLOCK, O_APPEND. |
| 540 | @param wql Opaque object to pass to selrecord(). |
| 541 | @param ctx Context to authenticate for select request. |
| 542 | @return Nonzero indicates that a file is ready for I/O. 0 indicates that the file is not ready for I/O; |
| 543 | there is no way to return an error. 0 should be returned if the device (or file) is not ready for I/O |
| 544 | and the driver (or filesystem) is going to track the request and provide subsequent wakeups. |
| 545 | the device (or filesystem) will provide a wakeup. |
| 546 | */ |
| 547 | #ifdef XNU_KERNEL_PRIVATE |
| 548 | extern errno_t VNOP_SELECT(vnode_t, int, int, void *, vfs_context_t); |
| 549 | #endif /* XNU_KERNEL_PRIVATE */ |
| 550 | |
| 551 | struct vnop_exchange_args { |
| 552 | struct vnodeop_desc *a_desc; |
| 553 | vnode_t a_fvp; |
| 554 | vnode_t a_tvp; |
| 555 | int a_options; |
| 556 | vfs_context_t a_context; |
| 557 | }; |
| 558 | |
| 559 | /*! |
| 560 | @function VNOP_EXCHANGE |
| 561 | @abstract Call down to a filesystem to atomically exchange the data of two files. |
| 562 | @discussion VNOP_EXCHANGE() is currently only called by the exchangedata() system call. It will only |
| 563 | be applied to files on the same volume. |
| 564 | @param fvp First vnode. |
| 565 | @param tvp Second vnode. |
| 566 | @param options Unused. |
| 567 | @param ctx Context to authenticate for exchangedata request. |
| 568 | @return 0 for success, else an error code. |
| 569 | */ |
| 570 | #ifdef XNU_KERNEL_PRIVATE |
| 571 | extern errno_t VNOP_EXCHANGE(vnode_t, vnode_t, int, vfs_context_t); |
| 572 | #endif /* XNU_KERNEL_PRIVATE */ |
| 573 | |
| 574 | struct vnop_revoke_args { |
| 575 | struct vnodeop_desc *a_desc; |
| 576 | vnode_t a_vp; |
| 577 | int a_flags; |
| 578 | vfs_context_t a_context; |
| 579 | }; |
| 580 | |
| 581 | /*! |
| 582 | @function VNOP_REVOKE |
| 583 | @abstract Call down to a filesystem to invalidate all open file descriptors for a vnode. |
| 584 | @discussion This function is typically called as part of a TTY revoke, but can also be |
| 585 | used on regular files. Most filesystems simply use nop_revoke(), which calls vn_revoke(), |
| 586 | as their revoke vnop implementation. |
| 587 | @param vp The vnode to revoke. |
| 588 | @param flags Unused. |
| 589 | @param ctx Context to authenticate for revoke request. |
| 590 | @return 0 for success, else an error code. |
| 591 | */ |
| 592 | #ifdef XNU_KERNEL_PRIVATE |
| 593 | extern errno_t VNOP_REVOKE(vnode_t, int, vfs_context_t); |
| 594 | #endif /* XNU_KERNEL_PRIVATE */ |
| 595 | |
| 596 | struct vnop_mmap_args { |
| 597 | struct vnodeop_desc *a_desc; |
| 598 | vnode_t a_vp; |
| 599 | int a_fflags; |
| 600 | vfs_context_t a_context; |
| 601 | }; |
| 602 | |
| 603 | /*! |
| 604 | @function VNOP_MMAP |
| 605 | @abstract Notify a filesystem that a file is being mmap-ed. |
| 606 | @discussion VNOP_MMAP is an advisory calldown to say that the system is mmap-ing a file. |
| 607 | @param vp The vnode being mmapped. |
| 608 | @param flags Memory protection: PROT_READ, PROT_WRITE, PROT_EXEC. |
| 609 | @param ctx Context to authenticate for mmap request. |
| 610 | @return 0 for success; all errors except EPERM are ignored. |
| 611 | */ |
| 612 | #ifdef XNU_KERNEL_PRIVATE |
| 613 | extern errno_t VNOP_MMAP(vnode_t, int, vfs_context_t); |
| 614 | #endif /* XNU_KERNEL_PRIVATE */ |
| 615 | |
| 616 | struct vnop_mnomap_args { |
| 617 | struct vnodeop_desc *a_desc; |
| 618 | vnode_t a_vp; |
| 619 | vfs_context_t a_context; |
| 620 | }; |
| 621 | |
| 622 | /*! |
| 623 | @function VNOP_MNOMAP |
| 624 | @abstract Inform a filesystem that a file is no longer mapped. |
| 625 | @discussion In general, no action is required of a filesystem for VNOP_MNOMAP. |
| 626 | @param vp The vnode which is no longer mapped. |
| 627 | @param ctx Context to authenticate for mnomap request. |
| 628 | @return Return value is ignored. |
| 629 | */ |
| 630 | #ifdef XNU_KERNEL_PRIVATE |
| 631 | extern errno_t VNOP_MNOMAP(vnode_t, vfs_context_t); |
| 632 | #endif /* XNU_KERNEL_PRIVATE */ |
| 633 | |
| 634 | struct vnop_fsync_args { |
| 635 | struct vnodeop_desc *a_desc; |
| 636 | vnode_t a_vp; |
| 637 | int a_waitfor; |
| 638 | vfs_context_t a_context; |
| 639 | }; |
| 640 | |
| 641 | /*! |
| 642 | @function VNOP_FSYNC |
| 643 | @abstract Call down to a filesystem to synchronize a file with on-disk state. |
| 644 | @discussion VNOP_FSYNC is called whenever we need to make sure that a file's data has been |
| 645 | pushed to backing store, for example when recycling; it is also the heart of the fsync() system call. |
| 646 | @param vp The vnode whose data to flush to backing store. |
| 647 | @param ctx Context to authenticate for fsync request. |
| 648 | @return 0 for success, else an error code. |
| 649 | */ |
| 650 | extern errno_t VNOP_FSYNC(vnode_t vp, int waitfor, vfs_context_t ctx); |
| 651 | |
| 652 | struct vnop_remove_args { |
| 653 | struct vnodeop_desc *a_desc; |
| 654 | vnode_t a_dvp; |
| 655 | vnode_t a_vp; |
| 656 | struct componentname *a_cnp; |
| 657 | int a_flags; |
| 658 | vfs_context_t a_context; |
| 659 | }; |
| 660 | |
| 661 | /*! |
| 662 | @function VNOP_REMOVE |
| 663 | @abstract Call down to a filesystem to delete a file. |
| 664 | @discussion VNOP_REMOVE is called to remove a file from a filesystem's namespace, for example by unlink(). |
| 665 | It can operate on regular files, named pipes, special files, and in some cases on directories. |
| 666 | @param dvp Directory in which to delete a file. |
| 667 | @param vp The file to delete. |
| 668 | @param cnp Filename information. |
| 669 | @param ctx Context to authenticate for fsync request. |
| 670 | @return 0 for success, else an error code. |
| 671 | */ |
| 672 | #ifdef XNU_KERNEL_PRIVATE |
| 673 | extern errno_t VNOP_REMOVE(vnode_t, vnode_t, struct componentname *, int, vfs_context_t); |
| 674 | #endif /* XNU_KERNEL_PRIVATE */ |
| 675 | |
| 676 | #ifdef KERNEL_PRIVATE |
| 677 | struct vnop_compound_remove_args { |
| 678 | struct vnodeop_desc *a_desc; |
| 679 | vnode_t a_dvp; /* Directory in which to lookup and remove */ |
| 680 | vnode_t *a_vpp; /* File to remove; may or may not point to NULL pointer */ |
| 681 | struct componentname *a_cnp; /* Name of file to remove */ |
| 682 | struct vnode_attr *a_vap; /* Destination for file attributes on successful delete */ |
| 683 | uint32_t a_flags; /* Control flags (unused) */ |
| 684 | vfs_context_t a_context; /* Authorization context */ |
| 685 | int (*a_remove_authorizer)( /* Authorizer callback */ |
| 686 | vnode_t dvp, /* Directory in which to delete */ |
| 687 | vnode_t vp, /* File to delete */ |
| 688 | struct componentname *cnp, /* As passed to VNOP */ |
| 689 | vfs_context_t ctx, /* As passed to VNOP */ |
| 690 | void *reserved); /* Always NULL */ |
| 691 | void *a_reserved; /* Unused */ |
| 692 | }; |
| 693 | #endif /* KERNEL_PRIVATE */ |
| 694 | |
| 695 | #ifdef BSD_KERNEL_PRIVATE |
| 696 | extern errno_t VNOP_COMPOUND_REMOVE(vnode_t, vnode_t*, struct nameidata *, int32_t flags, struct vnode_attr *vap, vfs_context_t); |
| 697 | #endif |
| 698 | struct vnop_link_args { |
| 699 | struct vnodeop_desc *a_desc; |
| 700 | vnode_t a_vp; |
| 701 | vnode_t a_tdvp; |
| 702 | struct componentname *a_cnp; |
| 703 | vfs_context_t a_context; |
| 704 | }; |
| 705 | |
| 706 | /*! |
| 707 | @function VNOP_LINK |
| 708 | @abstract Call down to a filesystem to create a hardlink to a file. |
| 709 | @discussion See "man 2 link". |
| 710 | @param vp File to link to. |
| 711 | @param dvp Directory in which to create the link. |
| 712 | @param cnp Filename information for new link. |
| 713 | @param ctx Context to authenticate for link request. |
| 714 | @return 0 for success, else an error code. |
| 715 | */ |
| 716 | #ifdef XNU_KERNEL_PRIVATE |
| 717 | extern errno_t VNOP_LINK(vnode_t, vnode_t, struct componentname *, vfs_context_t); |
| 718 | #endif /* XNU_KERNEL_PRIVATE */ |
| 719 | |
| 720 | struct vnop_rename_args { |
| 721 | struct vnodeop_desc *a_desc; |
| 722 | vnode_t a_fdvp; |
| 723 | vnode_t a_fvp; |
| 724 | struct componentname *a_fcnp; |
| 725 | vnode_t a_tdvp; |
| 726 | vnode_t a_tvp; |
| 727 | struct componentname *a_tcnp; |
| 728 | vfs_context_t a_context; |
| 729 | }; |
| 730 | |
| 731 | /*! |
| 732 | @function VNOP_RENAME |
| 733 | @abstract Call down to a filesystem to rename a file. |
| 734 | @discussion VNOP_RENAME() will only be called with a source and target on the same volume. |
| 735 | @param fdvp Directory in which source file resides. |
| 736 | @param fvp File being renamed. |
| 737 | @param fcnp Name information for source file. |
| 738 | @param tdvp Directory file is being moved to. |
| 739 | @param tvp Existing file with same name as target, should one exist. |
| 740 | @param tcnp Name information for target path. |
| 741 | @param ctx Context to authenticate for rename request. |
| 742 | @return 0 for success, else an error code. |
| 743 | */ |
| 744 | #ifdef XNU_KERNEL_PRIVATE |
| 745 | extern errno_t VNOP_RENAME(vnode_t, vnode_t, struct componentname *, vnode_t, vnode_t, struct componentname *, vfs_context_t); |
| 746 | #endif /* XNU_KERNEL_PRIVATE */ |
| 747 | |
| 748 | typedef unsigned int vfs_rename_flags_t; |
| 749 | |
| 750 | // Must match sys/stdio.h |
| 751 | enum { |
| 752 | VFS_RENAME_SECLUDE = 0x00000001, |
| 753 | VFS_RENAME_SWAP = 0x00000002, |
| 754 | VFS_RENAME_EXCL = 0x00000004, |
| 755 | |
| 756 | VFS_RENAME_FLAGS_MASK = (VFS_RENAME_SECLUDE | VFS_RENAME_SWAP |
| 757 | | VFS_RENAME_EXCL), |
| 758 | }; |
| 759 | |
| 760 | struct vnop_renamex_args { |
| 761 | struct vnodeop_desc *a_desc; |
| 762 | vnode_t a_fdvp; |
| 763 | vnode_t a_fvp; |
| 764 | struct componentname *a_fcnp; |
| 765 | vnode_t a_tdvp; |
| 766 | vnode_t a_tvp; |
| 767 | struct componentname *a_tcnp; |
| 768 | struct vnode_attr *a_vap; // Reserved for future use |
| 769 | vfs_rename_flags_t a_flags; |
| 770 | vfs_context_t a_context; |
| 771 | }; |
| 772 | |
| 773 | /*! |
| 774 | @function VNOP_RENAMEX |
| 775 | @abstract Call down to a filesystem to rename a file. |
| 776 | @discussion VNOP_RENAMEX() will only be called with a source and target on the same volume. |
| 777 | @param fdvp Directory in which source file resides. |
| 778 | @param fvp File being renamed. |
| 779 | @param fcnp Name information for source file. |
| 780 | @param tdvp Directory file is being moved to. |
| 781 | @param tvp Existing file with same name as target, should one exist. |
| 782 | @param tcnp Name information for target path. |
| 783 | @param flags Control certain rename semantics. |
| 784 | @param ctx Context to authenticate for rename request. |
| 785 | @return 0 for success, else an error code. |
| 786 | */ |
| 787 | #ifdef XNU_KERNEL_PRIVATE |
| 788 | extern errno_t VNOP_RENAMEX(vnode_t, vnode_t, struct componentname *, vnode_t, vnode_t, struct componentname *, vfs_rename_flags_t, vfs_context_t); |
| 789 | #endif /* XNU_KERNEL_PRIVATE */ |
| 790 | |
| 791 | #ifdef KERNEL_PRIVATE |
| 792 | struct vnop_compound_rename_args { |
| 793 | struct vnodeop_desc *a_desc; |
| 794 | |
| 795 | vnode_t a_fdvp; /* Directory from which to rename */ |
| 796 | vnode_t *a_fvpp; /* Vnode to rename (can point to a NULL pointer) */ |
| 797 | struct componentname *a_fcnp; /* Source name */ |
| 798 | struct vnode_attr *a_fvap; |
| 799 | |
| 800 | vnode_t a_tdvp; /* Directory to which to rename */ |
| 801 | vnode_t *a_tvpp; /* Vnode to rename over (can point to a NULL pointer) */ |
| 802 | struct componentname *a_tcnp; /* Destination name */ |
| 803 | struct vnode_attr *a_tvap; |
| 804 | |
| 805 | uint32_t a_flags; /* Control flags: currently unused */ |
| 806 | vfs_context_t a_context; /* Authorization context */ |
| 807 | int (*a_rename_authorizer)( /* Authorization callback */ |
| 808 | vnode_t fdvp, /* As passed to VNOP */ |
| 809 | vnode_t fvp, /* Vnode to rename */ |
| 810 | struct componentname *fcnp, /* As passed to VNOP */ |
| 811 | vnode_t tdvp, /* As passed to VNOP */ |
| 812 | vnode_t tvp, /* Vnode to rename over (can be NULL) */ |
| 813 | struct componentname *tcnp, /* As passed to VNOP */ |
| 814 | vfs_context_t ctx, /* As passed to VNOP */ |
| 815 | void *reserved); /* Always NULL */ |
| 816 | void *a_reserved; /* Currently unused */ |
| 817 | }; |
| 818 | #endif /* KERNEL_PRIVATE */ |
| 819 | |
| 820 | #ifdef XNU_KERNEL_PRIVATE |
| 821 | errno_t |
| 822 | VNOP_COMPOUND_RENAME( |
| 823 | struct vnode *fdvp, struct vnode **fvpp, struct componentname *fcnp, struct vnode_attr *fvap, |
| 824 | struct vnode *tdvp, struct vnode **tvpp, struct componentname *tcnp, struct vnode_attr *tvap, |
| 825 | uint32_t flags,vfs_context_t ctx); |
| 826 | #endif /* XNU_KERNEL_PRIVATE */ |
| 827 | |
| 828 | struct vnop_mkdir_args { |
| 829 | struct vnodeop_desc *a_desc; |
| 830 | vnode_t a_dvp; |
| 831 | vnode_t *a_vpp; |
| 832 | struct componentname *a_cnp; |
| 833 | struct vnode_attr *a_vap; |
| 834 | vfs_context_t a_context; |
| 835 | }; |
| 836 | |
| 837 | /*! |
| 838 | @function VNOP_MKDIR |
| 839 | @abstract Call down to a filesystem to create a directory. |
| 840 | @discussion The newly created directory should be returned with an iocount which will be dropped by the caller. |
| 841 | @param dvp Directory in which to create new directory. |
| 842 | @param vpp Destination for pointer to new directory's vnode. |
| 843 | @param cnp Name information for new directory. |
| 844 | @param vap Attributes for new directory. |
| 845 | @param ctx Context to authenticate for mkdir request. |
| 846 | @return 0 for success, else an error code. |
| 847 | */ |
| 848 | #ifdef XNU_KERNEL_PRIVATE |
| 849 | extern errno_t VNOP_MKDIR(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t); |
| 850 | #endif /* XNU_KERNEL_PRIVATE */ |
| 851 | |
| 852 | |
| 853 | #ifdef KERNEL_PRIVATE |
| 854 | struct vnop_compound_mkdir_args { |
| 855 | struct vnodeop_desc *a_desc; |
| 856 | vnode_t a_dvp; /* Directory in which to create */ |
| 857 | vnode_t *a_vpp; /* Destination for found or created vnode */ |
| 858 | struct componentname *a_cnp; /* Name of directory to create */ |
| 859 | struct vnode_attr *a_vap; /* Creation attributes */ |
| 860 | uint32_t a_flags; /* Control flags (unused) */ |
| 861 | vfs_context_t a_context; /* Authorization context */ |
| 862 | #if 0 |
| 863 | int (*a_mkdir_authorizer)(vnode_t dvp, struct componentname *cnp, struct vnode_attr *vap, vfs_context_t ctx, void *reserved); |
| 864 | #endif /* 0 */ |
| 865 | void *a_reserved; /* Unused */ |
| 866 | }; |
| 867 | #endif /* KERNEL_PRIVATE */ |
| 868 | |
| 869 | #ifdef XNU_KERNEL_PRIVATE |
| 870 | extern errno_t VNOP_COMPOUND_MKDIR(vnode_t, vnode_t *, struct nameidata *, struct vnode_attr *, vfs_context_t); |
| 871 | #endif /* XNU_KERNEL_PRIVATE */ |
| 872 | |
| 873 | struct vnop_rmdir_args { |
| 874 | struct vnodeop_desc *a_desc; |
| 875 | vnode_t a_dvp; |
| 876 | vnode_t a_vp; |
| 877 | struct componentname *a_cnp; |
| 878 | vfs_context_t a_context; |
| 879 | }; |
| 880 | |
| 881 | /*! |
| 882 | @function VNOP_RMDIR |
| 883 | @abstract Call down to a filesystem to delete a directory. |
| 884 | @param dvp Parent of directory to be removed. |
| 885 | @param vp Directory to remove. |
| 886 | @param cnp Name information for directory to be deleted. |
| 887 | @param ctx Context to authenticate for rmdir request. |
| 888 | @return 0 for success, else an error code. |
| 889 | */ |
| 890 | #ifdef XNU_KERNEL_PRIVATE |
| 891 | extern errno_t VNOP_RMDIR(vnode_t, vnode_t, struct componentname *, vfs_context_t); |
| 892 | #endif /* XNU_KERNEL_PRIVATE */ |
| 893 | |
| 894 | #ifdef KERNEL_PRIVATE |
| 895 | struct vnop_compound_rmdir_args { |
| 896 | struct vnodeop_desc *a_desc; |
| 897 | vnode_t a_dvp; /* Directory in which to look up and delete */ |
| 898 | vnode_t *a_vpp; /* Destination for found vnode */ |
| 899 | struct componentname *a_cnp; /* Name to delete */ |
| 900 | struct vnode_attr *a_vap; /* Location in which to store attributes if delete succeeds (can be NULL) */ |
| 901 | uint32_t a_flags; /* Control flags (currently unused) */ |
| 902 | vfs_context_t a_context; /* Context for authorization */ |
| 903 | int (*a_rmdir_authorizer)( /* Authorization callback */ |
| 904 | vnode_t dvp, /* As passed to VNOP */ |
| 905 | vnode_t vp, /* Directory to delete */ |
| 906 | struct componentname *cnp, /* As passed to VNOP */ |
| 907 | vfs_context_t ctx, /* As passed to VNOP */ |
| 908 | void *reserved); /* Always NULL */ |
| 909 | void *a_reserved; /* Unused */ |
| 910 | }; |
| 911 | #endif /* KERNEL_PRIVATE */ |
| 912 | |
| 913 | #ifdef XNU_KERNEL_PRIVATE |
| 914 | extern errno_t VNOP_COMPOUND_RMDIR(vnode_t, vnode_t*, struct nameidata *, struct vnode_attr *vap, vfs_context_t); |
| 915 | #endif /* XNU_KERNEL_PRIVATE */ |
| 916 | |
| 917 | |
| 918 | struct vnop_symlink_args { |
| 919 | struct vnodeop_desc *a_desc; |
| 920 | vnode_t a_dvp; |
| 921 | vnode_t *a_vpp; |
| 922 | struct componentname *a_cnp; |
| 923 | struct vnode_attr *a_vap; |
| 924 | char *a_target; |
| 925 | vfs_context_t a_context; |
| 926 | }; |
| 927 | |
| 928 | /*! |
| 929 | @function VNOP_SYMLINK |
| 930 | @abstract Call down to a filesystem to create a symbolic link. |
| 931 | @param If VNOP_SYMLINK() is successful, the new file should be returned with an iocount which will |
| 932 | be dropped by the caller. VFS does not ensure that the target path will have a length shorter |
| 933 | than the max symlink length for the filesystem. |
| 934 | @param dvp Parent directory for new symlink file. |
| 935 | @param vpp |
| 936 | @param cnp Name information for new symlink. |
| 937 | @param vap Attributes for symlink. |
| 938 | @param target Path for symlink to store; for "ln -s /var/vardir linktovardir", "target" would be "/var/vardir" |
| 939 | @param ctx Context to authenticate for symlink request. |
| 940 | @return 0 for success, else an error code. |
| 941 | */ |
| 942 | #ifdef XNU_KERNEL_PRIVATE |
| 943 | extern errno_t VNOP_SYMLINK(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, char *, vfs_context_t); |
| 944 | #endif /* XNU_KERNEL_PRIVATE */ |
| 945 | |
| 946 | /* |
| 947 | * |
| 948 | * When VNOP_READDIR is called from the NFS Server, the nfs_data |
| 949 | * argument is non-NULL. |
| 950 | * |
| 951 | * The value of nfs_eofflag should be set to TRUE if the end of |
| 952 | * the directory was reached while reading. |
| 953 | * |
| 954 | * The directory seek offset (cookies) are returned to the NFS client and |
| 955 | * may be used later to restart a directory read part way through |
| 956 | * the directory. There is one cookie returned for each directory |
| 957 | * entry returned and its size is determince from nfs_sizeofcookie. |
| 958 | * The value of the cookie should be the logical offset within the |
| 959 | * directory where the on-disc version of the appropriate directory |
| 960 | * entry starts. Memory for the cookies is allocated from M_TEMP |
| 961 | * and it is freed by the caller of VNOP_READDIR. |
| 962 | * |
| 963 | */ |
| 964 | |
| 965 | struct vnop_readdir_args { |
| 966 | struct vnodeop_desc *a_desc; |
| 967 | vnode_t a_vp; |
| 968 | struct uio *a_uio; |
| 969 | int a_flags; |
| 970 | int *a_eofflag; |
| 971 | int *a_numdirent; |
| 972 | vfs_context_t a_context; |
| 973 | }; |
| 974 | |
| 975 | /*! |
| 976 | @function VNOP_READDIR |
| 977 | @abstract Call down to a filesystem to enumerate directory entries. |
| 978 | @discussion VNOP_READDIR() packs a buffer with "struct dirent" directory entry representations as described |
| 979 | by the "getdirentries" manual page. |
| 980 | @param vp Directory to enumerate. |
| 981 | @param uio Destination information for resulting direntries. |
| 982 | @param flags VNODE_READDIR_EXTENDED, VNODE_READDIR_REQSEEKOFF, VNODE_READDIR_SEEKOFF32: Apple-internal flags. |
| 983 | @param eofflag Should be set to 1 if the end of the directory has been reached. |
| 984 | @param numdirent Should be set to number of entries written into buffer. |
| 985 | @param ctx Context to authenticate for readdir request. |
| 986 | @return 0 for success, else an error code. |
| 987 | */ |
| 988 | #ifdef XNU_KERNEL_PRIVATE |
| 989 | extern errno_t VNOP_READDIR(vnode_t, struct uio *, int, int *, int *, vfs_context_t); |
| 990 | #endif /* XNU_KERNEL_PRIVATE */ |
| 991 | |
| 992 | struct vnop_readdirattr_args { |
| 993 | struct vnodeop_desc *a_desc; |
| 994 | vnode_t a_vp; |
| 995 | struct attrlist *a_alist; |
| 996 | struct uio *a_uio; |
| 997 | uint32_t a_maxcount; |
| 998 | uint32_t a_options; |
| 999 | uint32_t *a_newstate; |
| 1000 | int *a_eofflag; |
| 1001 | uint32_t *a_actualcount; |
| 1002 | vfs_context_t a_context; |
| 1003 | }; |
| 1004 | |
| 1005 | /*! |
| 1006 | @function VNOP_READDIRATTR |
| 1007 | @abstract Call down to get file attributes for many files in a directory at once. |
| 1008 | @discussion VNOP_READDIRATTR() packs a buffer with file attributes, as if the results of many "getattrlist" calls. |
| 1009 | @param vp Directory in which to enumerate entries' attributes. |
| 1010 | @param alist Which attributes are wanted for each directory entry. |
| 1011 | @param uio Destination information for resulting attributes. |
| 1012 | @param maxcount Maximum count of files to get attributes for. |
| 1013 | @param options FSOPT_NOFOLLOW: do not follow symbolic links. FSOPT_NOINMEMUPDATE: do not use data which have been |
| 1014 | updated since an inode was loaded into memory. |
| 1015 | @param newstate The "newstate" should be set to a value which changes if the contents of a directory change |
| 1016 | through an addition or deletion but stays the same otherwise. |
| 1017 | @param eofflag Should be set to 1 if the end of the directory has been reached. |
| 1018 | @param actualcount Should be set to number of files whose attributes were written into buffer. |
| 1019 | @param ctx Context to authenticate for readdirattr request. |
| 1020 | @return 0 for success, else an error code. |
| 1021 | */ |
| 1022 | #ifdef XNU_KERNEL_PRIVATE |
| 1023 | extern errno_t VNOP_READDIRATTR(vnode_t, struct attrlist *, struct uio *, uint32_t, uint32_t, uint32_t *, int *, uint32_t *, vfs_context_t); |
| 1024 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1025 | |
| 1026 | struct vnop_getattrlistbulk_args { |
| 1027 | struct vnodeop_desc *a_desc; |
| 1028 | vnode_t a_vp; |
| 1029 | struct attrlist *a_alist; |
| 1030 | struct vnode_attr *a_vap; |
| 1031 | struct uio *a_uio; |
| 1032 | void *a_private; |
| 1033 | uint64_t a_options; |
| 1034 | int32_t *a_eofflag; |
| 1035 | int32_t *a_actualcount; |
| 1036 | vfs_context_t a_context; |
| 1037 | }; |
| 1038 | |
| 1039 | /*! |
| 1040 | @function VNOP_GETATTRLISTBULK |
| 1041 | @abstract Call down to get file attributes for many files in a directory at once. |
| 1042 | @discussion VNOP_GETATTRLISTBULK() packs a buffer with file attributes, as if the results of many "getattrlist" calls. |
| 1043 | @param vp Directory in which to enumerate entries' attributes. |
| 1044 | @param alist Which attributes are wanted for each directory entry. |
| 1045 | @param uio Destination information for resulting attributes. |
| 1046 | @param vap initialised vnode_attr structure pointer. This structure also has memory allocated (MAXPATHLEN bytes) and assigned to the va_name field for filesystems to use. |
| 1047 | @param private reserved for future use. |
| 1048 | @param options |
| 1049 | @param eofflag Should be set to 1 if the end of the directory has been reached. |
| 1050 | @param actualcount Should be set to number of files whose attributes were written into buffer. |
| 1051 | @param ctx Context to authenticate for getattrlistbulk request. |
| 1052 | @return 0 for success, else an error code. |
| 1053 | */ |
| 1054 | #ifdef XNU_KERNEL_PRIVATE |
| 1055 | extern errno_t VNOP_GETATTRLISTBULK(vnode_t, struct attrlist *, struct vnode_attr *, uio_t, void *, uint64_t, int32_t *, int32_t *, vfs_context_t); |
| 1056 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1057 | |
| 1058 | struct vnop_readlink_args { |
| 1059 | struct vnodeop_desc *a_desc; |
| 1060 | vnode_t a_vp; |
| 1061 | struct uio *a_uio; |
| 1062 | vfs_context_t a_context; |
| 1063 | }; |
| 1064 | |
| 1065 | /*! |
| 1066 | @function VNOP_READLINK |
| 1067 | @abstract Call down to a filesystem to get the pathname represented by a symbolic link. |
| 1068 | @discussion VNOP_READLINK() gets the path stored in a symbolic link; it is called by namei() and the readlink() system call. |
| 1069 | @param vp Symbolic link to read from. |
| 1070 | @param uio Destination information for link path. |
| 1071 | @param ctx Context to authenticate for readlink request. |
| 1072 | @return 0 for success, else an error code. |
| 1073 | */ |
| 1074 | #ifdef XNU_KERNEL_PRIVATE |
| 1075 | extern errno_t VNOP_READLINK(vnode_t, struct uio *, vfs_context_t); |
| 1076 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1077 | |
| 1078 | struct vnop_inactive_args { |
| 1079 | struct vnodeop_desc *a_desc; |
| 1080 | vnode_t a_vp; |
| 1081 | vfs_context_t a_context; |
| 1082 | }; |
| 1083 | |
| 1084 | /*! |
| 1085 | @function VNOP_INACTIVE |
| 1086 | @abstract Notify a filesystem that the last usecount (persistent reference) on a vnode has been dropped. |
| 1087 | @discussion VNOP_INACTVE() gives a filesystem a chance to aggressively release resources assocated with a vnode, perhaps |
| 1088 | even to call vnode_recycle(), but no action is prescribed; it is acceptable for VNOP_INACTIVE to be a no-op and |
| 1089 | to defer all reclamation until VNOP_RECLAIM(). |
| 1090 | VNOP_INACTVE() will not be called on a vnode if no persistent reference is ever taken; an |
| 1091 | important example is a stat(), which takes an iocount, reads its data, and drops that iocount. |
| 1092 | @param vp The vnode which is now inactive. |
| 1093 | @param ctx Context to authenticate for inactive message. |
| 1094 | @return 0 for success, else an error code, but return value is currently ignored. |
| 1095 | */ |
| 1096 | #ifdef XNU_KERNEL_PRIVATE |
| 1097 | extern errno_t VNOP_INACTIVE(vnode_t, vfs_context_t); |
| 1098 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1099 | |
| 1100 | struct vnop_reclaim_args { |
| 1101 | struct vnodeop_desc *a_desc; |
| 1102 | vnode_t a_vp; |
| 1103 | vfs_context_t a_context; |
| 1104 | }; |
| 1105 | |
| 1106 | /*! |
| 1107 | @function VNOP_RECLAIM |
| 1108 | @abstract Release filesystem-internal resources for a vnode. |
| 1109 | @discussion VNOP_RECLAIM() is called as part of the process of recycling a vnode. During |
| 1110 | a reclaim routine, a filesystem should remove a vnode from its hash and deallocate any resources |
| 1111 | allocated to that vnode. VFS guarantees that when VNOP_RECLAIM() is called, there are no more |
| 1112 | iocount references on a vnode (though there may still be usecount references--these are invalidated |
| 1113 | by the reclaim) and that no more will be granted. This means in practice that there will be no |
| 1114 | filesystem calls on the vnode being reclaimed until the reclaim has finished and the vnode has |
| 1115 | been reused. |
| 1116 | @param vp The vnode to reclaim. |
| 1117 | @param ctx Context to authenticate for reclaim. |
| 1118 | @return 0 for success, or an error code. A nonzero return value results in a panic. |
| 1119 | */ |
| 1120 | #ifdef XNU_KERNEL_PRIVATE |
| 1121 | extern errno_t VNOP_RECLAIM(vnode_t, vfs_context_t); |
| 1122 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1123 | |
| 1124 | struct vnop_pathconf_args { |
| 1125 | struct vnodeop_desc *a_desc; |
| 1126 | vnode_t a_vp; |
| 1127 | int a_name; |
| 1128 | int32_t *a_retval; |
| 1129 | vfs_context_t a_context; |
| 1130 | }; |
| 1131 | |
| 1132 | /*! |
| 1133 | @function VNOP_PATHCONF |
| 1134 | @abstract Query a filesystem for path properties. |
| 1135 | @param vp The vnode whose filesystem to query. |
| 1136 | @param name Which property to request: see unistd.h. For example: _PC_CASE_SENSITIVE (is |
| 1137 | a filesystem case-sensitive?). Only one property can be requested at a time. |
| 1138 | @param retval Destination for value of property. |
| 1139 | @param ctx Context to authenticate for pathconf request. |
| 1140 | @return 0 for success, or an error code. |
| 1141 | */ |
| 1142 | #ifdef XNU_KERNEL_PRIVATE |
| 1143 | extern errno_t VNOP_PATHCONF(vnode_t, int, int32_t *, vfs_context_t); |
| 1144 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1145 | |
| 1146 | struct vnop_advlock_args { |
| 1147 | struct vnodeop_desc *a_desc; |
| 1148 | vnode_t a_vp; |
| 1149 | caddr_t a_id; |
| 1150 | int a_op; |
| 1151 | struct flock *a_fl; |
| 1152 | int a_flags; |
| 1153 | vfs_context_t a_context; |
| 1154 | struct timespec *a_timeout; |
| 1155 | }; |
| 1156 | |
| 1157 | /*! |
| 1158 | @function VNOP_ADVLOCK |
| 1159 | @abstract Aquire or release and advisory lock on a vnode. |
| 1160 | @discussion Advisory locking is somewhat complicated. VNOP_ADVLOCK is overloaded for |
| 1161 | both flock() and POSIX advisory locking usage, though not all filesystems support both (or any). VFS |
| 1162 | provides an advisory locking mechanism for filesystems which can take advantage of it; vfs_setlocklocal() |
| 1163 | marks a filesystem as using VFS advisory locking support. |
| 1164 | @param vp The vnode to lock or unlock. |
| 1165 | @param id Identifier for lock holder: ignored by most filesystems. |
| 1166 | @param op Which locking operation: F_SETLK: set locking information about a region. |
| 1167 | F_GETLK: get locking information about the specified region. F_UNLCK: Unlock a region. |
| 1168 | @param fl Description of file region to lock. l_whence is as with "lseek." |
| 1169 | Includes a type: F_RDLCK (shared lock), F_UNLCK (unlock) , and F_WRLCK (exclusive lock). |
| 1170 | @param flags F_FLOCK: use flock() semantics. F_POSIX: use POSIX semantics. F_WAIT: sleep if necessary. |
| 1171 | F_PROV: Non-coelesced provisional lock (unused in xnu). |
| 1172 | @param ctx Context to authenticate for advisory locking request. |
| 1173 | @param timeout Timespec for timeout in case of F_SETLKWTIMEOUT. |
| 1174 | @return 0 for success, or an error code. |
| 1175 | */ |
| 1176 | #ifdef XNU_KERNEL_PRIVATE |
| 1177 | extern errno_t VNOP_ADVLOCK(vnode_t, caddr_t, int, struct flock *, int, vfs_context_t, struct timespec *); |
| 1178 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1179 | |
| 1180 | struct vnop_allocate_args { |
| 1181 | struct vnodeop_desc *a_desc; |
| 1182 | vnode_t a_vp; |
| 1183 | off_t a_length; |
| 1184 | u_int32_t a_flags; |
| 1185 | off_t *a_bytesallocated; |
| 1186 | off_t a_offset; |
| 1187 | vfs_context_t a_context; |
| 1188 | }; |
| 1189 | |
| 1190 | /*! |
| 1191 | @function VNOP_ALLOCATE |
| 1192 | @abstract Pre-allocate space for a file. |
| 1193 | @discussion VNOP_ALLOCATE() changes the amount of backing store set aside to |
| 1194 | a file. It can be used to either shrink or grow a file. If the file shrinks, |
| 1195 | its ubc size will be modified accordingly, but if it grows, then the ubc size is unchanged; |
| 1196 | space is set aside without being actively used by the file. VNOP_ALLOCATE() is currently only |
| 1197 | called as part of the F_PREALLOCATE fcntl. |
| 1198 | @param vp The vnode for which to preallocate space. |
| 1199 | @param length Desired preallocated file length. |
| 1200 | @param flags |
| 1201 | PREALLOCATE: preallocate allocation blocks. |
| 1202 | ALLOCATECONTIG: allocate contigious space. |
| 1203 | ALLOCATEALL: allocate all requested space or no space at all. |
| 1204 | FREEREMAINDER: deallocate allocated but unfilled blocks. |
| 1205 | ALLOCATEFROMPEOF: allocate from the physical eof. |
| 1206 | ALLOCATEFROMVOL: allocate from the volume offset. |
| 1207 | @param bytesallocated Additional bytes set aside for file. Set to 0 if none are allocated |
| 1208 | OR if the file is contracted. |
| 1209 | @param offset Hint for where to find free blocks. |
| 1210 | @param ctx Context to authenticate for allocation request. |
| 1211 | @return 0 for success, or an error code. |
| 1212 | */ |
| 1213 | #ifdef XNU_KERNEL_PRIVATE |
| 1214 | extern errno_t VNOP_ALLOCATE(vnode_t, off_t, u_int32_t, off_t *, off_t, vfs_context_t); |
| 1215 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1216 | |
| 1217 | struct vnop_pagein_args { |
| 1218 | struct vnodeop_desc *a_desc; |
| 1219 | vnode_t a_vp; |
| 1220 | upl_t a_pl; |
| 1221 | upl_offset_t a_pl_offset; |
| 1222 | off_t a_f_offset; |
| 1223 | size_t a_size; |
| 1224 | int a_flags; |
| 1225 | vfs_context_t a_context; |
| 1226 | }; |
| 1227 | |
| 1228 | /*! |
| 1229 | @function VNOP_PAGEIN |
| 1230 | @abstract Pull file data into memory. |
| 1231 | @discussion VNOP_PAGEIN() is called by when a process faults on data mapped from a file or |
| 1232 | when madvise() demands pre-fetching. It is conceptually somewhat similar to VNOP_READ(). Filesystems |
| 1233 | are typically expected to call cluster_pagein() to handle the labor of mapping and committing the UPL. |
| 1234 | @param vp The vnode for which to page in data. |
| 1235 | @param pl UPL describing pages needing to be paged in. |
| 1236 | @param pl_offset Offset in UPL at which to start placing data. |
| 1237 | @param f_offset Offset in file of data needing to be paged in. |
| 1238 | @param size Amount of data to page in (in bytes). |
| 1239 | @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC. |
| 1240 | Filesystems should generally leave it to the cluster layer to handle these flags. See the |
| 1241 | memory_object_types.h header in the kernel framework if interested. |
| 1242 | @param ctx Context to authenticate for pagein request. |
| 1243 | @return 0 for success, or an error code. |
| 1244 | */ |
| 1245 | #ifdef XNU_KERNEL_PRIVATE |
| 1246 | extern errno_t VNOP_PAGEIN(vnode_t, upl_t, upl_offset_t, off_t, size_t, int, vfs_context_t); |
| 1247 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1248 | |
| 1249 | struct vnop_pageout_args { |
| 1250 | struct vnodeop_desc *a_desc; |
| 1251 | vnode_t a_vp; |
| 1252 | upl_t a_pl; |
| 1253 | upl_offset_t a_pl_offset; |
| 1254 | off_t a_f_offset; |
| 1255 | size_t a_size; |
| 1256 | int a_flags; |
| 1257 | vfs_context_t a_context; |
| 1258 | }; |
| 1259 | |
| 1260 | /*! |
| 1261 | @function VNOP_PAGEOUT |
| 1262 | @abstract Write data from a mapped file back to disk. |
| 1263 | @discussion VNOP_PAGEOUT() is called when data from a mapped file needs to be flushed to disk, either |
| 1264 | because of an msync() call or due to memory pressure. Filesystems are for the most part expected to |
| 1265 | just call cluster_pageout(). However, if they opt into the VFC_VFSVNOP_PAGEOUTV2 flag, then |
| 1266 | they will be responsible for creating their own UPLs. |
| 1267 | @param vp The vnode for which to page out data. |
| 1268 | @param pl UPL describing pages needed to be paged out. If UPL is NULL, then it means the filesystem |
| 1269 | has opted into VFC_VFSVNOP_PAGEOUTV2 semantics, which means that it will create and operate on its own UPLs |
| 1270 | as opposed to relying on the one passed down into the filesystem. This means that the filesystem must be |
| 1271 | responsible for N cluster_pageout calls for N dirty ranges in the UPL. |
| 1272 | @param pl_offset Offset in UPL from which to start paging out data. Under the new VFC_VFSVNOP_PAGEOUTV2 |
| 1273 | semantics, this is the offset in the range specified that must be paged out if the associated page is dirty. |
| 1274 | @param f_offset Offset in file of data needing to be paged out. Under the new VFC_VFSVNOP_PAGEOUTV2 |
| 1275 | semantics, this represents the offset in the file where we should start looking for dirty pages. |
| 1276 | @param size Amount of data to page out (in bytes). Under VFC_VFSVNOP_PAGEOUTV2, this represents |
| 1277 | the size of the range to be considered. The fileystem is free to extend or shrink the specified range |
| 1278 | to better fit its blocking model as long as the page at 'pl_offset' is included. |
| 1279 | @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC. |
| 1280 | Filesystems should generally leave it to the cluster layer to handle these flags. See the |
| 1281 | memory_object_types.h header in the kernel framework if interested. |
| 1282 | @param ctx Context to authenticate for pageout request. |
| 1283 | @return 0 for success, or an error code. |
| 1284 | */ |
| 1285 | #ifdef XNU_KERNEL_PRIVATE |
| 1286 | extern errno_t VNOP_PAGEOUT(vnode_t, upl_t, upl_offset_t, off_t, size_t, int, vfs_context_t); |
| 1287 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1288 | |
| 1289 | struct vnop_searchfs_args { |
| 1290 | struct vnodeop_desc *a_desc; |
| 1291 | vnode_t a_vp; |
| 1292 | void *a_searchparams1; |
| 1293 | void *a_searchparams2; |
| 1294 | struct attrlist *a_searchattrs; |
| 1295 | uint32_t a_maxmatches; |
| 1296 | struct timeval *a_timelimit; |
| 1297 | struct attrlist *a_returnattrs; |
| 1298 | uint32_t *a_nummatches; |
| 1299 | uint32_t a_scriptcode; |
| 1300 | uint32_t a_options; |
| 1301 | struct uio *a_uio; |
| 1302 | struct searchstate *a_searchstate; |
| 1303 | vfs_context_t a_context; |
| 1304 | }; |
| 1305 | |
| 1306 | /* |
| 1307 | @function VNOP_SEARCHFS |
| 1308 | @abstract Search a filesystem quickly for files or directories that match the passed-in search criteria. |
| 1309 | @discussion VNOP_SEARCHFS is a getattrlist-based system call which is implemented almost entirely inside |
| 1310 | supported filesystems. Callers provide a set of criteria to match against, and the filesystem is responsible |
| 1311 | for finding all files or directories that match the criteria. Once these files or directories are found, |
| 1312 | the user-requested attributes of these files is provided as output. The set of searchable attributes is a |
| 1313 | subset of the getattrlist attributes. For example, ATTR_CMN_UUID is not a valid searchable attribute as of |
| 1314 | 10.6. A common usage scenario could be to request all files whose mod dates is greater than time X, less than |
| 1315 | time Y, and provide the inode ID and filename of the matching objects as output. |
| 1316 | @param vp The vnode representing the mountpoint of the filesystem to be searched. |
| 1317 | @param a_searchparams1 If one-argument search criteria is requested, the search criteria would go here. However, |
| 1318 | some search criteria, like ATTR_CMN_MODTIME, can be bounded. The user could request files modified between time X |
| 1319 | and time Y. In this case, the lower bound goes in a_searchparams1. |
| 1320 | @param a_searchparams2 If two-argument search criteria is requested, the upper bound goes in here. |
| 1321 | @param a_searchattrs Contains the getattrlist-style attribute bits which are requested by the current search. |
| 1322 | @param a_maxmatches The maximum number of matches to return in a single system call. |
| 1323 | @param a_timelimit The suggested maximum amount of time we can spend in the kernel to service this system call. |
| 1324 | Filesystems should use this as a guide only, and set their own internal maximum time to avoid denial of service. |
| 1325 | @param a_returnattrs The getattrlist-style attributes to return for items in the filesystem that match the search |
| 1326 | criteria above. |
| 1327 | @param a_scriptcode Currently ignored. |
| 1328 | @param a_uio The uio in which to write out the search matches. |
| 1329 | @param a_searchstate Sometimes searches cannot be completed in a single system call. In this case, we provide |
| 1330 | an identifier back to the user which indicates where to resume a previously-started search. This is an opaque structure |
| 1331 | used by the filesystem to identify where to resume said search. |
| 1332 | @param a_context The context in which to perform the filesystem search. |
| 1333 | @return 0 on success, EAGAIN for searches which could not be completed in 1 call, and other ERRNOS as needed. |
| 1334 | */ |
| 1335 | |
| 1336 | #ifdef XNU_KERNEL_PRIVATE |
| 1337 | extern errno_t VNOP_SEARCHFS(vnode_t, void *, void *, struct attrlist *, uint32_t, struct timeval *, struct attrlist *, uint32_t *, uint32_t, uint32_t, struct uio *, struct searchstate *, vfs_context_t); |
| 1338 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1339 | |
| 1340 | struct vnop_copyfile_args { |
| 1341 | struct vnodeop_desc *a_desc; |
| 1342 | vnode_t a_fvp; |
| 1343 | vnode_t a_tdvp; |
| 1344 | vnode_t a_tvp; |
| 1345 | struct componentname *a_tcnp; |
| 1346 | int a_mode; |
| 1347 | int a_flags; |
| 1348 | vfs_context_t a_context; |
| 1349 | }; |
| 1350 | |
| 1351 | #ifdef XNU_KERNEL_PRIVATE |
| 1352 | extern errno_t VNOP_COPYFILE(vnode_t, vnode_t, vnode_t, struct componentname *, int, int, vfs_context_t); |
| 1353 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1354 | |
| 1355 | typedef enum dir_clone_authorizer_op { |
| 1356 | OP_AUTHORIZE = 0, /* request authorization of action */ |
| 1357 | OP_VATTR_SETUP = 1, /* query for attributes that are required for OP_AUTHORIZE */ |
| 1358 | OP_VATTR_CLEANUP = 2 /* request to cleanup any state or free any memory allocated in OP_AUTHORIZE */ |
| 1359 | } dir_clone_authorizer_op_t; |
| 1360 | |
| 1361 | struct vnop_clonefile_args { |
| 1362 | struct vnodeop_desc *a_desc; |
| 1363 | vnode_t a_fvp; |
| 1364 | vnode_t a_dvp; |
| 1365 | vnode_t *a_vpp; |
| 1366 | struct componentname *a_cnp; |
| 1367 | struct vnode_attr *a_vap; |
| 1368 | uint32_t a_flags; |
| 1369 | vfs_context_t a_context; |
| 1370 | int (*a_dir_clone_authorizer)( /* Authorization callback */ |
| 1371 | struct vnode_attr *vap, /* attribute to be authorized */ |
| 1372 | kauth_action_t action, /* action for which attribute is to be authorized */ |
| 1373 | struct vnode_attr *dvap, /* target directory attributes */ |
| 1374 | vnode_t sdvp, /* source directory vnode pointer (optional) */ |
| 1375 | mount_t mp, /* mount point of filesystem */ |
| 1376 | dir_clone_authorizer_op_t vattr_op, /* specific operation requested : setup, authorization or cleanup */ |
| 1377 | uint32_t flags, /* needs to have the value passed to a_flags */ |
| 1378 | vfs_context_t ctx, /* As passed to VNOP */ |
| 1379 | void *reserved); /* Always NULL */ |
| 1380 | void *a_reserved; /* Currently unused */ |
| 1381 | }; |
| 1382 | |
| 1383 | /*! |
| 1384 | @function VNOP_CLONEFILE |
| 1385 | @abstract Call down to a filesystem to clone a filesystem object (regular file, directory or symbolic link.) |
| 1386 | @discussion If file creation succeeds, "vpp" should be returned with an iocount to be dropped by the caller. |
| 1387 | @param dvp Directory in which to clone object. |
| 1388 | @param vpp Destination for vnode for newly cloned object. |
| 1389 | @param cnp Description of name of object to clone. |
| 1390 | @param vap File creation properties, as seen in vnode_getattr(). Manipulated with VATTR_ISACTIVE, VATTR_RETURN, |
| 1391 | VATTR_SET_SUPPORTED, and so forth. All attributes not set here should either be copied |
| 1392 | from the source object |
| 1393 | or set to values which are used for creating new filesystem objects |
| 1394 | @param ctx Context against which to authenticate file creation. |
| 1395 | @return 0 for success or a filesystem-specific error. |
| 1396 | */ |
| 1397 | #ifdef XNU_KERNEL_PRIVATE |
| 1398 | extern errno_t VNOP_CLONEFILE(vnode_t, vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, uint32_t, vfs_context_t); |
| 1399 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1400 | |
| 1401 | struct vnop_getxattr_args { |
| 1402 | struct vnodeop_desc *a_desc; |
| 1403 | vnode_t a_vp; |
| 1404 | const char * a_name; |
| 1405 | uio_t a_uio; |
| 1406 | size_t *a_size; |
| 1407 | int a_options; |
| 1408 | vfs_context_t a_context; |
| 1409 | }; |
| 1410 | extern struct vnodeop_desc vnop_getxattr_desc; |
| 1411 | |
| 1412 | /*! |
| 1413 | @function VNOP_GETXATTR |
| 1414 | @abstract Get extended file attributes. |
| 1415 | @param vp The vnode to get extended attributes for. |
| 1416 | @param name Which property to extract. |
| 1417 | @param uio Destination information for attribute value. |
| 1418 | @param size Should be set to the amount of data written. |
| 1419 | @param options XATTR_NOSECURITY: bypass security-checking. |
| 1420 | @param ctx Context to authenticate for getxattr request. |
| 1421 | @return 0 for success, or an error code. |
| 1422 | */ |
| 1423 | extern errno_t VNOP_GETXATTR(vnode_t vp, const char *name, uio_t uio, size_t *size, int options, vfs_context_t ctx); |
| 1424 | |
| 1425 | struct vnop_setxattr_args { |
| 1426 | struct vnodeop_desc *a_desc; |
| 1427 | vnode_t a_vp; |
| 1428 | const char * a_name; |
| 1429 | uio_t a_uio; |
| 1430 | int a_options; |
| 1431 | vfs_context_t a_context; |
| 1432 | }; |
| 1433 | extern struct vnodeop_desc vnop_setxattr_desc; |
| 1434 | |
| 1435 | /*! |
| 1436 | @function VNOP_SETXATTR |
| 1437 | @abstract Set extended file attributes. |
| 1438 | @param vp The vnode to set extended attributes for. |
| 1439 | @param name Which property to extract. |
| 1440 | @param uio Source information for attribute value. |
| 1441 | @param options XATTR_NOSECURITY: bypass security-checking. XATTR_CREATE: set value, fail if exists. |
| 1442 | XATTR_REPLACE: set value, fail if does not exist. |
| 1443 | @param ctx Context to authenticate for setxattr request. |
| 1444 | @return 0 for success, or an error code. |
| 1445 | */ |
| 1446 | extern errno_t VNOP_SETXATTR(vnode_t vp, const char *name, uio_t uio, int options, vfs_context_t ctx); |
| 1447 | |
| 1448 | struct vnop_removexattr_args { |
| 1449 | struct vnodeop_desc *a_desc; |
| 1450 | vnode_t a_vp; |
| 1451 | const char * a_name; |
| 1452 | int a_options; |
| 1453 | vfs_context_t a_context; |
| 1454 | }; |
| 1455 | extern struct vnodeop_desc vnop_removexattr_desc; |
| 1456 | |
| 1457 | /*! |
| 1458 | @function VNOP_REMOVEXATTR |
| 1459 | @abstract Remove extended file attributes. |
| 1460 | @param vp The vnode from which to remove extended attributes. |
| 1461 | @param name Which attribute to delete. |
| 1462 | @param options XATTR_NOSECURITY: bypass security-checking. |
| 1463 | @param ctx Context to authenticate for attribute delete request. |
| 1464 | @return 0 for success, or an error code. |
| 1465 | */ |
| 1466 | #ifdef XNU_KERNEL_PRIVATE |
| 1467 | extern errno_t VNOP_REMOVEXATTR(vnode_t, const char *, int, vfs_context_t); |
| 1468 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1469 | |
| 1470 | struct vnop_listxattr_args { |
| 1471 | struct vnodeop_desc *a_desc; |
| 1472 | vnode_t a_vp; |
| 1473 | uio_t a_uio; |
| 1474 | size_t *a_size; |
| 1475 | int a_options; |
| 1476 | vfs_context_t a_context; |
| 1477 | }; |
| 1478 | extern struct vnodeop_desc vnop_listxattr_desc; |
| 1479 | |
| 1480 | /*! |
| 1481 | @function VNOP_LISTXATTR |
| 1482 | @abstract List extended attribute keys. |
| 1483 | @discussion Should write a sequence of unseparated, null-terminated extended-attribute |
| 1484 | names into the space described by the provided uio. These keys can then be passed to |
| 1485 | getxattr() (and VNOP_GETXATTR()). |
| 1486 | @param vp The vnode for which to get extended attribute keys. |
| 1487 | @param uio Description of target memory for attribute keys. |
| 1488 | @param size Should be set to amount of data written to buffer. |
| 1489 | @param options XATTR_NOSECURITY: bypass security checking. |
| 1490 | @param ctx Context to authenticate for attribute name request. |
| 1491 | */ |
| 1492 | #ifdef XNU_KERNEL_PRIVATE |
| 1493 | extern errno_t VNOP_LISTXATTR(vnode_t, uio_t, size_t *, int, vfs_context_t); |
| 1494 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1495 | |
| 1496 | struct vnop_blktooff_args { |
| 1497 | struct vnodeop_desc *a_desc; |
| 1498 | vnode_t a_vp; |
| 1499 | daddr64_t a_lblkno; |
| 1500 | off_t *a_offset; |
| 1501 | }; |
| 1502 | |
| 1503 | /*! |
| 1504 | @function VNOP_BLKTOOFF |
| 1505 | @abstract Call down to a filesystem to convert a logical block number to a file offset. |
| 1506 | @discussion VNOP_BLKTOOFF() converts a logical block to a file offset in bytes. That offset |
| 1507 | can be passed to VNOP_BLOCKMAP(), then, to get a physical block number--buf_strategy() does this. |
| 1508 | @param vp The vnode for which to convert a logical block to an offset. |
| 1509 | @param lblkno Logical block number to turn into offset. |
| 1510 | @param offset Destination for file offset. |
| 1511 | @return 0 for success, else an error code. |
| 1512 | */ |
| 1513 | #ifdef XNU_KERNEL_PRIVATE |
| 1514 | extern errno_t VNOP_BLKTOOFF(vnode_t, daddr64_t, off_t *); |
| 1515 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1516 | |
| 1517 | struct vnop_offtoblk_args { |
| 1518 | struct vnodeop_desc *a_desc; |
| 1519 | vnode_t a_vp; |
| 1520 | off_t a_offset; |
| 1521 | daddr64_t *a_lblkno; |
| 1522 | }; |
| 1523 | |
| 1524 | /*! |
| 1525 | @function VNOP_OFFTOBLK |
| 1526 | @abstract Call down to a filesystem to convert a file offset to a logical block number. |
| 1527 | @param vp The vnode for which to convert an offset to a logical block number. |
| 1528 | @param offset File offset to convert. |
| 1529 | @param lblkno Destination for corresponding logical block number. |
| 1530 | @return 0 for success, else an error code. |
| 1531 | */ |
| 1532 | #ifdef XNU_KERNEL_PRIVATE |
| 1533 | extern errno_t VNOP_OFFTOBLK(vnode_t, off_t, daddr64_t *); |
| 1534 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1535 | |
| 1536 | struct vnop_blockmap_args { |
| 1537 | struct vnodeop_desc *a_desc; |
| 1538 | vnode_t a_vp; |
| 1539 | off_t a_foffset; |
| 1540 | size_t a_size; |
| 1541 | daddr64_t *a_bpn; |
| 1542 | size_t *a_run; |
| 1543 | void *a_poff; |
| 1544 | int a_flags; |
| 1545 | vfs_context_t a_context; |
| 1546 | }; |
| 1547 | |
| 1548 | /*! |
| 1549 | @function VNOP_BLOCKMAP |
| 1550 | @abstract Call down to a filesystem to get information about the on-disk layout of a file region. |
| 1551 | @discussion VNOP_BLOCKMAP() returns the information required to pass a request for a contiguous region |
| 1552 | down to a device's strategy routine. |
| 1553 | @param vp The vnode for which to get on-disk information. |
| 1554 | @param foffset Offset (in bytes) at which region starts. |
| 1555 | @param size Size of region. |
| 1556 | @param bpn Destination for physical block number at which region begins on disk. |
| 1557 | @param run Destination for number of bytes which can be found contiguously on-disk before |
| 1558 | first discontinuity. |
| 1559 | @param poff Currently unused. |
| 1560 | @param flags VNODE_READ: request is for a read. VNODE_WRITE: request is for a write. |
| 1561 | @param ctx Context to authenticate for blockmap request; currently often set to NULL. |
| 1562 | @return 0 for success, else an error code. |
| 1563 | */ |
| 1564 | #ifdef XNU_KERNEL_PRIVATE |
| 1565 | extern errno_t VNOP_BLOCKMAP(vnode_t, off_t, size_t, daddr64_t *, size_t *, void *, |
| 1566 | int, vfs_context_t); |
| 1567 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1568 | |
| 1569 | struct vnop_strategy_args { |
| 1570 | struct vnodeop_desc *a_desc; |
| 1571 | struct buf *a_bp; |
| 1572 | }; |
| 1573 | |
| 1574 | /*! |
| 1575 | @function VNOP_STRATEGY |
| 1576 | @abstract Initiate I/O on a file (both read and write). |
| 1577 | @discussion A filesystem strategy routine takes a buffer, performs whatever manipulations are necessary for passing |
| 1578 | the I/O request down to the device layer, and calls the appropriate device's strategy routine. Most filesystems should |
| 1579 | just call buf_strategy() with "bp" as the argument. |
| 1580 | @param bp Complete specificiation of requested I/O: region of data involved, whether request is for read or write, and so on. |
| 1581 | @return 0 for success, else an error code. |
| 1582 | */ |
| 1583 | extern errno_t VNOP_STRATEGY(struct buf *bp); |
| 1584 | |
| 1585 | struct vnop_bwrite_args { |
| 1586 | struct vnodeop_desc *a_desc; |
| 1587 | buf_t a_bp; |
| 1588 | }; |
| 1589 | |
| 1590 | /*! |
| 1591 | @function VNOP_BWRITE |
| 1592 | @abstract Write a buffer to backing store. |
| 1593 | @discussion VNOP_BWRITE() is called by buf_bawrite() (asynchronous write) and potentially by buf_bdwrite() (delayed write) |
| 1594 | but not by buf_bwrite(). A filesystem may choose to perform some kind of manipulation of the buffer in this routine; it |
| 1595 | generally will end up calling VFS's default implementation, vn_bwrite() (which calls buf_bwrite() without further ado). |
| 1596 | @param bp The buffer to write. |
| 1597 | @return 0 for success, else an error code. |
| 1598 | */ |
| 1599 | extern errno_t VNOP_BWRITE(buf_t bp); |
| 1600 | |
| 1601 | struct vnop_kqfilt_add_args { |
| 1602 | struct vnodeop_desc *a_desc; |
| 1603 | struct vnode *a_vp; |
| 1604 | struct knote *a_kn; |
| 1605 | vfs_context_t a_context; |
| 1606 | }; |
| 1607 | extern struct vnodeop_desc vnop_kqfilt_add_desc; |
| 1608 | |
| 1609 | #ifdef XNU_KERNEL_PRIVATE |
| 1610 | extern errno_t VNOP_KQFILT_ADD(vnode_t , struct knote *, vfs_context_t); |
| 1611 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1612 | |
| 1613 | struct vnop_kqfilt_remove_args { |
| 1614 | struct vnodeop_desc *a_desc; |
| 1615 | struct vnode *a_vp; |
| 1616 | uintptr_t a_ident; |
| 1617 | vfs_context_t a_context; |
| 1618 | }; |
| 1619 | extern struct vnodeop_desc vnop_kqfilt_remove_desc; |
| 1620 | |
| 1621 | #ifdef XNU_KERNEL_PRIVATE |
| 1622 | errno_t VNOP_KQFILT_REMOVE(vnode_t , uintptr_t , vfs_context_t); |
| 1623 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1624 | |
| 1625 | |
| 1626 | #ifdef KERNEL_PRIVATE |
| 1627 | #define VNODE_MONITOR_BEGIN 0x01 |
| 1628 | #define VNODE_MONITOR_END 0x02 |
| 1629 | #define VNODE_MONITOR_UPDATE 0x04 |
| 1630 | struct vnop_monitor_args { |
| 1631 | struct vnodeop_desc *a_desc; |
| 1632 | vnode_t a_vp; |
| 1633 | uint32_t a_events; |
| 1634 | uint32_t a_flags; |
| 1635 | void *a_handle; |
| 1636 | vfs_context_t a_context; |
| 1637 | }; |
| 1638 | extern struct vnodeop_desc vnop_monitor_desc; |
| 1639 | #endif /* KERNEL_PRIVATE */ |
| 1640 | |
| 1641 | #ifdef XNU_KERNEL_PRIVATE |
| 1642 | /*! |
| 1643 | @function VNOP_MONITOR |
| 1644 | @abstract Indicate to a filesystem that the number of watchers of a file has changed. |
| 1645 | @param vp The vnode whose watch state has changed. |
| 1646 | @param events Unused. Filesystems can ignore this parameter. |
| 1647 | @param flags Type of change to the watch state. VNODE_MONITOR_BEGIN is passed when the kernel |
| 1648 | begins tracking a new watcher of a file. VNODE_MONITOR_END is passed when a watcher stops watching a file. |
| 1649 | VNODE_MONITOR_UPDATE is currently unused. A filesystem is guaranteed that each VNODE_MONITOR_BEGIN |
| 1650 | will be matched by a VNODE_MONITOR_END with the same "handle" argument. |
| 1651 | @param handle Unique identifier for a given watcher. A VNODE_MONITOR_BEGIN for a given handle will be matched with a |
| 1652 | VNODE_MONITOR_END for the same handle; a filesystem need not consider this parameter unless |
| 1653 | it for some reason wants be able to match specific VNOP_MONITOR calls rather than just keeping |
| 1654 | a count. |
| 1655 | @param ctx The context which is starting to monitor a file or ending a watch on a file. A matching |
| 1656 | pair of VNODE_MONITOR_BEGIN and VNODE_MONITOR_END need not have the same context. |
| 1657 | @discussion VNOP_MONITOR() is intended to let networked filesystems know when they should bother |
| 1658 | listening for changes to files which occur remotely, so that they can post notifications using |
| 1659 | vnode_notify(). Local filesystems should not implement a monitor vnop. |
| 1660 | It is called when there is a new watcher for a file or when a watcher for a file goes away. |
| 1661 | Each BEGIN will be matched with an END with the same handle. Note that vnode_ismonitored() can |
| 1662 | be used to see if there are currently watchers for a file. |
| 1663 | */ |
| 1664 | errno_t VNOP_MONITOR(vnode_t vp, uint32_t events, uint32_t flags, void *handle, vfs_context_t ctx); |
| 1665 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1666 | |
| 1667 | struct label; |
| 1668 | struct vnop_setlabel_args { |
| 1669 | struct vnodeop_desc *a_desc; |
| 1670 | struct vnode *a_vp; |
| 1671 | struct label *a_vl; |
| 1672 | vfs_context_t a_context; |
| 1673 | }; |
| 1674 | extern struct vnodeop_desc vnop_setlabel_desc; |
| 1675 | |
| 1676 | /*! |
| 1677 | @function VNOP_SETLABEL |
| 1678 | @abstract Associate a MACF label with a file. |
| 1679 | @param vp The vnode to label. |
| 1680 | @param label The desired label. |
| 1681 | @param ctx Context to authenticate for label change. |
| 1682 | @return 0 for success, else an error code. |
| 1683 | */ |
| 1684 | #ifdef XNU_KERNEL_PRIVATE |
| 1685 | errno_t VNOP_SETLABEL(vnode_t, struct label *, vfs_context_t); |
| 1686 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1687 | |
| 1688 | #ifdef __APPLE_API_UNSTABLE |
| 1689 | |
| 1690 | #if NAMEDSTREAMS |
| 1691 | |
| 1692 | enum nsoperation { NS_OPEN, NS_CREATE, NS_DELETE }; |
| 1693 | |
| 1694 | /* a_flags for vnop_getnamedstream_args: */ |
| 1695 | #define NS_GETRAWENCRYPTED 0x00000001 |
| 1696 | |
| 1697 | struct vnop_getnamedstream_args { |
| 1698 | struct vnodeop_desc *a_desc; |
| 1699 | vnode_t a_vp; |
| 1700 | vnode_t *a_svpp; |
| 1701 | const char *a_name; |
| 1702 | enum nsoperation a_operation; |
| 1703 | int a_flags; |
| 1704 | vfs_context_t a_context; |
| 1705 | }; |
| 1706 | |
| 1707 | /*! |
| 1708 | @function VNOP_GETNAMEDSTREAM |
| 1709 | @abstract Get a named stream associated with a file. |
| 1710 | @discussion If this call sucecss, svpp should be returned with an iocount which the caller |
| 1711 | will drop. VFS provides a facility for simulating named streams when interacting with filesystems |
| 1712 | which do not support them. |
| 1713 | @param vp The vnode for which to get a named stream. |
| 1714 | @param svpp Destination for pointer to named stream's vnode. |
| 1715 | @param name The name of the named stream, e.g. "com.apple.ResourceFork". |
| 1716 | @param operation Operation to perform. In HFS and AFP, this parameter is only considered as follows: |
| 1717 | if the resource fork has not been opened and the operation is not NS_OPEN, fail with ENOATTR. Currently |
| 1718 | only passed as NS_OPEN by VFS. |
| 1719 | @param flags Flags used to control getnamedstream behavior. Currently only used for raw-encrypted-requests. |
| 1720 | @param ctx Context to authenticate for getting named stream. |
| 1721 | @return 0 for success, else an error code. |
| 1722 | */ |
| 1723 | #ifdef XNU_KERNEL_PRIVATE |
| 1724 | extern errno_t VNOP_GETNAMEDSTREAM(vnode_t, vnode_t *, const char *, enum nsoperation, int flags, vfs_context_t); |
| 1725 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1726 | |
| 1727 | struct vnop_makenamedstream_args { |
| 1728 | struct vnodeop_desc *a_desc; |
| 1729 | vnode_t *a_svpp; |
| 1730 | vnode_t a_vp; |
| 1731 | const char *a_name; |
| 1732 | int a_flags; |
| 1733 | vfs_context_t a_context; |
| 1734 | }; |
| 1735 | |
| 1736 | /*! |
| 1737 | @function VNOP_MAKENAMEDSTREAM |
| 1738 | @abstract Create a named stream associated with a file. |
| 1739 | @discussion If this call succeeds, svpp should be returned with an iocount which the caller will drop. |
| 1740 | VFS provides a facility for simulating named streams when interacting with filesystems |
| 1741 | which do not support them. |
| 1742 | @param vp The vnode for which to get a named stream. |
| 1743 | @param svpp Destination for pointer to named stream's vnode. |
| 1744 | @param name The name of the named stream, e.g. "com.apple.ResourceFork". |
| 1745 | @param flags Currently unused. |
| 1746 | @param ctx Context to authenticate creating named stream. |
| 1747 | @return 0 for success, else an error code. |
| 1748 | */ |
| 1749 | #ifdef XNU_KERNEL_PRIVATE |
| 1750 | extern errno_t VNOP_MAKENAMEDSTREAM(vnode_t, vnode_t *, const char *, int flags, vfs_context_t); |
| 1751 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1752 | |
| 1753 | struct vnop_removenamedstream_args { |
| 1754 | struct vnodeop_desc *a_desc; |
| 1755 | vnode_t a_vp; |
| 1756 | vnode_t a_svp; |
| 1757 | const char *a_name; |
| 1758 | int a_flags; |
| 1759 | vfs_context_t a_context; |
| 1760 | }; |
| 1761 | |
| 1762 | /*! |
| 1763 | @function VNOP_REMOVENAMEDSTREAM |
| 1764 | @abstract Delete a named stream associated with a file. |
| 1765 | @discussion VFS provides a facility for simulating named streams when interacting with filesystems |
| 1766 | which do not support them. |
| 1767 | @param vp The vnode to which the named stream belongs. |
| 1768 | @param svp The named stream's vnode. |
| 1769 | @param name The name of the named stream, e.g. "com.apple.ResourceFork". |
| 1770 | @param flags Currently unused. |
| 1771 | @param ctx Context to authenticate deleting named stream. |
| 1772 | @return 0 for success, else an error code. |
| 1773 | */ |
| 1774 | #ifdef XNU_KERNEL_PRIVATE |
| 1775 | extern errno_t VNOP_REMOVENAMEDSTREAM(vnode_t, vnode_t, const char *, int flags, vfs_context_t); |
| 1776 | #endif /* XNU_KERNEL_PRIVATE */ |
| 1777 | |
| 1778 | #endif // NAMEDSTREAMS |
| 1779 | |
| 1780 | #endif // defined(__APPLE_API_UNSTABLE) |
| 1781 | |
| 1782 | __END_DECLS |
| 1783 | |
| 1784 | #endif /* KERNEL */ |
| 1785 | |
| 1786 | #endif /* !_SYS_VNODE_IF_H_ */ |
| 1787 | |