From: Jonathan Nieder Date: Mon, 9 Jan 2012 18:01:50 +0000 (+0100) Subject: common: check_create_dir(): Support symlinks as well. X-Git-Tag: collectd-4.10.6~13 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=52543e770fb2e416365998d02c4b2fc2a53dbb8e;p=collectd.git common: check_create_dir(): Support symlinks as well. Previously, the following situation would cause an endless look (as reported by Michael Prokop in Debian bug #619123): the (CSV or RRD) datadir is a symlink pointing to a non-existent target. With this patch applied, check_create_dir() fails with " exists but is not a directory". Signed-off-by: Sebastian Harl --- diff --git a/src/common.c b/src/common.c index d2a1b362..530f7330 100644 --- a/src/common.c +++ b/src/common.c @@ -542,7 +542,8 @@ int check_create_dir (const char *file_orig) } while (42) { - if (stat (dir, &statbuf) == -1) + if ((stat (dir, &statbuf) == -1) + && (lstat (dir, &statbuf) == -1)) { if (errno == ENOENT) {