diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-01-31 18:52:49 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-01-31 18:52:49 +0000 |
commit | 068bf6534f698e0b235ae362db7c68d438979e07 (patch) | |
tree | 7b4e24217b4a694bd39856698581c6a20f88bc30 /src | |
parent | 61f621b506a7cd29eb1b042a8510b709791034d0 (diff) | |
download | postgresql-068bf6534f698e0b235ae362db7c68d438979e07.tar.gz postgresql-068bf6534f698e0b235ae362db7c68d438979e07.zip |
Fix initdb to not generate misleading error messages when postgres.bki
or other share-directory files are inaccessible for some reason other
than not existing. Inspired by trouble report from Simon Kinsella.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/initdb/initdb.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 0d3f092080c..d374c9c14ae 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.129 2007/01/20 17:04:58 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.130 2007/01/31 18:52:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1041,10 +1041,26 @@ check_input(char *path) { struct stat statbuf; - if (stat(path, &statbuf) != 0 || !S_ISREG(statbuf.st_mode)) + if (stat(path, &statbuf) != 0) + { + if (errno == ENOENT) + fprintf(stderr, + _("%s: file \"%s\" does not exist\n" + "This means you have a corrupted installation or identified\n" + "the wrong directory with the invocation option -L.\n"), + progname, path); + else + fprintf(stderr, + _("%s: could not access file \"%s\": %s\n" + "This may mean you have a corrupted installation or identified\n" + "the wrong directory with the invocation option -L.\n"), + progname, path, strerror(errno)); + exit(1); + } + if (!S_ISREG(statbuf.st_mode)) { fprintf(stderr, - _("%s: file \"%s\" does not exist\n" + _("%s: file \"%s\" is not a regular file\n" "This means you have a corrupted installation or identified\n" "the wrong directory with the invocation option -L.\n"), progname, path); |