xref: /lighttpd1.4/src/stat_cache.h (revision df070173)
15e134da0SJan Kneschke #ifndef _FILE_CACHE_H_
25e134da0SJan Kneschke #define _FILE_CACHE_H_
38abd06a7SGlenn Strauss #include "first.h"
45e134da0SJan Kneschke 
513ea2d88SGlenn Strauss #include <sys/stat.h>
613ea2d88SGlenn Strauss #include "sys-time.h"
713ea2d88SGlenn Strauss 
804d76e7aSGlenn Strauss #include "base_decls.h"
904d76e7aSGlenn Strauss #include "buffer.h"
1068d8d4c5SGlenn Strauss #include "array.h"
1104d76e7aSGlenn Strauss 
12fe021118SGlenn Strauss typedef struct stat stat_cache_st;
13fe021118SGlenn Strauss 
147f8ab9ddSGlenn Strauss typedef struct stat_cache_entry {
1568d8d4c5SGlenn Strauss     buffer name;
16309c1693SGlenn Strauss     unix_time64_t stat_ts;
17d8e5e21eSGlenn Strauss     int fd;
187f8ab9ddSGlenn Strauss     int refcnt;
190b00b13aSGlenn Strauss   #if defined(HAVE_FAM_H) || defined(HAVE_SYS_INOTIFY_H) || defined(HAVE_SYS_EVENT_H)
208cc189f4SGlenn Strauss     void *fam_dir;
2104d76e7aSGlenn Strauss   #endif
2268d8d4c5SGlenn Strauss     buffer etag;
2368d8d4c5SGlenn Strauss     buffer content_type;
2468d8d4c5SGlenn Strauss     struct stat st;
2504d76e7aSGlenn Strauss } stat_cache_entry;
2604d76e7aSGlenn Strauss 
27fb9b8ad8SGlenn Strauss __attribute_cold__
2866bdd96dSGlenn Strauss int stat_cache_choose_engine (const buffer *stat_cache_string, log_error_st *errh);
2966bdd96dSGlenn Strauss 
3066bdd96dSGlenn Strauss struct fdevents;        /* declaration */
31fb9b8ad8SGlenn Strauss 
32fb9b8ad8SGlenn Strauss __attribute_cold__
3366bdd96dSGlenn Strauss int stat_cache_init(struct fdevents *ev, log_error_st *errh);
34fb9b8ad8SGlenn Strauss 
35fb9b8ad8SGlenn Strauss __attribute_cold__
3668d8d4c5SGlenn Strauss void stat_cache_free(void);
375e134da0SJan Kneschke 
387f8ab9ddSGlenn Strauss void stat_cache_entry_refchg(void *data, int mod);
397f8ab9ddSGlenn Strauss 
4068d8d4c5SGlenn Strauss __attribute_cold__
4168d8d4c5SGlenn Strauss void stat_cache_xattrname (const char *name);
4268d8d4c5SGlenn Strauss 
4319bc8885SGlenn Strauss __attribute_pure__
44d334eaf1SGlenn Strauss const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen);
4519bc8885SGlenn Strauss 
4668d8d4c5SGlenn Strauss #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
4768d8d4c5SGlenn Strauss const buffer * stat_cache_mimetype_by_xattr(const char *name);
4868d8d4c5SGlenn Strauss const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr);
497c7f8c46SGlenn Strauss #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr)
5068d8d4c5SGlenn Strauss #else
5168d8d4c5SGlenn Strauss const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes);
527c7f8c46SGlenn Strauss #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes)
5368d8d4c5SGlenn Strauss #endif
54ed62e354SGlenn Strauss const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags);
55*df070173SGlenn Strauss void stat_cache_update_entry(const char *name, uint32_t len, const struct stat *st, const buffer *etagb);
56d334eaf1SGlenn Strauss void stat_cache_delete_entry(const char *name, uint32_t len);
57d334eaf1SGlenn Strauss void stat_cache_delete_dir(const char *name, uint32_t len);
58d334eaf1SGlenn Strauss void stat_cache_invalidate_entry(const char *name, uint32_t len);
5968d8d4c5SGlenn Strauss stat_cache_entry * stat_cache_get_entry(const buffer *name);
60d8e5e21eSGlenn Strauss stat_cache_entry * stat_cache_get_entry_open(const buffer *name, int symlinks);
61fe021118SGlenn Strauss const stat_cache_st * stat_cache_path_stat(const buffer *name);
627d368cd7SGlenn Strauss int stat_cache_path_isdir(const buffer *name);
6386e5f090SGlenn Strauss 
6486e5f090SGlenn Strauss __attribute_cold__
6568d8d4c5SGlenn Strauss int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh);
6686e5f090SGlenn Strauss 
670fcd5143SGlenn Strauss int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks);
685e134da0SJan Kneschke 
6968d8d4c5SGlenn Strauss void stat_cache_trigger_cleanup(void);
705e134da0SJan Kneschke #endif
71