2005-08-08 08:22:06 +00:00
|
|
|
#ifndef _FILE_CACHE_H_
|
|
|
|
#define _FILE_CACHE_H_
|
2016-03-19 15:14:35 +00:00
|
|
|
#include "first.h"
|
2005-08-08 08:22:06 +00:00
|
|
|
|
2021-04-28 17:18:37 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include "sys-time.h"
|
|
|
|
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "base_decls.h"
|
|
|
|
#include "buffer.h"
|
2019-12-05 08:16:25 +00:00
|
|
|
#include "array.h"
|
2018-03-25 07:45:05 +00:00
|
|
|
|
2020-10-13 17:57:37 +00:00
|
|
|
typedef struct stat stat_cache_st;
|
|
|
|
|
2020-10-20 01:36:46 +00:00
|
|
|
typedef struct stat_cache_entry {
|
2019-12-05 08:16:25 +00:00
|
|
|
buffer name;
|
2021-07-12 18:46:49 +00:00
|
|
|
unix_time64_t stat_ts;
|
2020-10-10 11:55:04 +00:00
|
|
|
int fd;
|
2020-10-20 01:36:46 +00:00
|
|
|
int refcnt;
|
2020-11-04 09:20:00 +00:00
|
|
|
#if defined(HAVE_FAM_H) || defined(HAVE_SYS_INOTIFY_H) || defined(HAVE_SYS_EVENT_H)
|
2019-12-05 08:16:25 +00:00
|
|
|
void *fam_dir;
|
2020-11-03 05:46:50 +00:00
|
|
|
#endif
|
2019-12-05 08:16:25 +00:00
|
|
|
buffer etag;
|
|
|
|
buffer content_type;
|
|
|
|
struct stat st;
|
2018-03-25 07:45:05 +00:00
|
|
|
} stat_cache_entry;
|
|
|
|
|
2019-02-04 04:27:57 +00:00
|
|
|
__attribute_cold__
|
2019-12-26 02:51:20 +00:00
|
|
|
int stat_cache_choose_engine (const buffer *stat_cache_string, log_error_st *errh);
|
|
|
|
|
|
|
|
struct fdevents; /* declaration */
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2019-12-26 02:51:20 +00:00
|
|
|
int stat_cache_init(struct fdevents *ev, log_error_st *errh);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2019-12-05 08:16:25 +00:00
|
|
|
void stat_cache_free(void);
|
2005-08-08 08:22:06 +00:00
|
|
|
|
2020-10-20 01:36:46 +00:00
|
|
|
void stat_cache_entry_refchg(void *data, int mod);
|
|
|
|
|
2019-12-05 08:16:25 +00:00
|
|
|
__attribute_cold__
|
|
|
|
void stat_cache_xattrname (const char *name);
|
|
|
|
|
2021-03-15 09:41:50 +00:00
|
|
|
__attribute_pure__
|
2020-07-09 21:51:01 +00:00
|
|
|
const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen);
|
2021-03-15 09:41:50 +00:00
|
|
|
|
2019-12-05 08:16:25 +00:00
|
|
|
#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
|
|
|
|
const buffer * stat_cache_mimetype_by_xattr(const char *name);
|
|
|
|
const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr);
|
2020-01-13 02:51:12 +00:00
|
|
|
#define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_xattr((sce), (r)->conf.mimetypes, (r)->conf.use_xattr)
|
2019-12-05 08:16:25 +00:00
|
|
|
#else
|
|
|
|
const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const array *mimetypes);
|
2020-01-13 02:51:12 +00:00
|
|
|
#define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes)
|
2019-12-05 08:16:25 +00:00
|
|
|
#endif
|
2019-11-16 01:26:54 +00:00
|
|
|
const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags);
|
2020-07-09 21:51:01 +00:00
|
|
|
void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb);
|
|
|
|
void stat_cache_delete_entry(const char *name, uint32_t len);
|
|
|
|
void stat_cache_delete_dir(const char *name, uint32_t len);
|
|
|
|
void stat_cache_invalidate_entry(const char *name, uint32_t len);
|
2019-12-05 08:16:25 +00:00
|
|
|
stat_cache_entry * stat_cache_get_entry(const buffer *name);
|
2020-10-10 11:55:04 +00:00
|
|
|
stat_cache_entry * stat_cache_get_entry_open(const buffer *name, int symlinks);
|
2020-10-13 17:57:37 +00:00
|
|
|
const stat_cache_st * stat_cache_path_stat(const buffer *name);
|
2020-10-09 17:33:48 +00:00
|
|
|
int stat_cache_path_isdir(const buffer *name);
|
2020-09-29 17:38:29 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2019-12-05 08:16:25 +00:00
|
|
|
int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh);
|
2020-09-29 17:38:29 +00:00
|
|
|
|
2019-11-26 03:38:16 +00:00
|
|
|
int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks);
|
2005-08-08 08:22:06 +00:00
|
|
|
|
2019-12-05 08:16:25 +00:00
|
|
|
void stat_cache_trigger_cleanup(void);
|
2005-08-08 08:22:06 +00:00
|
|
|
#endif
|