Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3154:55a36d3793e4 HEAD
lstat() the root directory before trying to mkdir() it.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Feb 2005 23:16:29 +0200 |
parents | c16260eab83f |
children | 9abab33f1262 |
files | src/lib-storage/index/mbox/mbox-storage.c |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-storage.c Wed Feb 09 23:14:13 2005 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Wed Feb 09 23:16:29 2005 +0200 @@ -299,8 +299,13 @@ root_dir = t_strndup(root_dir, len-1); /* make sure the directory exists */ - if (mkdir_parents(root_dir, CREATE_MODE) < 0 && - errno != EEXIST) { + if (lstat(root_dir, &st) == 0) { + /* yep, go ahead */ + } else if (errno != ENOENT && errno != ENOTDIR) { + i_error("lstat(%s) failed: %m", root_dir); + return NULL; + } else if (mkdir_parents(root_dir, CREATE_MODE) < 0 && + errno != EEXIST) { i_error("mkdir_parents(%s) failed: %m", root_dir); return NULL; }