Klaus Demo nginx / e58700d
*) 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 Igor Sysoev 12 years ago
5 changed file(s) with 17 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
174174
175175 len = ngx_de_namelen(&dir);
176176
177 if (!dir.valid_type) {
177 if (dir.type == 0) {
178178
179179 /* 1 byte for '/' and 1 byte for terminating '\0' */
180180
273273 if (dir->de) {
274274 #if (NGX_HAVE_D_TYPE)
275275 dir->type = dir->de->d_type;
276 dir->valid_type = dir->type ? 1 : 0;
277276 #else
278 dir->valid_type = 0;
277 dir->type = 0;
279278 #endif
280279 return NGX_OK;
281280 }
2323
2424 unsigned type:8;
2525 unsigned valid_info:1;
26 unsigned valid_type:1;
2726 } ngx_dir_t;
2827
2928
199198 #else
200199 #define ngx_de_namelen(dir) ngx_strlen((dir)->de->d_name)
201200 #endif
202 #define ngx_de_info(name, dir) stat((const char *) name, &(dir)->info)
201
202 static ngx_inline ngx_int_t
203 ngx_de_info(u_char *name, ngx_dir_t *dir)
204 {
205 dir->type = 0;
206 return stat((const char *) name, &dir->info);
207 }
208
203209 #define ngx_de_info_n "stat()"
204210 #define ngx_de_link_info(name, dir) lstat((const char *) name, &(dir)->info)
205211 #define ngx_de_link_info_n "lstat()"
206212
207213 #if (NGX_HAVE_D_TYPE)
208214
209 #if (NGX_LINUX)
210
211 /* XFS on Linux does not set dirent.d_type */
215 /*
216 * some file systems (e.g. XFS on Linux and CD9660 on FreeBSD)
217 * do not set dirent.d_type
218 */
212219
213220 #define ngx_de_is_dir(dir) \
214221 (((dir)->type) ? ((dir)->type == DT_DIR) : (S_ISDIR((dir)->info.st_mode)))
215222 #define ngx_de_is_file(dir) \
216223 (((dir)->type) ? ((dir)->type == DT_REG) : (S_ISREG((dir)->info.st_mode)))
217224 #define ngx_de_is_link(dir) \
218 (((dir)->type) ? ((dir)->type == DT_LINK) : (S_ISLNK((dir)->info.st_mode)))
219
220 #else
221
222 #define ngx_de_is_dir(dir) ((dir)->type == DT_DIR)
223 #define ngx_de_is_file(dir) ((dir)->type == DT_REG)
224 #define ngx_de_is_link(dir) ((dir)->type == DT_LINK)
225
226 #endif /* NGX_LINUX */
225 (((dir)->type) ? ((dir)->type == DT_LNK) : (S_ISLNK((dir)->info.st_mode)))
227226
228227 #else
229228
321321 }
322322
323323 dir->valid_info = 1;
324 dir->valid_type = 1;
325324 dir->ready = 1;
326325
327326 return NGX_OK;
337336 }
338337
339338 if (FindNextFile(dir->dir, &dir->finddata) != 0) {
339 dir->type = 1;
340340 return NGX_OK;
341341 }
342342
2020 WIN32_FIND_DATA finddata;
2121
2222 unsigned valid_info:1;
23 unsigned valid_type:1;
23 unsigned type:1;
2424 unsigned ready:1;
2525 } ngx_dir_t;
2626