mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
This commit is contained in:
parent
12fcfab8be
commit
50034b856c
@ -76,7 +76,7 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
|||||||
|
|
||||||
/* open configuration file */
|
/* open configuration file */
|
||||||
|
|
||||||
fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
|
fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
|
||||||
if (fd == NGX_INVALID_FILE) {
|
if (fd == NGX_INVALID_FILE) {
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
||||||
ngx_open_file_n " \"%s\" failed",
|
ngx_open_file_n " \"%s\" failed",
|
||||||
|
@ -312,7 +312,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file[i].fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
|
file[i].fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
|
||||||
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
|
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND,
|
||||||
|
NGX_FILE_DEFAULT_ACCESS);
|
||||||
|
|
||||||
ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
|
ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
|
||||||
"log: %p %d \"%s\"",
|
"log: %p %d \"%s\"",
|
||||||
@ -849,7 +850,8 @@ ngx_create_pidfile(ngx_str_t *name, ngx_log_t *log)
|
|||||||
trunc = ngx_test_config ? 0 : NGX_FILE_TRUNCATE;
|
trunc = ngx_test_config ? 0 : NGX_FILE_TRUNCATE;
|
||||||
|
|
||||||
file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
|
file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
|
||||||
NGX_FILE_CREATE_OR_OPEN|trunc);
|
NGX_FILE_CREATE_OR_OPEN|trunc,
|
||||||
|
NGX_FILE_DEFAULT_ACCESS);
|
||||||
|
|
||||||
if (file.fd == NGX_INVALID_FILE) {
|
if (file.fd == NGX_INVALID_FILE) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||||
@ -959,7 +961,8 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
|
fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
|
||||||
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
|
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND,
|
||||||
|
NGX_FILE_DEFAULT_ACCESS);
|
||||||
|
|
||||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
"reopen file \"%s\", old:%d new:%d",
|
"reopen file \"%s\", old:%d new:%d",
|
||||||
|
@ -209,7 +209,7 @@ ngx_log_init(void)
|
|||||||
ngx_stderr_fileno = GetStdHandle(STD_ERROR_HANDLE);
|
ngx_stderr_fileno = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
|
||||||
ngx_stderr.fd = ngx_open_file(NGX_ERROR_LOG_PATH, NGX_FILE_RDWR,
|
ngx_stderr.fd = ngx_open_file(NGX_ERROR_LOG_PATH, NGX_FILE_RDWR,
|
||||||
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
|
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND, 0);
|
||||||
|
|
||||||
if (ngx_stderr.fd == NGX_INVALID_FILE) {
|
if (ngx_stderr.fd == NGX_INVALID_FILE) {
|
||||||
ngx_message_box("nginx", MB_OK, ngx_errno,
|
ngx_message_box("nginx", MB_OK, ngx_errno,
|
||||||
|
@ -133,7 +133,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
|
|||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
|
fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
|
||||||
|
|
||||||
if (fd == NGX_INVALID_FILE) {
|
if (fd == NGX_INVALID_FILE) {
|
||||||
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
||||||
|
@ -109,7 +109,7 @@ ngx_http_flv_handler(ngx_http_request_t *r)
|
|||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
|
fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
|
||||||
|
|
||||||
if (fd == NGX_INVALID_FILE) {
|
if (fd == NGX_INVALID_FILE) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
@ -245,7 +245,7 @@ ngx_http_index_handler(ngx_http_request_t *r)
|
|||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
|
fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
|
||||||
|
|
||||||
if (fd == (ngx_fd_t) NGX_AGAIN) {
|
if (fd == (ngx_fd_t) NGX_AGAIN) {
|
||||||
ctx->current = i;
|
ctx->current = i;
|
||||||
|
@ -126,7 +126,7 @@ ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
|
fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
|
||||||
|
|
||||||
if (fd == NGX_INVALID_FILE) {
|
if (fd == NGX_INVALID_FILE) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define ngx_open_file(name, access, create) \
|
#define ngx_open_file(name, mode, create, access) \
|
||||||
open((const char *) name, access|create, 0644)
|
open((const char *) name, mode|create, access)
|
||||||
#define ngx_open_file_n "open()"
|
#define ngx_open_file_n "open()"
|
||||||
|
|
||||||
#define NGX_FILE_RDONLY O_RDONLY
|
#define NGX_FILE_RDONLY O_RDONLY
|
||||||
@ -28,6 +28,8 @@
|
|||||||
#define NGX_FILE_TRUNCATE O_TRUNC
|
#define NGX_FILE_TRUNCATE O_TRUNC
|
||||||
#define NGX_FILE_APPEND O_APPEND
|
#define NGX_FILE_APPEND O_APPEND
|
||||||
|
|
||||||
|
#define NGX_FILE_DEFAULT_ACCESS 0644
|
||||||
|
|
||||||
|
|
||||||
#define ngx_close_file close
|
#define ngx_close_file close
|
||||||
#define ngx_close_file_n "close()"
|
#define ngx_close_file_n "close()"
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define ngx_open_file(name, access, create) \
|
#define ngx_open_file(name, mode, create, access) \
|
||||||
CreateFile((const char *) name, access, \
|
CreateFile((const char *) name, mode, \
|
||||||
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
|
||||||
NULL, create, FILE_FLAG_BACKUP_SEMANTICS, NULL)
|
NULL, create, FILE_FLAG_BACKUP_SEMANTICS, NULL)
|
||||||
/*
|
/*
|
||||||
@ -43,6 +43,8 @@
|
|||||||
#define NGX_FILE_OPEN OPEN_EXISTING
|
#define NGX_FILE_OPEN OPEN_EXISTING
|
||||||
#define NGX_FILE_APPEND 0
|
#define NGX_FILE_APPEND 0
|
||||||
|
|
||||||
|
#define NGX_FILE_DEFAULT_ACCESS 0
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_file_append_mode(ngx_fd_t fd);
|
ngx_int_t ngx_file_append_mode(ngx_fd_t fd);
|
||||||
#define ngx_file_append_mode_n "SetFilePointer()"
|
#define ngx_file_append_mode_n "SetFilePointer()"
|
||||||
|
Loading…
Reference in New Issue
Block a user