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