* check if file or directory under "DataDir" exists and is accessible */
| 1815 | * check if file or directory under "DataDir" exists and is accessible |
| 1816 | */ |
| 1817 | static void |
| 1818 | checkPgDir(const char *dir) |
| 1819 | { |
| 1820 | struct stat st; |
| 1821 | /* |
| 1822 | * DataDir is known to be smaller than MAXPGPATH, and 'dir' argument is always |
| 1823 | * a short constant. |
| 1824 | */ |
| 1825 | char buf[MAXPGPATH + MAXPGPATH]; |
| 1826 | |
| 1827 | snprintf(buf, sizeof(buf), "%s%s", DataDir, dir); |
| 1828 | |
| 1829 | if (stat(buf, &st) != 0) |
| 1830 | { |
| 1831 | /* check if log is there */ |
| 1832 | snprintf(buf, sizeof(buf), "%s%s", DataDir, "/log"); |
| 1833 | if (stat(buf, &st) == 0) |
| 1834 | elog(LOG, "System file or directory missing (%s), shutting down segment", dir); |
| 1835 | |
| 1836 | /* quit all processes and exit */ |
| 1837 | pmdie(SIGQUIT); |
| 1838 | } |
| 1839 | } |
| 1840 | |
| 1841 | /* |
| 1842 | * Determine how long should we let ServerLoop sleep. |
no test coverage detected