Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_FILE_H_INCLUDED_
0009 #define _NGX_FILE_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 
0015 
0016 struct ngx_file_s {
0017     ngx_fd_t                   fd;
0018     ngx_str_t                  name;
0019     ngx_file_info_t            info;
0020 
0021     off_t                      offset;
0022     off_t                      sys_offset;
0023 
0024     ngx_log_t                 *log;
0025 
0026 #if (NGX_THREADS || NGX_COMPAT)
0027     ngx_int_t                (*thread_handler)(ngx_thread_task_t *task,
0028                                                ngx_file_t *file);
0029     void                      *thread_ctx;
0030     ngx_thread_task_t         *thread_task;
0031 #endif
0032 
0033 #if (NGX_HAVE_FILE_AIO || NGX_COMPAT)
0034     ngx_event_aio_t           *aio;
0035 #endif
0036 
0037     unsigned                   valid_info:1;
0038     unsigned                   directio:1;
0039 };
0040 
0041 
0042 #define NGX_MAX_PATH_LEVEL  3
0043 
0044 
0045 typedef ngx_msec_t (*ngx_path_manager_pt) (void *data);
0046 typedef ngx_msec_t (*ngx_path_purger_pt) (void *data);
0047 typedef void (*ngx_path_loader_pt) (void *data);
0048 
0049 
0050 typedef struct {
0051     ngx_str_t                  name;
0052     size_t                     len;
0053     size_t                     level[NGX_MAX_PATH_LEVEL];
0054 
0055     ngx_path_manager_pt        manager;
0056     ngx_path_purger_pt         purger;
0057     ngx_path_loader_pt         loader;
0058     void                      *data;
0059 
0060     u_char                    *conf_file;
0061     ngx_uint_t                 line;
0062 } ngx_path_t;
0063 
0064 
0065 typedef struct {
0066     ngx_str_t                  name;
0067     size_t                     level[NGX_MAX_PATH_LEVEL];
0068 } ngx_path_init_t;
0069 
0070 
0071 typedef struct {
0072     ngx_file_t                 file;
0073     off_t                      offset;
0074     ngx_path_t                *path;
0075     ngx_pool_t                *pool;
0076     char                      *warn;
0077 
0078     ngx_uint_t                 access;
0079 
0080     unsigned                   log_level:8;
0081     unsigned                   persistent:1;
0082     unsigned                   clean:1;
0083     unsigned                   thread_write:1;
0084 } ngx_temp_file_t;
0085 
0086 
0087 typedef struct {
0088     ngx_uint_t                 access;
0089     ngx_uint_t                 path_access;
0090     time_t                     time;
0091     ngx_fd_t                   fd;
0092 
0093     unsigned                   create_path:1;
0094     unsigned                   delete_file:1;
0095 
0096     ngx_log_t                 *log;
0097 } ngx_ext_rename_file_t;
0098 
0099 
0100 typedef struct {
0101     off_t                      size;
0102     size_t                     buf_size;
0103 
0104     ngx_uint_t                 access;
0105     time_t                     time;
0106 
0107     ngx_log_t                 *log;
0108 } ngx_copy_file_t;
0109 
0110 
0111 typedef struct ngx_tree_ctx_s  ngx_tree_ctx_t;
0112 
0113 typedef ngx_int_t (*ngx_tree_init_handler_pt) (void *ctx, void *prev);
0114 typedef ngx_int_t (*ngx_tree_handler_pt) (ngx_tree_ctx_t *ctx, ngx_str_t *name);
0115 
0116 struct ngx_tree_ctx_s {
0117     off_t                      size;
0118     off_t                      fs_size;
0119     ngx_uint_t                 access;
0120     time_t                     mtime;
0121 
0122     ngx_tree_init_handler_pt   init_handler;
0123     ngx_tree_handler_pt        file_handler;
0124     ngx_tree_handler_pt        pre_tree_handler;
0125     ngx_tree_handler_pt        post_tree_handler;
0126     ngx_tree_handler_pt        spec_handler;
0127 
0128     void                      *data;
0129     size_t                     alloc;
0130 
0131     ngx_log_t                 *log;
0132 };
0133 
0134 
0135 ngx_int_t ngx_get_full_name(ngx_pool_t *pool, ngx_str_t *prefix,
0136     ngx_str_t *name);
0137 
0138 ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain);
0139 ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
0140     ngx_pool_t *pool, ngx_uint_t persistent, ngx_uint_t clean,
0141     ngx_uint_t access);
0142 void ngx_create_hashed_filename(ngx_path_t *path, u_char *file, size_t len);
0143 ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path);
0144 ngx_err_t ngx_create_full_path(u_char *dir, ngx_uint_t access);
0145 ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot);
0146 ngx_int_t ngx_create_paths(ngx_cycle_t *cycle, ngx_uid_t user);
0147 ngx_int_t ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to,
0148     ngx_ext_rename_file_t *ext);
0149 ngx_int_t ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf);
0150 ngx_int_t ngx_walk_tree(ngx_tree_ctx_t *ctx, ngx_str_t *tree);
0151 
0152 ngx_atomic_uint_t ngx_next_temp_number(ngx_uint_t collision);
0153 
0154 char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0155 char *ngx_conf_merge_path_value(ngx_conf_t *cf, ngx_path_t **path,
0156     ngx_path_t *prev, ngx_path_init_t *init);
0157 char *ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0158 
0159 
0160 extern ngx_atomic_t      *ngx_temp_number;
0161 extern ngx_atomic_int_t   ngx_random_number;
0162 
0163 
0164 #endif /* _NGX_FILE_H_INCLUDED_ */