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 stat_cache_entry { 16 buffer name; 17 time_t stat_ts; 18 int fd; 19 int refcnt; 20 #if defined(HAVE_FAM_H) || defined(HAVE_SYS_INOTIFY_H) || defined(HAVE_SYS_EVENT_H) 21 void *fam_dir; 22 #endif 23 buffer etag; 24 buffer content_type; 25 struct stat st; 26 } stat_cache_entry; 27 28 __attribute_cold__ 29 int stat_cache_choose_engine (const buffer *stat_cache_string, log_error_st *errh); 30 31 struct fdevents; /* declaration */ 32 33 __attribute_cold__ 34 int stat_cache_init(struct fdevents *ev, log_error_st *errh); 35 36 __attribute_cold__ 37 void stat_cache_free(void); 38 39 void stat_cache_entry_refchg(void *data, int mod); 40 41 __attribute_cold__ 42 void stat_cache_xattrname (const char *name); 43 44 const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen); 45 #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) 46 const buffer * stat_cache_mimetype_by_xattr(const char *name); 47 const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr); 48 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr) 49 #else 50 const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes); 51 #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes) 52 #endif 53 const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags); 54 void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb); 55 void stat_cache_delete_entry(const char *name, uint32_t len); 56 void stat_cache_delete_dir(const char *name, uint32_t len); 57 void stat_cache_invalidate_entry(const char *name, uint32_t len); 58 stat_cache_entry * stat_cache_get_entry(const buffer *name); 59 stat_cache_entry * stat_cache_get_entry_open(const buffer *name, int symlinks); 60 const stat_cache_st * stat_cache_path_stat(const buffer *name); 61 int stat_cache_path_isdir(const buffer *name); 62 63 __attribute_cold__ 64 int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh); 65 66 int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks); 67 68 void stat_cache_trigger_cleanup(void); 69 #endif 70