|
|
|
|
@ -44,6 +44,7 @@ get_controlfile(const char *DataDir, const char *progname, bool *crc_ok_p) |
|
|
|
|
int fd; |
|
|
|
|
char ControlFilePath[MAXPGPATH]; |
|
|
|
|
pg_crc32c crc; |
|
|
|
|
int r; |
|
|
|
|
|
|
|
|
|
AssertArg(crc_ok_p); |
|
|
|
|
|
|
|
|
|
@ -64,18 +65,34 @@ get_controlfile(const char *DataDir, const char *progname, bool *crc_ok_p) |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData)) |
|
|
|
|
r = read(fd, ControlFile, sizeof(ControlFileData)); |
|
|
|
|
if (r != sizeof(ControlFileData)) |
|
|
|
|
{ |
|
|
|
|
if (r < 0) |
|
|
|
|
#ifndef FRONTEND |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode_for_file_access(), |
|
|
|
|
errmsg("could not read file \"%s\": %m", ControlFilePath))); |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode_for_file_access(), |
|
|
|
|
errmsg("could not read file \"%s\": %m", ControlFilePath))); |
|
|
|
|
#else |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, _("%s: could not read file \"%s\": %s\n"), |
|
|
|
|
progname, ControlFilePath, strerror(errno)); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, _("%s: could not read file \"%s\": %s\n"), |
|
|
|
|
progname, ControlFilePath, strerror(errno)); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
else |
|
|
|
|
#ifndef FRONTEND |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errmsg("could not read file \"%s\": read %d bytes, expected %d", |
|
|
|
|
ControlFilePath, r, (int) sizeof(ControlFileData)))); |
|
|
|
|
#else |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, _("%s: could not read file \"%s\": read %d bytes, expected %d\n"), |
|
|
|
|
progname, ControlFilePath, r, (int) sizeof(ControlFileData)); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
close(fd); |
|
|
|
|
|
|
|
|
|
|