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.4 2004/04/08 22:00:40 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 * The namecache is disjoint, there may not always be a path to the system
51 * root through nc_parent links. If a namecache entry has no parent, that
52 * entry will not be hashed and can only be 'found' via '.' or '..'.
55 LIST_ENTRY(namecache) nc_hash; /* hash chain (nc_parent,name) */
56 TAILQ_ENTRY(namecache) nc_entry; /* scan via nc_parent->nc_list */
57 TAILQ_ENTRY(namecache) nc_vnode; /* scan via vnode->v_namecache */
58 struct namecache_list nc_list; /* list of children */
59 struct namecache *nc_parent; /* namecache entry for parent */
60 struct vnode *nc_vp; /* vnode representing name or NULL */
61 int nc_refs; /* ref count prevents deletion */
63 u_char nc_nlen; /* The length of the name, 255 max */
65 char *nc_name; /* Separately allocated seg name */
66 int nc_timeout; /* compared against ticks, or 0 */
69 typedef struct namecache *namecache_t;
72 * Flags in namecache.nc_flag (u_char)
74 #define NCF_NEGATIVE 0x01 /* negative entry */
75 #define NCF_WHITEOUT 0x02 /* negative entry corresponds to whiteout */
76 #define NCF_UNRESOLVED 0x04 /* invalid or unresolved entry */
77 #define NCF_MOUNTPT 0x08 /* mount point */
78 #define NCF_ROOT 0x10 /* namecache root (static) */
79 #define NCF_HASHED 0x20 /* namecache entry in hash table */
81 #define CINV_SELF 0x0001 /* invalidate a specific (dvp,vp) entry */
82 #define CINV_CHILDREN 0x0002 /* invalidate all children of vp */
84 #define NCPNULL ((struct namecache *)NULL) /* placemarker */
85 #define NCPPNULL ((struct namecache **)NULL) /* placemarker */
89 struct vop_lookup_args;
93 int cache_lookup(struct vnode *dvp, struct namecache *par,
94 struct vnode **vpp, struct namecache **ncpp,
95 struct componentname *cnp);
96 void cache_mount(struct vnode *dvp, struct vnode *tvp);
97 void cache_enter(struct vnode *dvp, struct namecache *par,
98 struct vnode *vp, struct componentname *cnp);
99 void vfs_cache_setroot(struct vnode *vp);
100 void cache_purge(struct vnode *vp);
101 void cache_purgevfs (struct mount *mp);
102 void cache_drop(struct namecache *ncp);
103 struct namecache *cache_hold(struct namecache *ncp);
104 int cache_leaf_test (struct vnode *vp);
105 int vfs_cache_lookup(struct vop_lookup_args *ap);
106 int textvp_fullpath (struct proc *p, char **retbuf, char **retfreebuf);