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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user