doesn't mkdir fail for other reasons too? Also, shouldn't it be recursive?