Klaus Demo nginx / 50034b8
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access) Igor Sysoev 15 years ago
9 changed file(s) with 20 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
7575
7676 /* open configuration file */
7777
78 fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
78 fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
7979 if (fd == NGX_INVALID_FILE) {
8080 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
8181 ngx_open_file_n " \"%s\" failed",
311311 }
312312
313313 file[i].fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
314 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
314 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND,
315 NGX_FILE_DEFAULT_ACCESS);
315316
316317 ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
317318 "log: %p %d \"%s\"",
848849 trunc = ngx_test_config ? 0 : NGX_FILE_TRUNCATE;
849850
850851 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
851 NGX_FILE_CREATE_OR_OPEN|trunc);
852 NGX_FILE_CREATE_OR_OPEN|trunc,
853 NGX_FILE_DEFAULT_ACCESS);
852854
853855 if (file.fd == NGX_INVALID_FILE) {
854856 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
958960 }
959961
960962 fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
961 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
963 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND,
964 NGX_FILE_DEFAULT_ACCESS);
962965
963966 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
964967 "reopen file \"%s\", old:%d new:%d",
208208 ngx_stderr_fileno = GetStdHandle(STD_ERROR_HANDLE);
209209
210210 ngx_stderr.fd = ngx_open_file(NGX_ERROR_LOG_PATH, NGX_FILE_RDWR,
211 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
211 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND, 0);
212212
213213 if (ngx_stderr.fd == NGX_INVALID_FILE) {
214214 ngx_message_box("nginx", MB_OK, ngx_errno,
132132 return NGX_HTTP_INTERNAL_SERVER_ERROR;
133133 }
134134
135 fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
135 fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
136136
137137 if (fd == NGX_INVALID_FILE) {
138138 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
108108 return NGX_HTTP_INTERNAL_SERVER_ERROR;
109109 }
110110
111 fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
111 fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
112112
113113 if (fd == NGX_INVALID_FILE) {
114114 err = ngx_errno;
244244 return NGX_HTTP_INTERNAL_SERVER_ERROR;
245245 }
246246
247 fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
247 fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
248248
249249 if (fd == (ngx_fd_t) NGX_AGAIN) {
250250 ctx->current = i;
125125 return NGX_HTTP_INTERNAL_SERVER_ERROR;
126126 }
127127
128 fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
128 fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
129129
130130 if (fd == NGX_INVALID_FILE) {
131131 err = ngx_errno;
1616
1717
1818
19 #define ngx_open_file(name, access, create) \
20 open((const char *) name, access|create, 0644)
19 #define ngx_open_file(name, mode, create, access) \
20 open((const char *) name, mode|create, access)
2121 #define ngx_open_file_n "open()"
2222
2323 #define NGX_FILE_RDONLY O_RDONLY
2626 #define NGX_FILE_OPEN 0
2727 #define NGX_FILE_TRUNCATE O_TRUNC
2828 #define NGX_FILE_APPEND O_APPEND
29
30 #define NGX_FILE_DEFAULT_ACCESS 0644
2931
3032
3133 #define ngx_close_file close
2727
2828
2929
30 #define ngx_open_file(name, access, create) \
31 CreateFile((const char *) name, access, \
30 #define ngx_open_file(name, mode, create, access) \
31 CreateFile((const char *) name, mode, \
3232 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
3333 NULL, create, FILE_FLAG_BACKUP_SEMANTICS, NULL)
3434 /*
4141 #define NGX_FILE_CREATE_OR_OPEN OPEN_ALWAYS
4242 #define NGX_FILE_OPEN OPEN_EXISTING
4343 #define NGX_FILE_APPEND 0
44
45 #define NGX_FILE_DEFAULT_ACCESS 0
4446
4547
4648 ngx_int_t ngx_file_append_mode(ngx_fd_t fd);