From: Peter Avalos Date: Sun, 5 Feb 2012 19:20:09 +0000 (-0800) Subject: sh: Use dirent.d_type in pathname generation. X-Git-Tag: v3.4.0rc~1279 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/c601174268e0ea6cad93a733cecb3a07b2c503a6 sh: Use dirent.d_type in pathname generation. This improves performance for globs where a slash or another component follows a component with metacharacters by eliminating unnecessary attempts to open directories that are not. Obtained-from: FreeBSD 228942 --- diff --git a/bin/sh/expand.c b/bin/sh/expand.c index 2cb334030b..c10a0f5ceb 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)expand.c 8.5 (Berkeley) 5/15/95 - * $FreeBSD: src/bin/sh/expand.c,v 1.92 2011/12/28 23:30:17 jilles Exp $ + * $FreeBSD: src/bin/sh/expand.c,v 1.93 2011/12/28 23:40:46 jilles Exp $ */ #include @@ -1291,6 +1291,10 @@ expmeta(char *enddir, char *name) if (atend) addfname(expdir); else { + if (dp->d_type != DT_UNKNOWN && + dp->d_type != DT_DIR && + dp->d_type != DT_LNK) + continue; if (enddir + namlen + 2 > expdir_end) continue; enddir[namlen] = '/';