/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1992, 19934* The Regents of the University of California. All rights reserved.5*6* This code is derived from software donated to Berkeley by7* Jan-Simon Pendry.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the University nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*/3334#ifndef FS_NULL_H35#define FS_NULL_H3637#include <sys/ck.h>38#include <vm/uma.h>3940#define NULLM_CACHE 0x000141#define NULLM_NOUNPBYPASS 0x00024243struct null_mount {44struct mount *nullm_vfs;45struct vnode *nullm_lowerrootvp; /* Ref to lower root vnode */46uint64_t nullm_flags;47struct mount_upper_node upper_node;48struct mount_upper_node notify_node;49};5051#ifdef _KERNEL52/*53* A cache of vnode references54*/55struct null_node {56CK_SLIST_ENTRY(null_node) null_hash; /* Hash list */57struct vnode *null_lowervp; /* VREFed once */58struct vnode *null_vnode; /* Back pointer */59u_int null_flags;60};6162#define NULLV_NOUNLOCK 0x000163#define NULLV_DROP 0x00026465#define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data))66#define VTONULL(vp) ((struct null_node *)(vp)->v_data)67#define VTONULL_SMR(vp) ((struct null_node *)vn_load_v_data_smr(vp))68#define NULLTOV(xp) ((xp)->null_vnode)6970int nullfs_init(struct vfsconf *vfsp);71int nullfs_uninit(struct vfsconf *vfsp);72int null_nodeget(struct mount *mp, struct vnode *target, struct vnode **vpp);73struct vnode *null_hashget(struct mount *mp, struct vnode *lowervp);74void null_hashrem(struct null_node *xp);75int null_bypass(struct vop_generic_args *ap);7677#ifdef DIAGNOSTIC78struct vnode *null_checkvp(struct vnode *vp, char *fil, int lno);79#define NULLVPTOLOWERVP(vp) null_checkvp((vp), __FILE__, __LINE__)80#else81#define NULLVPTOLOWERVP(vp) (VTONULL(vp)->null_lowervp)82#endif8384extern struct vop_vector null_vnodeops;85extern struct vop_vector null_vnodeops_no_unp_bypass;8687static inline bool88null_is_nullfs_vnode(struct vnode *vp)89{90const struct vop_vector *op;9192op = vp->v_op;93return (op == &null_vnodeops || op == &null_vnodeops_no_unp_bypass);94}9596extern uma_zone_t null_node_zone;9798#ifdef NULLFS_DEBUG99#define NULLFSDEBUG(format, args...) printf(format ,## args)100#else101#define NULLFSDEBUG(format, args...)102#endif /* NULLFS_DEBUG */103104#endif /* _KERNEL */105106#endif107108109