The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/unionfs/union.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 1994 The Regents of the University of California.
    5  * Copyright (c) 1994 Jan-Simon Pendry.
    6  * Copyright (c) 2005, 2006 Masanori Ozawa <ozawa@ongs.co.jp>, ONGS Inc.
    7  * Copyright (c) 2006 Daichi Goto <daichi@freebsd.org>
    8  * All rights reserved.
    9  *
   10  * This code is derived from software donated to Berkeley by
   11  * Jan-Simon Pendry.
   12  *
   13  * Redistribution and use in source and binary forms, with or without
   14  * modification, are permitted provided that the following conditions
   15  * are met:
   16  * 1. Redistributions of source code must retain the above copyright
   17  *    notice, this list of conditions and the following disclaimer.
   18  * 2. Redistributions in binary form must reproduce the above copyright
   19  *    notice, this list of conditions and the following disclaimer in the
   20  *    documentation and/or other materials provided with the distribution.
   21  * 3. Neither the name of the University nor the names of its contributors
   22  *    may be used to endorse or promote products derived from this software
   23  *    without specific prior written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   35  * SUCH DAMAGE.
   36  *
   37  *      @(#)union.h     8.9 (Berkeley) 12/10/94
   38  * $FreeBSD$
   39  */
   40 
   41 #ifdef _KERNEL
   42 
   43 /* copy method of attr from lower to upper */
   44 typedef enum _unionfs_copymode {
   45         UNIONFS_TRADITIONAL = 0,
   46         UNIONFS_TRANSPARENT,
   47         UNIONFS_MASQUERADE
   48 } unionfs_copymode;
   49 
   50 /* whiteout policy of upper layer */
   51 typedef enum _unionfs_whitemode {
   52        UNIONFS_WHITE_ALWAYS = 0,
   53        UNIONFS_WHITE_WHENNEEDED
   54 } unionfs_whitemode;
   55 
   56 struct unionfs_mount {
   57         struct vnode   *um_lowervp;     /* VREFed once */
   58         struct vnode   *um_uppervp;     /* VREFed once */
   59         struct vnode   *um_rootvp;      /* ROOT vnode */
   60         unionfs_copymode um_copymode;
   61         unionfs_whitemode um_whitemode;
   62         uid_t           um_uid;
   63         gid_t           um_gid;
   64         u_short         um_udir;
   65         u_short         um_ufile;
   66 };
   67 
   68 /* unionfs status list */
   69 struct unionfs_node_status {
   70         LIST_ENTRY(unionfs_node_status) uns_list;       /* Status list */
   71         pid_t           uns_pid;                /* current process id */
   72         int             uns_node_flag;          /* uns flag */
   73         int             uns_lower_opencnt;      /* open count of lower */
   74         int             uns_upper_opencnt;      /* open count of upper */
   75         int             uns_lower_openmode;     /* open mode of lower */
   76         int             uns_readdir_status;     /* read status of readdir */
   77 };
   78 
   79 /* union node status flags */
   80 #define UNS_OPENL_4_READDIR     0x01    /* open lower layer for readdir */
   81 
   82 /* A cache of vnode references */
   83 struct unionfs_node {
   84         struct vnode   *un_lowervp;             /* lower side vnode */
   85         struct vnode   *un_uppervp;             /* upper side vnode */
   86         struct vnode   *un_dvp;                 /* parent unionfs vnode */
   87         struct vnode   *un_vnode;               /* Back pointer */
   88         LIST_HEAD(, unionfs_node_status) un_unshead;
   89                                                 /* unionfs status head */
   90         LIST_HEAD(unionfs_node_hashhead, unionfs_node) *un_hashtbl;
   91                                                 /* dir vnode hash table */
   92         LIST_ENTRY(unionfs_node)   un_hash;     /* hash list entry */
   93         u_long          un_hashmask;            /* bit mask */
   94         char           *un_path;                /* path */
   95         int             un_flag;                /* unionfs node flag */
   96 };
   97 
   98 /*
   99  * unionfs node flags
  100  * It needs the vnode with exclusive lock, when changing the un_flag variable.
  101  */
  102 #define UNIONFS_OPENEXTL        0x01    /* openextattr (lower) */
  103 #define UNIONFS_OPENEXTU        0x02    /* openextattr (upper) */
  104 
  105 #define MOUNTTOUNIONFSMOUNT(mp) ((struct unionfs_mount *)((mp)->mnt_data))
  106 #define VTOUNIONFS(vp) ((struct unionfs_node *)(vp)->v_data)
  107 #define UNIONFSTOV(xp) ((xp)->un_vnode)
  108 
  109 int unionfs_init(struct vfsconf *vfsp);
  110 int unionfs_uninit(struct vfsconf *vfsp);
  111 int unionfs_nodeget(struct mount *mp, struct vnode *uppervp, struct vnode *lowervp, struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct thread *td);
  112 void unionfs_noderem(struct vnode *vp, struct thread *td);
  113 void unionfs_get_node_status(struct unionfs_node *unp, struct thread *td, struct unionfs_node_status **unspp);
  114 void unionfs_tryrem_node_status(struct unionfs_node *unp, struct unionfs_node_status *unsp);
  115 
  116 int unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td);
  117 int unionfs_copyfile(struct unionfs_node *unp, int docopy, struct ucred *cred, struct thread *td);
  118 void unionfs_create_uppervattr_core(struct unionfs_mount *ump, struct vattr *lva, struct vattr *uva, struct thread *td);
  119 int unionfs_create_uppervattr(struct unionfs_mount *ump, struct vnode *lvp, struct vattr *uva, struct ucred *cred, struct thread *td);
  120 int unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *duvp, struct unionfs_node *unp, struct componentname *cnp, struct thread *td);
  121 int unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp, struct thread *td, char *path);
  122 int unionfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct componentname *cn, struct thread *td, char *path, int pathlen, u_long nameiop);
  123 int unionfs_relookup_for_create(struct vnode *dvp, struct componentname *cnp, struct thread *td);
  124 int unionfs_relookup_for_delete(struct vnode *dvp, struct componentname *cnp, struct thread *td);
  125 int unionfs_relookup_for_rename(struct vnode *dvp, struct componentname *cnp, struct thread *td);
  126 
  127 #ifdef DIAGNOSTIC
  128 struct vnode   *unionfs_checklowervp(struct vnode *vp, char *fil, int lno);
  129 struct vnode   *unionfs_checkuppervp(struct vnode *vp, char *fil, int lno);
  130 #define UNIONFSVPTOLOWERVP(vp) unionfs_checklowervp((vp), __FILE__, __LINE__)
  131 #define UNIONFSVPTOUPPERVP(vp) unionfs_checkuppervp((vp), __FILE__, __LINE__)
  132 #else
  133 #define UNIONFSVPTOLOWERVP(vp) (VTOUNIONFS(vp)->un_lowervp)
  134 #define UNIONFSVPTOUPPERVP(vp) (VTOUNIONFS(vp)->un_uppervp)
  135 #endif
  136 
  137 extern struct vop_vector unionfs_vnodeops;
  138 
  139 #ifdef MALLOC_DECLARE
  140 MALLOC_DECLARE(M_UNIONFSNODE);
  141 MALLOC_DECLARE(M_UNIONFSPATH);
  142 #endif
  143 
  144 #ifdef UNIONFS_DEBUG
  145 #define UNIONFSDEBUG(format, args...) printf(format ,## args)
  146 #else
  147 #define UNIONFSDEBUG(format, args...)
  148 #endif                          /* UNIONFS_DEBUG */
  149 
  150 #endif                          /* _KERNEL */

Cache object: fef9dad1974dbdc9cfdeae993f60e929


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.