xref: /lighttpd1.4/src/stat_cache.h (revision 86c2d309)
1 #ifndef _FILE_CACHE_H_
2 #define _FILE_CACHE_H_
3 #include "first.h"
4 
5 #include <sys/stat.h>
6 #include "sys-time.h"
7 
8 #include "base_decls.h"
9 #include "buffer.h"
10 #include "array.h"
11 
12 typedef struct stat stat_cache_st;
13 
14 typedef struct stat_cache_entry {
15     buffer name;
16     unix_time64_t stat_ts;
17     int fd;
18     int refcnt;
19   #if defined(HAVE_FAM_H) || defined(HAVE_SYS_INOTIFY_H) || defined(HAVE_SYS_EVENT_H)
20     void *fam_dir;
21   #endif
22     buffer etag;
23     buffer content_type;
24     struct stat st;
25 } stat_cache_entry;
26 
27 __attribute_cold__
28 int stat_cache_choose_engine (const buffer *stat_cache_string, log_error_st *errh);
29 
30 struct fdevents;        /* declaration */
31 
32 __attribute_cold__
33 int stat_cache_init(struct fdevents *ev, log_error_st *errh);
34 
35 __attribute_cold__
36 void stat_cache_free(void);
37 
38 void stat_cache_entry_refchg(void *data, int mod);
39 
40 __attribute_cold__
41 void stat_cache_xattrname (const char *name);
42 
43 __attribute_pure__
44 const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen);
45 
46 #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
47 const buffer * stat_cache_mimetype_by_xattr(const char *name);
48 const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr);
49 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr)
50 #else
51 const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes);
52 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes)
53 #endif
54 const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags);
55 void stat_cache_update_entry(const char *name, uint32_t len, const struct stat *st, const buffer *etagb);
56 void stat_cache_delete_entry(const char *name, uint32_t len);
57 void stat_cache_delete_dir(const char *name, uint32_t len);
58 void stat_cache_invalidate_entry(const char *name, uint32_t len);
59 stat_cache_entry * stat_cache_get_entry(const buffer *name);
60 stat_cache_entry * stat_cache_get_entry_open(const buffer *name, int symlinks);
61 const stat_cache_st * stat_cache_path_stat(const buffer *name);
62 int stat_cache_path_isdir(const buffer *name);
63 
64 __attribute_cold__
65 int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh);
66 
67 int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks);
68 
69 void stat_cache_trigger_cleanup(void);
70 #endif
71