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 9 #include <sys/types.h> 10 #include <sys/time.h> 11 #include <sys/stat.h> 12 13 typedef struct { 14 buffer name; 15 time_t stat_ts; 16 #ifdef HAVE_FAM_H 17 void *fam_dir; 18 #endif 19 buffer etag; 20 buffer content_type; 21 struct stat st; 22 } stat_cache_entry; 23 24 __attribute_cold__ 25 int stat_cache_choose_engine (const buffer *stat_cache_string, log_error_st *errh); 26 27 struct fdevents; /* declaration */ 28 29 __attribute_cold__ 30 int stat_cache_init(struct fdevents *ev, log_error_st *errh); 31 32 __attribute_cold__ 33 void stat_cache_free(void); 34 35 __attribute_cold__ 36 void stat_cache_xattrname (const char *name); 37 38 const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen); 39 #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) 40 const buffer * stat_cache_mimetype_by_xattr(const char *name); 41 const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr); 42 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr) 43 #else 44 const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes); 45 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes) 46 #endif 47 const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags); 48 void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb); 49 void stat_cache_delete_entry(const char *name, uint32_t len); 50 void stat_cache_delete_dir(const char *name, uint32_t len); 51 void stat_cache_invalidate_entry(const char *name, uint32_t len); 52 stat_cache_entry * stat_cache_get_entry(const buffer *name); 53 int stat_cache_path_isdir(const buffer *name); 54 55 __attribute_cold__ 56 int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh); 57 58 int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks); 59 60 void stat_cache_trigger_cleanup(void); 61 #endif 62