1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Warn about initdb using mount-points

Add code to detect and warn about trying to initdb or create pg_xlog on
mount points.
This commit is contained in:
Bruce Momjian
2013-02-16 18:52:50 -05:00
parent 1bd42cd70a
commit 17f1523932
3 changed files with 60 additions and 13 deletions

View File

@@ -31,6 +31,7 @@ pg_check_dir(const char *dir)
int result = 1;
DIR *chkdir;
struct dirent *file;
bool dot_found = false;
errno = 0;
@@ -47,15 +48,26 @@ pg_check_dir(const char *dir)
/* skip this and parent directory */
continue;
}
#ifndef WIN32
/* file starts with "." */
else if (file->d_name[0] == '.')
{
dot_found = true;
}
else if (strcmp("lost+found", file->d_name) == 0)
{
result = 3; /* not empty, mount point */
break;
}
#endif
else
{
result = 2; /* not empty */
result = 4; /* not empty */
break;
}
}
#ifdef WIN32
/*
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
* released version
@@ -69,5 +81,9 @@ pg_check_dir(const char *dir)
if (errno != 0)
result = -1; /* some kind of I/O error? */
/* We report on dot-files if we _only_ find dot files */
if (result == 1 && dot_found)
result = 2;
return result;
}