diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-03-06 16:01:21 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-03-06 16:01:21 +0300 |
commit | 78c95de9dab2ec463c609bcca15f5aba8bb3e8e1 (patch) | |
tree | 0c537befff09e31b4eb5ddefa13de3fe69f0bb22 /src | |
parent | 7ac9f3605c3a4e687293fcec64a09f5233a82edf (diff) |
XFS on Linux does not set dirent.d_type,
therefore fallback to stat() if dirent.d_type is not set,
this fixes slash after directory name in ngx_http_autoindex_module;
the issue has been introduced in r2235
Diffstat (limited to 'src')
-rw-r--r-- | src/os/unix/ngx_files.c | 8 | ||||
-rw-r--r-- | src/os/unix/ngx_files.h | 15 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c index 661ecaa4e..1203989b6 100644 --- a/src/os/unix/ngx_files.c +++ b/src/os/unix/ngx_files.c @@ -249,11 +249,6 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir) } dir->valid_info = 0; -#if (NGX_HAVE_D_TYPE) - dir->valid_type = 1; -#else - dir->valid_type = 0; -#endif return NGX_OK; } @@ -267,6 +262,9 @@ ngx_read_dir(ngx_dir_t *dir) if (dir->de) { #if (NGX_HAVE_D_TYPE) dir->type = dir->de->d_type; + dir->valid_type = dir->type ? 1 : 0; +#else + dir->valid_type = 0; #endif return NGX_OK; } diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h index fe14887f1..068b4d8fd 100644 --- a/src/os/unix/ngx_files.h +++ b/src/os/unix/ngx_files.h @@ -200,10 +200,25 @@ ngx_int_t ngx_read_dir(ngx_dir_t *dir); #if (NGX_HAVE_D_TYPE) +#if (NGX_LINUX) + +/* XFS on Linux does not set dirent.d_type */ + +#define ngx_de_is_dir(dir) \ + (((dir)->type) ? ((dir)->type == DT_DIR) : (S_ISDIR((dir)->info.st_mode))) +#define ngx_de_is_file(dir) \ + (((dir)->type) ? ((dir)->type == DT_REG) : (S_ISREG((dir)->info.st_mode))) +#define ngx_de_is_link(dir) \ + (((dir)->type) ? ((dir)->type == DT_LINK) : (S_ISLNK((dir)->info.st_mode))) + +#else + #define ngx_de_is_dir(dir) ((dir)->type == DT_DIR) #define ngx_de_is_file(dir) ((dir)->type == DT_REG) #define ngx_de_is_link(dir) ((dir)->type == DT_LINK) +#endif /* NGX_LINUX */ + #else #define ngx_de_is_dir(dir) (S_ISDIR((dir)->info.st_mode)) |