+/*!
+ @function vn_path_package_check
+ @abstract Figure out if a path corresponds to a Mac OS X package.
+ @discussion Determines if the extension on a path is a known OS X extension type.
+ @param vp Unused.
+ @param path Path to check.
+ @param pathlen Size of path buffer.
+ @param component Set to index of start of last path component if the path is found to be a package. Set to -1 if
+ the path is not a known package type.
+ @return 0 unless some parameter was invalid, in which case EINVAL is returned. Determine package-ness by checking
+ what *component is set to.
+ */
+int vn_path_package_check(vnode_t vp, char *path, int pathlen, int *component);
+
+#ifdef KERNEL_PRIVATE
+/*!
+ @function vn_searchfs_inappropriate_name
+ @abstract Figure out if the component is inappropriate for a SearchFS query.
+ @param name component to check
+ @param len length of component.
+ @return 0 if no match, 1 if inappropriate.
+ */
+int vn_searchfs_inappropriate_name(const char *name, int len);
+#endif
+
+/*!
+ @function vn_rdwr
+ @abstract Read from or write to a file.
+ @discussion vn_rdwr() abstracts the details of constructing a uio and picking a vnode operation to allow
+ simple in-kernel file I/O.
+ @param rw UIO_READ for a read, UIO_WRITE for a write.
+ @param vp The vnode on which to perform I/O.
+ @param base Start of buffer into which to read or from which to write data.
+ @param len Length of buffer.
+ @param offset Offset within the file at which to start I/O.
+ @param segflg What kind of address "base" is. See uio_seg definition in sys/uio.h. UIO_SYSSPACE for kernelspace, UIO_USERSPACE for userspace.
+ UIO_USERSPACE32 and UIO_USERSPACE64 are in general preferred, but vn_rdwr will make sure that has the correct address sizes.
+ @param ioflg Defined in vnode.h, e.g. IO_NOAUTH, IO_NOCACHE.
+ @param cred Credential to pass down to filesystem for authentication.
+ @param aresid Destination for amount of requested I/O which was not completed, as with uio_resid().
+ @param p Process requesting I/O.
+ @return 0 for success; errors from filesystem, and EIO if did not perform all requested I/O and the "aresid" parameter is NULL.
+ */
+int vn_rdwr(enum uio_rw, vnode_t, caddr_t, int, off_t, enum uio_seg, int, kauth_cred_t, int *, proc_t);
+
+/*!
+ @function vnode_getname
+ @abstract Get the name of a vnode from the VFS namecache.
+ @discussion Not all vnodes have names, and vnode names can change (notably, hardlinks). Use this routine at your own risk.
+ The string is returned with a refcount incremented in the cache; callers must call vnode_putname() to release that reference.
+ @param vp The vnode whose name to grab.
+ @return The name, or NULL if unavailable.
+ */
+const char *vnode_getname(vnode_t vp);
+
+/*!
+ @function vnode_putname
+ @abstract Release a reference on a name from the VFS cache.
+ @discussion Should be called on a string obtained with vnode_getname().
+ @param name String to release.
+ @return void.
+ */
+void vnode_putname(const char *name);
+
+/*!
+ @function vnode_getparent
+ @abstract Get an iocount on the parent of a vnode.
+ @discussion A vnode's parent may change over time or be reclaimed, so vnode_getparent() may return different
+ results at different times (e.g. a multiple-hardlink file). The parent is returned with an iocount which must
+ subsequently be dropped with vnode_put().
+ @param vp The vnode whose parent to grab.
+ @return Parent if available, else NULL.
+ */
+vnode_t vnode_getparent(vnode_t vp);
+
+/*!
+ @function vnode_setdirty
+ @abstract Mark the vnode as having data or metadata that needs to be written out during reclaim
+ @discussion The vnode should be marked as dirty anytime a file system defers flushing of data or meta-data associated with it.
+ @param the vnode to mark as dirty
+ @return 0 if successful else an error code.
+ */
+int vnode_setdirty(vnode_t);
+
+/*!
+ @function vnode_cleardirty
+ @abstract Mark the vnode as clean i.e. all its data or metadata has been flushed
+ @discussion The vnode should be marked as clean whenever the file system is done flushing data or meta-data associated with it.
+ @param the vnode to clear as being dirty
+ @return 0 if successful else an error code.
+ */
+int vnode_cleardirty(vnode_t);
+
+/*!
+ @function vnode_isdirty
+ @abstract Determine if a vnode is marked dirty.
+ @discussion The vnode should be marked as clean whenever the file system is done flushing data or meta-data associated with it.
+ @param vp the vnode to test.
+ @return Non-zero if the vnode is dirty, 0 otherwise.
+ */
+int vnode_isdirty(vnode_t);
+
+
+
+#ifdef KERNEL_PRIVATE
+/*!
+ @function vnode_lookup_continue_needed
+ @abstract Determine whether vnode needs additional processing in VFS before being opened.
+ @discussion If result is zero, filesystem can open this vnode. If result is nonzero,
+ additional processing is needed in VFS (e.g. symlink, mountpoint). Nonzero results should
+ be passed up to VFS.
+ @param vp Vnode to consider opening (found by filesystem).
+ @param cnp Componentname as passed to filesystem from VFS.
+ @result 0 to indicate that a vnode can be opened, or an error that should be passed up to VFS.
+ */
+int vnode_lookup_continue_needed(vnode_t vp, struct componentname *cnp);
+
+/*!
+ @function vnode_istty
+ @abstract Determine if the given vnode represents a tty device.
+ @param vp Vnode to examine.
+ @result Non-zero to indicate that the vnode represents a tty device. Zero otherwise.
+ */
+int vnode_istty(vnode_t vp);
+#endif /* KERNEL_PRIVATE */
+
+#ifdef BSD_KERNEL_PRIVATE
+/* Not in export list so can be private */
+struct stat;
+int vn_stat(struct vnode *vp, void * sb, kauth_filesec_t *xsec, int isstat64, vfs_context_t ctx);
+int vn_stat_noauth(struct vnode *vp, void * sb, kauth_filesec_t *xsec, int isstat64, vfs_context_t ctx);
+int vaccess(mode_t file_mode, uid_t uid, gid_t gid,
+ mode_t acc_mode, kauth_cred_t cred);
+int check_mountedon(dev_t dev, enum vtype type, int *errorp);
+int vn_getcdhash(struct vnode *vp, off_t offset, unsigned char *cdhash);
+void vnode_reclaim(vnode_t);
+vfs_context_t vfs_context_kernel(void); /* get from 1st kernel thread */
+int vfs_context_issuser(vfs_context_t);
+vnode_t vfs_context_cwd(vfs_context_t);
+vnode_t current_rootdir(void);
+vnode_t current_workingdir(void);
+void *vnode_vfsfsprivate(vnode_t);
+struct vfsstatfs *vnode_vfsstatfs(vnode_t);
+uint32_t vnode_vfsvisflags(vnode_t);
+uint32_t vnode_vfscmdflags(vnode_t);
+int vnode_is_openevt(vnode_t);
+void vnode_set_openevt(vnode_t);
+void vnode_clear_openevt(vnode_t);
+int vnode_isstandard(vnode_t);
+int vnode_makeimode(int, int);
+enum vtype vnode_iftovt(int);
+int vnode_vttoif(enum vtype);
+int vnode_isshadow(vnode_t);
+boolean_t vnode_on_reliable_media(vnode_t);
+/*
+ * Indicate that a file has multiple hard links. VFS will always call
+ * VNOP_LOOKUP on this vnode. Volfs will always ask for it's parent
+ * object ID (instead of using the v_parent pointer).
+ */
+vnode_t vnode_parent(vnode_t);
+void vnode_setparent(vnode_t, vnode_t);
+/*!
+ @function vnode_getname_printable
+ @abstract Get a non-null printable name of a vnode.
+ @Used to make sure a printable name is returned for all vnodes. If a name exists or can be artificially created, the routine creates a new entry in the VFS namecache. Otherwise, the function returns an artificially created vnode name which is safer and easier to use. vnode_putname_printable() should be used to release names obtained by this routine.
+ @param vp The vnode whose name to grab.
+ @return The printable name.
+ */
+const char *vnode_getname_printable(vnode_t vp);
+
+/*!
+ @function vnode_putname_printable
+ @abstract Release a reference on a name from the VFS cache if it was added by the matching vnode_getname_printable() call.
+ @param name String to release.
+ @return void.
+ */
+void vnode_putname_printable(const char *name);
+void vnode_setname(vnode_t, char *);
+int vnode_isnoflush(vnode_t);
+void vnode_setnoflush(vnode_t);
+void vnode_clearnoflush(vnode_t);
+/* XXX temporary until we can arrive at a KPI for NFS, Seatbelt */
+thread_t vfs_context_thread(vfs_context_t);
+#if CONFIG_IOSCHED
+vnode_t vnode_mountdevvp(vnode_t);
+#endif
+#endif /* BSD_KERNEL_PRIVATE */
+
+/*
+ * Helper functions for implementing VNOP_GETATTRLISTBULK for a filesystem
+ */
+
+/*!
+ @function vfs_setup_vattr_from_attrlist
+ @abstract Setup a vnode_attr structure given an attrlist structure.
+ @Used by a VNOP_GETATTRLISTBULK implementation to setup a vnode_attr structure from a attribute list. It also returns the fixed size of the attribute buffer required.
+ @param alp Pointer to attribute list structure.
+ @param vap Pointer to vnode_attr structure.
+ @param obj_vtype Type of object - If VNON is passed, then the type is ignored and common, file and dir attrs are used to initialise the vattrs. If set to VDIR, only common and directory attributes are used. For all other types, only common and file attrbutes are used.
+ @param attr_fixed_sizep. Returns the fixed length required in the attrbute buffer for the object. NULL should be passed if it is not required.
+ @param ctx vfs context of caller.
+ @return error.
+ */
+errno_t vfs_setup_vattr_from_attrlist(struct attrlist * /* alp */, struct vnode_attr * /* vap */, enum vtype /* obj_vtype */, ssize_t * /* attr_fixed_sizep */, vfs_context_t /* ctx */);
+
+/*!
+ @function vfs_attr_pack
+ @abstract Pack a vnode_attr structure into a buffer in the same format as getattrlist(2).
+ @Used by a VNOP_GETATTRLISTBULK implementation to pack data provided into a vnode_attr structure into a buffer the way getattrlist(2) does.
+ @param vp If available, the vnode for which the attributes are being given, NULL if vnode is not available (which will usually be the case for a VNOP_GETATTRLISTBULK implementation.
+ @param auio - a uio_t initialised with one iovec..
+ @param alp - Pointer to an attrlist structure.
+ @param options - options for call (same as options for getattrlistbulk(2)).
+ @param vap Pointer to a filled in vnode_attr structure. Data from the vnode_attr structure will be used to copy and lay out the data in the required format for getatrlistbulk(2) by this function.
+ @param fndesc Currently unused
+ @param ctx vfs context of caller.
+ @return error.
+ */
+errno_t vfs_attr_pack(vnode_t /* vp */, uio_t /* uio */, struct attrlist * /* alp */, uint64_t /* options */, struct vnode_attr * /* vap */, void * /* fndesc */, vfs_context_t /* ctx */);
+