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 stat stat_cache_st; 14 15 typedef struct { 16 buffer name; 17 time_t stat_ts; 18 int fd; 19 #ifdef HAVE_FAM_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 __attribute_cold__ 39 void stat_cache_xattrname (const char *name); 40 41 const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen); 42 #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) 43 const buffer * stat_cache_mimetype_by_xattr(const char *name); 44 const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr); 45 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr) 46 #else 47 const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes); 48 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes) 49 #endif 50 const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags); 51 void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb); 52 void stat_cache_delete_entry(const char *name, uint32_t len); 53 void stat_cache_delete_dir(const char *name, uint32_t len); 54 void stat_cache_invalidate_entry(const char *name, uint32_t len); 55 stat_cache_entry * stat_cache_get_entry(const buffer *name); 56 stat_cache_entry * stat_cache_get_entry_open(const buffer *name, int symlinks); 57 const stat_cache_st * stat_cache_path_stat(const buffer *name); 58 int stat_cache_path_isdir(const buffer *name); 59 60 __attribute_cold__ 61 int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh); 62 63 int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks); 64 65 void stat_cache_trigger_cleanup(void); 66 #endif 67