From b5ff71655de1de3877f051107eede51bb0a79f65 Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Sat, 4 Jun 2011 14:30:54 +0100 Subject: [PATCH] recurse: ignore links --- config.mk | 2 +- util/recurse.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/config.mk b/config.mk index 4115ac3..fbf4924 100644 --- a/config.mk +++ b/config.mk @@ -2,7 +2,7 @@ VERSION = 0.0 #CC = gcc -#CC = musl-gcc +CC = musl-gcc LD = $(CC) CPPFLAGS = -D_POSIX_C_SOURCE=200112L CFLAGS = -Os -ansi -Wall -pedantic $(CPPFLAGS) diff --git a/util/recurse.c b/util/recurse.c index 6c1ba5a..e98db96 100644 --- a/util/recurse.c +++ b/util/recurse.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "../util.h" void @@ -11,14 +12,14 @@ recurse(const char *path, void (*fn)(const char *)) { char *cwd; struct dirent *d; + struct stat st; DIR *dp; - if(!(dp = opendir(path))) { - if(errno == ENOTDIR) - return; - else - eprintf("opendir %s:", path); - } + if(lstat(path, &st) == -1 || !S_ISDIR(st.st_mode)) + return; + else if(!(dp = opendir(path))) + eprintf("opendir %s:", path); + cwd = agetcwd(); if(chdir(path) == -1) eprintf("chdir %s:", path);