2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 2003 Matthew Dillon <dillon@backplane.com>,
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * $DragonFly: src/sys/sys/namecache.h,v 1.2 2003/10/09 22:27:20 dillon Exp $
38 #ifndef _SYS_NAMECACHE_H_
39 #define _SYS_NAMECACHE_H_
43 TAILQ_HEAD(namecache_list, namecache);
46 * The namecache structure is used to manage the filesystem namespace. Most
47 * vnodes cached by the system will reference one or more associated namecache
50 * STAGE-2: nc_parent mostly unused because we cannot yet guarentee
51 * consistency in the topology. nc_dvp_data and nc_dvp_id
52 * are used instead but will be removed in stage-3.
54 * nc_dvp_data/nc_dvp_id used temporarily because nc_parent
55 * not yet useable, will be removed in STAGE-3.
57 * STAGE-3: nc_parent guarenteed to not be NULL, used exclusively.
60 LIST_ENTRY(namecache) nc_hash; /* hash chain (nc_parent,name) */
61 TAILQ_ENTRY(namecache) nc_entry; /* scan via nc_parent->nc_list */
62 TAILQ_ENTRY(namecache) nc_vnode; /* scan via vnode->v_namecache */
63 struct namecache_list nc_list; /* list of children */
64 struct namecache *nc_parent; /* namecache entry for parent */
65 struct vnode *nc_vp; /* vnode representing name or NULL */
66 uintptr_t nc_dvp_data; /* hash key helper STAGE-2 ONLY */
67 u_long nc_dvp_id; /* hash key helper STAGE-2 ONLY */
68 int nc_refs; /* ref count prevents deletion */
70 u_char nc_nlen; /* The length of the name, 255 max */
72 char *nc_name; /* Separately allocated seg name */
75 typedef struct namecache *namecache_t;
78 * Flags in namecache.nc_flag (u_char)
80 #define NCF_NEGATIVE 0x01 /* negative entry */
81 #define NCF_WHITEOUT 0x02 /* negative entry corresponds to whiteout */
82 #define NCF_UNRESOLVED 0x04 /* invalid or unresolved entry */
83 #define NCF_MOUNTPT 0x08 /* mount point */
84 #define NCF_ROOT 0x10 /* namecache root (static) */
85 #define NCF_HASHED 0x20 /* namecache entry in hash table */
87 #define CINV_SELF 0x0001 /* invalidate a specific (dvp,vp) entry */
88 #define CINV_CHILDREN 0x0002 /* invalidate all children of vp */
90 #define NCPNULL ((struct namecache *)NULL) /* placemarker */
91 #define NCPPNULL ((struct namecache **)NULL) /* placemarker */
95 struct vop_lookup_args;
99 int cache_lookup(struct vnode *dvp, struct namecache *par,
100 struct vnode **vpp, struct namecache **ncpp,
101 struct componentname *cnp);
102 void cache_mount(struct vnode *dvp, struct vnode *tvp);
103 void cache_enter(struct vnode *dvp, struct namecache *par,
104 struct vnode *vp, struct componentname *cnp);
105 void vfs_cache_setroot(struct vnode *vp);
106 void cache_purge(struct vnode *vp);
107 void cache_purgevfs (struct mount *mp);
108 void cache_drop(struct namecache *ncp);
109 struct namecache *cache_hold(struct namecache *ncp);
110 int cache_leaf_test (struct vnode *vp);
111 int vfs_cache_lookup(struct vop_lookup_args *ap);
112 int textvp_fullpath (struct proc *p, char **retbuf, char **retfreebuf);