http://prdownloads.sourceforge.net/lufs/lufs-0.9.6.tar.gz?download
[lufs.git] / lufsd / dircache.h
1 /*
2  * dircache.h
3  * Copyright (C) 2002 Florin Malita <mali@go.ro>
4  *
5  * This file is part of LUFS, a free userspace filesystem implementation.
6  * See http://lufs.sourceforge.net/ for updates.
7  *
8  * LUFS is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * LUFS is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef _DIRCACHE_H_
24 #define _DIRCACHE_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30
31 #define NBUCKETS        7
32 #define DEF_NENTRIES    6
33 #define DEF_TTL         20
34
35 struct list_head;
36
37 struct direntry{
38     char                *e_name;
39     char                *e_link;
40     struct list_head    e_list;
41     struct lufs_fattr   e_attr;
42 };
43
44 struct directory{
45     char                *d_name;
46     struct list_head    d_entries;
47     struct list_head    d_list;
48     unsigned long d_stamp;
49 };
50
51 struct dir_cache{
52     int                 ttl;
53     int                 entries;
54     pthread_mutex_t     lock;
55     struct list_head    buckets[NBUCKETS];
56     int                 lengths[NBUCKETS];
57 };
58
59 struct dir_cache* lu_cache_create(struct list_head*);
60 void lu_cache_destroy(struct dir_cache*);
61
62 int lu_cache_lookup_file(struct dir_cache*, char*, struct lufs_fattr*, char*, int);
63 void lu_cache_add(struct dir_cache*, char*, char*, struct lufs_fattr*, char*);
64 int lu_cache_readdir(struct dir_cache*, char*, int, char*, int);
65 int lu_cache_invalidate(struct dir_cache*, char*);
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif