1 |
dpavlin |
4 |
/* |
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 |
|
|
#include <fuse.h> |
27 |
|
|
|
28 |
|
|
#ifdef __cplusplus |
29 |
|
|
extern "C" { |
30 |
|
|
#endif |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
#define NBUCKETS 7 |
34 |
|
|
#define DEF_NENTRIES 6 |
35 |
|
|
#define DEF_TTL 20 |
36 |
|
|
|
37 |
|
|
struct list_head; |
38 |
|
|
|
39 |
|
|
struct direntry{ |
40 |
|
|
char *e_name; |
41 |
|
|
char *e_link; |
42 |
|
|
struct list_head e_list; |
43 |
|
|
struct lufs_fattr e_attr; |
44 |
|
|
}; |
45 |
|
|
|
46 |
|
|
struct directory{ |
47 |
|
|
char *d_name; |
48 |
|
|
struct list_head d_entries; |
49 |
|
|
struct list_head d_list; |
50 |
|
|
unsigned long d_stamp; |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
|
struct dir_cache{ |
54 |
|
|
int ttl; |
55 |
|
|
int entries; |
56 |
|
|
pthread_mutex_t lock; |
57 |
|
|
struct list_head buckets[NBUCKETS]; |
58 |
|
|
int lengths[NBUCKETS]; |
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
struct dir_cache* lu_cache_create(struct list_head*); |
62 |
|
|
void lu_cache_destroy(struct dir_cache*); |
63 |
|
|
|
64 |
|
|
int lu_cache_lookup_file(struct dir_cache*, char*, struct lufs_fattr*, char*, int); |
65 |
|
|
void lu_cache_add(struct dir_cache*, char*, char*, struct lufs_fattr*, char*); |
66 |
|
|
int lu_cache_readdir(struct dir_cache *cache, char *dir, |
67 |
|
|
fuse_dirh_t h, fuse_dirfil_t filler); |
68 |
|
|
int lu_cache_invalidate(struct dir_cache*, char*); |
69 |
|
|
|
70 |
|
|
|
71 |
|
|
#ifdef __cplusplus |
72 |
|
|
} |
73 |
|
|
#endif |
74 |
|
|
|
75 |
|
|
#endif |