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 int fd; 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 (const buffer *stat_cache_string, log_error_st *errh); 27 28 struct fdevents; /* declaration */ 29 30 __attribute_cold__ 31 int stat_cache_init(struct fdevents *ev, log_error_st *errh); 32 33 __attribute_cold__ 34 void stat_cache_free(void); 35 36 __attribute_cold__ 37 void stat_cache_xattrname (const char *name); 38 39 const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen); 40 #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) 41 const buffer * stat_cache_mimetype_by_xattr(const char *name); 42 const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr); 43 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr) 44 #else 45 const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes); 46 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes) 47 #endif 48 const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags); 49 void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb); 50 void stat_cache_delete_entry(const char *name, uint32_t len); 51 void stat_cache_delete_dir(const char *name, uint32_t len); 52 void stat_cache_invalidate_entry(const char *name, uint32_t len); 53 stat_cache_entry * stat_cache_get_entry(const buffer *name); 54 stat_cache_entry * stat_cache_get_entry_open(const buffer *name, int symlinks); 55 int stat_cache_path_isdir(const buffer *name); 56 57 __attribute_cold__ 58 int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh); 59 60 int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks); 61 62 void stat_cache_trigger_cleanup(void); 63 #endif 64