DataFlash: don't try to create a directory that exists

this is an attempt to avoid microSD card corruption. The most common
corruption is two 'logs' directories, which may indicate an issue with
trying to create it a 2nd time.
This commit is contained in:
Andrew Tridgell 2013-12-14 15:32:39 +11:00
parent 5767aa47d9
commit 4ce2555a65

View File

@ -50,8 +50,12 @@ void DataFlash_File::Init(void)
{
// create the log directory if need be
int ret;
ret = mkdir(_log_directory, 0777);
if (ret == -1 && errno != EEXIST) {
struct stat st;
ret = stat(_log_directory, &st);
if (ret == -1) {
ret = mkdir(_log_directory, 0777);
}
if (ret == -1) {
hal.console->printf("Failed to create log directory %s", _log_directory);
return;
}