*) reset cached dirent.d_type after stat()
this fixes slash after link to a directory in ngx_http_autoindex_module;
*) use cached dirent.d_type as hint on all systems
the issues has been introduced in r2235
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 832dbbe..9cdfeab 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -24,7 +24,6 @@
unsigned type:8;
unsigned valid_info:1;
- unsigned valid_type:1;
} ngx_dir_t;
@@ -200,31 +199,31 @@
#else
#define ngx_de_namelen(dir) ngx_strlen((dir)->de->d_name)
#endif
-#define ngx_de_info(name, dir) stat((const char *) name, &(dir)->info)
+
+static ngx_inline ngx_int_t
+ngx_de_info(u_char *name, ngx_dir_t *dir)
+{
+ dir->type = 0;
+ return stat((const char *) name, &dir->info);
+}
+
#define ngx_de_info_n "stat()"
#define ngx_de_link_info(name, dir) lstat((const char *) name, &(dir)->info)
#define ngx_de_link_info_n "lstat()"
#if (NGX_HAVE_D_TYPE)
-#if (NGX_LINUX)
-
-/* XFS on Linux does not set dirent.d_type */
+/*
+ * some file systems (e.g. XFS on Linux and CD9660 on FreeBSD)
+ * do 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 */
+ (((dir)->type) ? ((dir)->type == DT_LNK) : (S_ISLNK((dir)->info.st_mode)))
#else