xref: /titanic_44/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_cache.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *
24  *			cache.h
25  *
26  * Include file for the cache class.
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 /* Copyright (c) 1994 by Sun Microsystems, Inc. */
31 
32 #ifndef CFSD_CACHE
33 #define	CFSD_CACHE
34 
35 typedef struct cfsd_cache_object {
36 	char			 i_cachedir[MAXPATHLEN]; /* cache directory */
37 	int			 i_cacheid;		 /* cache id */
38 	cfsd_fscache_object_t	*i_fscachelist;		 /* list of fscaches */
39 	int			 i_fscachecount;	 /* # of objs in list */
40 	mutex_t			 i_lock;		 /* synchro lock */
41 	int			 i_refcnt;		 /* refs to object */
42 	int			 i_nextfscacheid;	 /* for fscache ids */
43 	int			 i_modify;		 /* changes when mod */
44 	struct cfsd_cache_object	*i_next;	 /* next cache object */
45 } cfsd_cache_object_t;
46 
47 cfsd_cache_object_t *cfsd_cache_create(void);
48 void cfsd_cache_destroy(cfsd_cache_object_t *cache_object_p);
49 
50 int cache_setup(cfsd_cache_object_t *cache_object_p, const char *cachedirp,
51     int cacheid);
52 void cache_lock(cfsd_cache_object_t *cache_object_p);
53 void cache_unlock(cfsd_cache_object_t *cache_object_p);
54 
55 cfsd_fscache_object_t *cache_fscachelist_at(cfsd_cache_object_t *cache_object_p,
56     size_t index);
57 void cache_fscachelist_add(cfsd_cache_object_t *cache_object_p,
58     cfsd_fscache_object_t *fscache_object_p);
59 cfsd_fscache_object_t *cache_fscachelist_find(
60     cfsd_cache_object_t *cache_object_p, const char *namep);
61 
62 #endif /* CFSD_CACHE */
63