2 * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by 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
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * Copyright (c) 1989, 1993
35 * The Regents of the University of California. All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * $DragonFly: src/sys/sys/namecache.h,v 1.6 2004/07/16 05:51:57 dillon Exp $
68 #ifndef _SYS_NAMECACHE_H_
69 #define _SYS_NAMECACHE_H_
73 TAILQ_HEAD(namecache_list, namecache);
76 * The namecache structure is used to manage the filesystem namespace. Most
77 * vnodes cached by the system will reference one or more associated namecache
80 * The namecache is disjoint, there may not always be a path to the system
81 * root through nc_parent links. If a namecache entry has no parent, that
82 * entry will not be hashed and can only be 'found' via '.' or '..'.
85 LIST_ENTRY(namecache) nc_hash; /* hash chain (nc_parent,name) */
86 TAILQ_ENTRY(namecache) nc_entry; /* scan via nc_parent->nc_list */
87 TAILQ_ENTRY(namecache) nc_vnode; /* scan via vnode->v_namecache */
88 struct namecache_list nc_list; /* list of children */
89 struct namecache *nc_parent; /* namecache entry for parent */
90 struct vnode *nc_vp; /* vnode representing name or NULL */
91 int nc_refs; /* ref count prevents deletion */
93 u_char nc_nlen; /* The length of the name, 255 max */
95 char *nc_name; /* Separately allocated seg name */
96 int nc_timeout; /* compared against ticks, or 0 */
99 typedef struct namecache *namecache_t;
102 * Flags in namecache.nc_flag (u_char)
104 #define NCF_NEGATIVE 0x01 /* negative entry */
105 #define NCF_WHITEOUT 0x02 /* negative entry corresponds to whiteout */
106 #define NCF_UNRESOLVED 0x04 /* invalid or unresolved entry */
107 #define NCF_MOUNTPT 0x08 /* mount point */
108 #define NCF_ROOT 0x10 /* namecache root (static) */
109 #define NCF_HASHED 0x20 /* namecache entry in hash table */
111 #define CINV_SELF 0x0001 /* invalidate a specific (dvp,vp) entry */
112 #define CINV_CHILDREN 0x0002 /* invalidate all children of vp */
114 #define NCPNULL ((struct namecache *)NULL) /* placemarker */
115 #define NCPPNULL ((struct namecache **)NULL) /* placemarker */
119 struct vop_lookup_args;
120 struct componentname;
123 int cache_lookup(struct vnode *dvp, struct namecache *par,
124 struct vnode **vpp, struct namecache **ncpp,
125 struct componentname *cnp);
126 void cache_mount(struct vnode *dvp, struct vnode *tvp);
127 void cache_enter(struct vnode *dvp, struct namecache *par,
128 struct vnode *vp, struct componentname *cnp);
129 void vfs_cache_setroot(struct vnode *vp);
130 void cache_purge(struct vnode *vp);
131 void cache_purgevfs (struct mount *mp);
132 void cache_drop(struct namecache *ncp);
133 struct namecache *cache_hold(struct namecache *ncp);
134 int cache_leaf_test (struct vnode *vp);
135 int vfs_cache_lookup(struct vop_lookup_args *ap);