@@ -257,6 +257,7 @@ void setup_signals(void);
257257void setup_text_search (void );
258258void create_data_directory (void );
259259void create_xlog_symlink (void );
260+ void warn_on_mount_point (int error );
260261void initialize_data_directory (void );
261262
262263
@@ -3144,7 +3145,9 @@ setup_signals(void)
31443145void
31453146create_data_directory (void )
31463147{
3147- switch (pg_check_dir (pg_data ))
3148+ int ret ;
3149+
3150+ switch ((ret = pg_check_dir (pg_data )))
31483151 {
31493152 case 0 :
31503153 /* PGDATA not there, must create it */
@@ -3179,15 +3182,20 @@ create_data_directory(void)
31793182 break ;
31803183
31813184 case 2 :
3185+ case 3 :
3186+ case 4 :
31823187 /* Present and not empty */
31833188 fprintf (stderr ,
31843189 _ ("%s: directory \"%s\" exists but is not empty\n" ),
31853190 progname , pg_data );
3186- fprintf (stderr ,
3187- _ ("If you want to create a new database system, either remove or empty\n"
3188- "the directory \"%s\" or run %s\n"
3189- "with an argument other than \"%s\".\n" ),
3190- pg_data , progname , pg_data );
3191+ if (ret != 4 )
3192+ warn_on_mount_point (ret );
3193+ else
3194+ fprintf (stderr ,
3195+ _ ("If you want to create a new database system, either remove or empty\n"
3196+ "the directory \"%s\" or run %s\n"
3197+ "with an argument other than \"%s\".\n" ),
3198+ pg_data , progname , pg_data );
31913199 exit (1 ); /* no further message needed */
31923200
31933201 default :
@@ -3206,6 +3214,7 @@ create_xlog_symlink(void)
32063214 if (strcmp (xlog_dir , "" ) != 0 )
32073215 {
32083216 char * linkloc ;
3217+ int ret ;
32093218
32103219 /* clean up xlog directory name, check it's absolute */
32113220 canonicalize_path (xlog_dir );
@@ -3216,7 +3225,7 @@ create_xlog_symlink(void)
32163225 }
32173226
32183227 /* check if the specified xlog directory exists/is empty */
3219- switch (pg_check_dir (xlog_dir ))
3228+ switch (( ret = pg_check_dir (xlog_dir ) ))
32203229 {
32213230 case 0 :
32223231 /* xlog directory not there, must create it */
@@ -3255,14 +3264,19 @@ create_xlog_symlink(void)
32553264 break ;
32563265
32573266 case 2 :
3267+ case 3 :
3268+ case 4 :
32583269 /* Present and not empty */
32593270 fprintf (stderr ,
32603271 _ ("%s: directory \"%s\" exists but is not empty\n" ),
32613272 progname , xlog_dir );
3262- fprintf (stderr ,
3263- _ ("If you want to store the transaction log there, either\n"
3264- "remove or empty the directory \"%s\".\n" ),
3265- xlog_dir );
3273+ if (ret != 4 )
3274+ warn_on_mount_point (ret );
3275+ else
3276+ fprintf (stderr ,
3277+ _ ("If you want to store the transaction log there, either\n"
3278+ "remove or empty the directory \"%s\".\n" ),
3279+ xlog_dir );
32663280 exit_nicely ();
32673281
32683282 default :
@@ -3291,6 +3305,21 @@ create_xlog_symlink(void)
32913305}
32923306
32933307
3308+ void
3309+ warn_on_mount_point (int error )
3310+ {
3311+ if (error == 2 )
3312+ fprintf (stderr ,
3313+ _ ("It contains a dot-prefixed/invisible file, perhaps due to it being a mount point.\n" ));
3314+ else if (error == 3 )
3315+ fprintf (stderr ,
3316+ _ ("It contains a lost+found directory, perhaps due to it being a mount point.\n" ));
3317+
3318+ fprintf (stderr ,
3319+ _ ("Using the top-level directory of a mount point is not recommended.\n" ));
3320+ }
3321+
3322+
32943323void
32953324initialize_data_directory (void )
32963325{
0 commit comments