* Compute and check the directory paths to files that are part of the * installation (as deduced from the postgres executable's own location) */
| 1737 | * installation (as deduced from the postgres executable's own location) |
| 1738 | */ |
| 1739 | static void |
| 1740 | getInstallationPaths(const char *argv0) |
| 1741 | { |
| 1742 | DIR *pdir; |
| 1743 | |
| 1744 | /* Locate the postgres executable itself */ |
| 1745 | if (find_my_exec(argv0, my_exec_path) < 0) |
| 1746 | ereport(FATAL, |
| 1747 | (errmsg("%s: could not locate my own executable path", argv0))); |
| 1748 | |
| 1749 | #ifdef EXEC_BACKEND |
| 1750 | /* Locate executable backend before we change working directory */ |
| 1751 | if (find_other_exec(argv0, "postgres", PG_BACKEND_VERSIONSTR, |
| 1752 | postgres_exec_path) < 0) |
| 1753 | ereport(FATAL, |
| 1754 | (errmsg("%s: could not locate matching postgres executable", |
| 1755 | argv0))); |
| 1756 | #endif |
| 1757 | |
| 1758 | /* |
| 1759 | * Locate the pkglib directory --- this has to be set early in case we try |
| 1760 | * to load any modules from it in response to postgresql.conf entries. |
| 1761 | */ |
| 1762 | get_pkglib_path(my_exec_path, pkglib_path); |
| 1763 | |
| 1764 | /* |
| 1765 | * Verify that there's a readable directory there; otherwise the Postgres |
| 1766 | * installation is incomplete or corrupt. (A typical cause of this |
| 1767 | * failure is that the postgres executable has been moved or hardlinked to |
| 1768 | * some directory that's not a sibling of the installation lib/ |
| 1769 | * directory.) |
| 1770 | */ |
| 1771 | pdir = AllocateDir(pkglib_path); |
| 1772 | if (pdir == NULL) |
| 1773 | ereport(ERROR, |
| 1774 | (errcode_for_file_access(), |
| 1775 | errmsg("could not open directory \"%s\": %m", |
| 1776 | pkglib_path), |
| 1777 | errhint("This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.", |
| 1778 | my_exec_path))); |
| 1779 | FreeDir(pdir); |
| 1780 | |
| 1781 | /* |
| 1782 | * XXX is it worth similarly checking the share/ directory? If the lib/ |
| 1783 | * directory is there, then share/ probably is too. |
| 1784 | */ |
| 1785 | } |
| 1786 | |
| 1787 | /* |
| 1788 | * Check that pg_control exists in the correct location in the data directory. |
no test coverage detected