xref: /lighttpd1.4/src/stat_cache.h (revision 68d8d4c5)
1 #ifndef _FILE_CACHE_H_
2 #define _FILE_CACHE_H_
3 #include "first.h"
4 
5 #include "base_decls.h"
6 #include "buffer.h"
7 #include "array.h"
8 #include "etag.h"
9 
10 #include <sys/types.h>
11 #include <sys/time.h>
12 #include <sys/stat.h>
13 
14 typedef struct {
15     buffer name;
16     time_t stat_ts;
17 #ifdef HAVE_FAM_H
18     void *fam_dir;
19 #endif
20     buffer etag;
21     buffer content_type;
22     struct stat st;
23 } stat_cache_entry;
24 
25 __attribute_cold__
26 int stat_cache_choose_engine (server *srv, const buffer *stat_cache_string);
27 
28 __attribute_cold__
29 int stat_cache_init(server *srv);
30 
31 __attribute_cold__
32 void stat_cache_free(void);
33 
34 __attribute_cold__
35 void stat_cache_xattrname (const char *name);
36 
37 const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, size_t nlen);
38 #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
39 const buffer * stat_cache_mimetype_by_xattr(const char *name);
40 const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr);
41 #define stat_cache_content_type_get(con, sce) stat_cache_content_type_get_by_xattr((sce), (con)->conf.mimetypes, (con)->conf.use_xattr)
42 #else
43 const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes);
44 #define stat_cache_content_type_get(con, sce) stat_cache_content_type_get_by_ext((sce), (con)->conf.mimetypes)
45 #endif
46 const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags);
47 void stat_cache_update_entry(const char *name, size_t len, struct stat *st, buffer *etagb);
48 void stat_cache_delete_entry(const char *name, size_t len);
49 void stat_cache_delete_dir(const char *name, size_t len);
50 void stat_cache_invalidate_entry(const char *name, size_t len);
51 stat_cache_entry * stat_cache_get_entry(const buffer *name);
52 int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh);
53 int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks);
54 
55 void stat_cache_trigger_cleanup(void);
56 #endif
57