diff options
Diffstat (limited to 'src/bin/initdb/initdb.c')
-rw-r--r-- | src/bin/initdb/initdb.c | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 2ea3f6ed02b..b8faf9cba6a 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -257,6 +257,7 @@ void setup_signals(void); void setup_text_search(void); void create_data_directory(void); void create_xlog_symlink(void); +void warn_on_mount_point(int error); void initialize_data_directory(void); @@ -3144,7 +3145,9 @@ setup_signals(void) void create_data_directory(void) { - switch (pg_check_dir(pg_data)) + int ret; + + switch ((ret = pg_check_dir(pg_data))) { case 0: /* PGDATA not there, must create it */ @@ -3179,15 +3182,20 @@ create_data_directory(void) break; case 2: + case 3: + case 4: /* Present and not empty */ fprintf(stderr, _("%s: directory \"%s\" exists but is not empty\n"), progname, pg_data); - fprintf(stderr, - _("If you want to create a new database system, either remove or empty\n" - "the directory \"%s\" or run %s\n" - "with an argument other than \"%s\".\n"), - pg_data, progname, pg_data); + if (ret != 4) + warn_on_mount_point(ret); + else + fprintf(stderr, + _("If you want to create a new database system, either remove or empty\n" + "the directory \"%s\" or run %s\n" + "with an argument other than \"%s\".\n"), + pg_data, progname, pg_data); exit(1); /* no further message needed */ default: @@ -3206,6 +3214,7 @@ create_xlog_symlink(void) if (strcmp(xlog_dir, "") != 0) { char *linkloc; + int ret; /* clean up xlog directory name, check it's absolute */ canonicalize_path(xlog_dir); @@ -3216,7 +3225,7 @@ create_xlog_symlink(void) } /* check if the specified xlog directory exists/is empty */ - switch (pg_check_dir(xlog_dir)) + switch ((ret = pg_check_dir(xlog_dir))) { case 0: /* xlog directory not there, must create it */ @@ -3255,14 +3264,19 @@ create_xlog_symlink(void) break; case 2: + case 3: + case 4: /* Present and not empty */ fprintf(stderr, _("%s: directory \"%s\" exists but is not empty\n"), progname, xlog_dir); - fprintf(stderr, - _("If you want to store the transaction log there, either\n" - "remove or empty the directory \"%s\".\n"), - xlog_dir); + if (ret != 4) + warn_on_mount_point(ret); + else + fprintf(stderr, + _("If you want to store the transaction log there, either\n" + "remove or empty the directory \"%s\".\n"), + xlog_dir); exit_nicely(); default: @@ -3292,6 +3306,21 @@ create_xlog_symlink(void) void +warn_on_mount_point(int error) +{ + if (error == 2) + fprintf(stderr, + _("It contains a dot-prefixed/invisible file, perhaps due to it being a mount point.\n")); + else if (error == 3) + fprintf(stderr, + _("It contains a lost+found directory, perhaps due to it being a mount point.\n")); + + fprintf(stderr, + _("Using the top-level directory of a mount point is not recommended.\n")); +} + + +void initialize_data_directory(void) { int i; |