/* Make PID file world readable */
if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
- write_stderr("%s: could not change permissions of external PID file \"%s\": %s\n",
- progname, external_pid_file, strerror(errno));
+ write_stderr("%s: could not change permissions of external PID file \"%s\": %m\n",
+ progname, external_pid_file);
}
else
- write_stderr("%s: could not write external PID file \"%s\": %s\n",
- progname, external_pid_file, strerror(errno));
+ write_stderr("%s: could not write external PID file \"%s\": %m\n",
+ progname, external_pid_file);
on_proc_exit(unlink_external_pid_file, 0);
}
{
write_stderr("%s: could not find the database system\n"
"Expected to find it in the directory \"%s\",\n"
- "but could not open file \"%s\": %s\n",
- progname, DataDir, path, strerror(errno));
+ "but could not open file \"%s\": %m\n",
+ progname, DataDir, path);
ExitPostmaster(2);
}
FreeFile(fp);
fp = AllocateFile(id, PG_BINARY_R);
if (!fp)
{
- write_stderr("could not open backend variables file \"%s\": %s\n",
- id, strerror(errno));
+ write_stderr("could not open backend variables file \"%s\": %m\n", id);
exit(1);
}
if (fread(¶m, sizeof(param), 1, fp) != 1)
{
- write_stderr("could not read from backend variables file \"%s\": %s\n",
- id, strerror(errno));
+ write_stderr("could not read from backend variables file \"%s\": %m\n", id);
exit(1);
}
FreeFile(fp);
if (unlink(id) != 0)
{
- write_stderr("could not remove file \"%s\": %s\n",
- id, strerror(errno));
+ write_stderr("could not remove file \"%s\": %m\n", id);
exit(1);
}
#else
* to our input pipe which would result in a different sort of looping.
*/
if (rc != count)
- write_stderr("could not write to log file: %s\n", strerror(errno));
+ write_stderr("could not write to log file: %m\n");
}
#ifdef WIN32
if (configdir && stat(configdir, &stat_buf) != 0)
{
- write_stderr("%s: could not access directory \"%s\": %s\n",
+ write_stderr("%s: could not access directory \"%s\": %m\n",
progname,
- configdir,
- strerror(errno));
+ configdir);
if (errno == ENOENT)
write_stderr("Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
return false;
*/
if (stat(ConfigFileName, &stat_buf) != 0)
{
- write_stderr("%s: could not access the server configuration file \"%s\": %s\n",
- progname, ConfigFileName, strerror(errno));
+ write_stderr("%s: could not access the server configuration file \"%s\": %m\n",
+ progname, ConfigFileName);
free(configdir);
return false;
}
if (stat(tzdir, &statbuf) != 0)
{
#ifdef DEBUG_IDENTIFY_TIMEZONE
- fprintf(stderr, "could not stat \"%s\": %s\n",
- tzdir, strerror(errno));
+ fprintf(stderr, "could not stat \"%s\": %m\n",
+ tzdir);
#endif
tzdir[tzdir_orig_len] = '\0';
continue;
write_stderr(_("%s: directory \"%s\" does not exist\n"), progname,
pg_data);
else
- write_stderr(_("%s: could not access directory \"%s\": %s\n"), progname,
- pg_data, strerror(errno));
+ write_stderr(_("%s: could not access directory \"%s\": %m\n"), progname,
+ pg_data);
/*
* The Linux Standard Base Core Specification 3.1 says this should
return 0;
else
{
- write_stderr(_("%s: could not open PID file \"%s\": %s\n"),
- progname, pid_file, strerror(errno));
+ write_stderr(_("%s: could not open PID file \"%s\": %m\n"),
+ progname, pid_file);
exit(1);
}
}
if (pm_pid < 0)
{
/* fork failed */
- write_stderr(_("%s: could not start server: %s\n"),
- progname, strerror(errno));
+ write_stderr(_("%s: could not start server: %m\n"),
+ progname);
exit(1);
}
if (pm_pid > 0)
#ifdef HAVE_SETSID
if (setsid() < 0)
{
- write_stderr(_("%s: could not start server due to setsid() failure: %s\n"),
- progname, strerror(errno));
+ write_stderr(_("%s: could not start server due to setsid() failure: %m\n"),
+ progname);
exit(1);
}
#endif
(void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL);
/* exec failed */
- write_stderr(_("%s: could not start server: %s\n"),
- progname, strerror(errno));
+ write_stderr(_("%s: could not start server: %m\n"),
+ progname);
exit(1);
return 0; /* keep dumb compilers quiet */
*/
if (errno != ENOENT)
{
- write_stderr(_("%s: could not open log file \"%s\": %s\n"),
- progname, log_file, strerror(errno));
+ write_stderr(_("%s: could not open log file \"%s\": %m\n"),
+ progname, log_file);
exit(1);
}
}
if (postmasterPID != -1)
{
if (kill(postmasterPID, SIGINT) != 0)
- write_stderr(_("%s: could not send stop signal (PID: %d): %s\n"),
- progname, (int) postmasterPID, strerror(errno));
+ write_stderr(_("%s: could not send stop signal (PID: %d): %m\n"),
+ progname, (int) postmasterPID);
}
/*
if (kill(pid, sig) != 0)
{
- write_stderr(_("%s: could not send stop signal (PID: %d): %s\n"), progname, (int) pid,
- strerror(errno));
+ write_stderr(_("%s: could not send stop signal (PID: %d): %m\n"), progname, (int) pid);
exit(1);
}
{
if (kill(pid, sig) != 0)
{
- write_stderr(_("%s: could not send stop signal (PID: %d): %s\n"), progname, (int) pid,
- strerror(errno));
+ write_stderr(_("%s: could not send stop signal (PID: %d): %m\n"), progname, (int) pid);
exit(1);
}
if (kill(pid, sig) != 0)
{
- write_stderr(_("%s: could not send reload signal (PID: %d): %s\n"),
- progname, (int) pid, strerror(errno));
+ write_stderr(_("%s: could not send reload signal (PID: %d): %m\n"),
+ progname, (int) pid);
exit(1);
}
if ((prmfile = fopen(promote_file, "w")) == NULL)
{
- write_stderr(_("%s: could not create promote signal file \"%s\": %s\n"),
- progname, promote_file, strerror(errno));
+ write_stderr(_("%s: could not create promote signal file \"%s\": %m\n"),
+ progname, promote_file);
exit(1);
}
if (fclose(prmfile))
{
- write_stderr(_("%s: could not write promote signal file \"%s\": %s\n"),
- progname, promote_file, strerror(errno));
+ write_stderr(_("%s: could not write promote signal file \"%s\": %m\n"),
+ progname, promote_file);
exit(1);
}
sig = SIGUSR1;
if (kill(pid, sig) != 0)
{
- write_stderr(_("%s: could not send promote signal (PID: %d): %s\n"),
- progname, (int) pid, strerror(errno));
+ write_stderr(_("%s: could not send promote signal (PID: %d): %m\n"),
+ progname, (int) pid);
if (unlink(promote_file) != 0)
- write_stderr(_("%s: could not remove promote signal file \"%s\": %s\n"),
- progname, promote_file, strerror(errno));
+ write_stderr(_("%s: could not remove promote signal file \"%s\": %m\n"),
+ progname, promote_file);
exit(1);
}
if ((logrotatefile = fopen(logrotate_file, "w")) == NULL)
{
- write_stderr(_("%s: could not create log rotation signal file \"%s\": %s\n"),
- progname, logrotate_file, strerror(errno));
+ write_stderr(_("%s: could not create log rotation signal file \"%s\": %m\n"),
+ progname, logrotate_file);
exit(1);
}
if (fclose(logrotatefile))
{
- write_stderr(_("%s: could not write log rotation signal file \"%s\": %s\n"),
- progname, logrotate_file, strerror(errno));
+ write_stderr(_("%s: could not write log rotation signal file \"%s\": %m\n"),
+ progname, logrotate_file);
exit(1);
}
sig = SIGUSR1;
if (kill(pid, sig) != 0)
{
- write_stderr(_("%s: could not send log rotation signal (PID: %d): %s\n"),
- progname, (int) pid, strerror(errno));
+ write_stderr(_("%s: could not send log rotation signal (PID: %d): %m\n"),
+ progname, (int) pid);
if (unlink(logrotate_file) != 0)
- write_stderr(_("%s: could not remove log rotation signal file \"%s\": %s\n"),
- progname, logrotate_file, strerror(errno));
+ write_stderr(_("%s: could not remove log rotation signal file \"%s\": %m\n"),
+ progname, logrotate_file);
exit(1);
}
{
if (kill(pid, sig) != 0)
{
- write_stderr(_("%s: could not send signal %d (PID: %d): %s\n"),
- progname, sig, (int) pid, strerror(errno));
+ write_stderr(_("%s: could not send signal %d (PID: %d): %m\n"),
+ progname, sig, (int) pid);
exit(1);
}
}
if (ret == EOF)
{
if (!gzeof(gzfp))
- pg_fatal("could not read from input file: %s", strerror(errno));
+ pg_fatal("could not read from input file: %m");
else
pg_fatal("could not read from input file: end of file");
}
ret = fread(ptr, 1, size, fp);
if (ret != size && !feof(fp))
- pg_fatal("could not read from input file: %s",
- strerror(errno));
+ pg_fatal("could not read from input file: %m");
if (rsize)
*rsize = ret;
if (ret == EOF)
{
if (!feof(fp))
- pg_fatal("could not read from input file: %s", strerror(errno));
+ pg_fatal("could not read from input file: %m");
else
pg_fatal("could not read from input file: end of file");
}
prep_status("Creating script to delete old cluster");
if ((script = fopen_priv(*deletion_script_file_name, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- *deletion_script_file_name, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m",
+ *deletion_script_file_name);
#ifndef WIN32
/* add shebang header */
#ifndef WIN32
if (chmod(*deletion_script_file_name, S_IRWXU) != 0)
- pg_fatal("could not add execute permission to file \"%s\": %s",
- *deletion_script_file_name, strerror(errno));
+ pg_fatal("could not add execute permission to file \"%s\": %m",
+ *deletion_script_file_name);
#endif
check_ok();
if (strcmp(datallowconn, "f") == 0)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script, "%s\n", datname);
}
for (rowno = 0; rowno < ntups; rowno++)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
fprintf(script, "In database: %s\n", active_db->db_name);
{
if (script == NULL &&
(script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
fprintf(script, "In database: %s\n", active_db->db_name);
{
if (script == NULL &&
(script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
fprintf(script, "In database: %s\n", active_db->db_name);
for (rowno = 0; rowno < ntups; rowno++)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
fprintf(script, "In database: %s\n", active_db->db_name);
for (int rowno = 0; rowno < ntups; rowno++)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script, "%s (oid=%s)\n",
PQgetvalue(res, rowno, i_rolname),
PQgetvalue(res, rowno, i_roloid));
{
if (script == NULL &&
(script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
fprintf(script, "In database: %s\n", active_db->db_name);
{
if (script == NULL &&
(script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script, "The slot \"%s\" is invalid\n",
slot->slotname);
{
if (script == NULL &&
(script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script,
"The slot \"%s\" has not consumed the WAL yet\n",
for (int i = 0; i < ntup; i++)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script, "The replication origin is missing for database:\"%s\" subscription:\"%s\"\n",
PQgetvalue(res, i, 0),
PQgetvalue(res, i, 1));
for (int i = 0; i < ntup; i++)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script, "The table sync state \"%s\" is not allowed for database:\"%s\" subscription:\"%s\" schema:\"%s\" relation:\"%s\"\n",
PQgetvalue(res, i, 0),
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
- pg_fatal("could not get control data using %s: %s",
- cmd, strerror(errno));
+ pg_fatal("could not get control data using %s: %m", cmd);
/* we have the result of cmd in "output". so parse it line by line now */
while (fgets(bufin, sizeof(bufin), output))
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
- pg_fatal("could not get control data using %s: %s",
- cmd, strerror(errno));
+ pg_fatal("could not get control data using %s: %m", cmd);
/* Only in <= 9.2 */
if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
if ((output = popen(cmd, "r")) == NULL ||
fgets(cmd_output, sizeof(cmd_output), output) == NULL)
- pg_fatal("could not get pg_ctl version data using %s: %s",
- cmd, strerror(errno));
+ pg_fatal("could not get pg_ctl version data using %s: %m", cmd);
rc = pclose(output);
if (rc != 0)
{
/* ENOTDIR means we will throw a more useful error later */
if (errno != ENOENT && errno != ENOTDIR)
- pg_fatal("could not open file \"%s\" for reading: %s",
- path, strerror(errno));
+ pg_fatal("could not open file \"%s\" for reading: %m", path);
return false;
}
subdir);
if (stat(subDirName, &statBuf) != 0)
- report_status(PG_FATAL, "check for \"%s\" failed: %s",
- subDirName, strerror(errno));
+ report_status(PG_FATAL, "check for \"%s\" failed: %m",
+ subDirName);
else if (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL, "\"%s\" is not a directory",
subDirName);
/* check bindir */
if (stat(cluster->bindir, &statBuf) != 0)
- report_status(PG_FATAL, "check for \"%s\" failed: %s",
- cluster->bindir, strerror(errno));
+ report_status(PG_FATAL, "check for \"%s\" failed: %m",
+ cluster->bindir);
else if (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL, "\"%s\" is not a directory",
cluster->bindir);
{
#if defined(HAVE_COPYFILE) && defined(COPYFILE_CLONE_FORCE)
if (copyfile(src, dst, NULL, COPYFILE_CLONE_FORCE) < 0)
- pg_fatal("error while cloning relation \"%s.%s\" (\"%s\" to \"%s\"): %s",
- schemaName, relName, src, dst, strerror(errno));
+ pg_fatal("error while cloning relation \"%s.%s\" (\"%s\" to \"%s\"): %m",
+ schemaName, relName, src, dst);
#elif defined(__linux__) && defined(FICLONE)
int src_fd;
int dest_fd;
if ((src_fd = open(src, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while cloning relation \"%s.%s\": could not open file \"%s\": %s",
- schemaName, relName, src, strerror(errno));
+ pg_fatal("error while cloning relation \"%s.%s\": could not open file \"%s\": %m",
+ schemaName, relName, src);
if ((dest_fd = open(dst, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode)) < 0)
- pg_fatal("error while cloning relation \"%s.%s\": could not create file \"%s\": %s",
- schemaName, relName, dst, strerror(errno));
+ pg_fatal("error while cloning relation \"%s.%s\": could not create file \"%s\": %m",
+ schemaName, relName, dst);
if (ioctl(dest_fd, FICLONE, src_fd) < 0)
{
char *buffer;
if ((src_fd = open(src, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %s",
- schemaName, relName, src, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
+ schemaName, relName, src);
if ((dest_fd = open(dst, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %s",
- schemaName, relName, dst, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
+ schemaName, relName, dst);
/* copy in fairly large chunks for best efficiency */
#define COPY_BUF_SIZE (50 * BLCKSZ)
ssize_t nbytes = read(src_fd, buffer, COPY_BUF_SIZE);
if (nbytes < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %s",
- schemaName, relName, src, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
+ schemaName, relName, src);
if (nbytes == 0)
break;
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %s",
- schemaName, relName, dst, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
+ schemaName, relName, dst);
}
}
if (CopyFile(src, dst, true) == 0)
{
_dosmaperr(GetLastError());
- pg_fatal("error while copying relation \"%s.%s\" (\"%s\" to \"%s\"): %s",
- schemaName, relName, src, dst, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\" (\"%s\" to \"%s\"): %m",
+ schemaName, relName, src, dst);
}
#endif /* WIN32 */
ssize_t nbytes;
if ((src_fd = open(src, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %s",
- schemaName, relName, src, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
+ schemaName, relName, src);
if ((dest_fd = open(dst, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %s",
- schemaName, relName, dst, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
+ schemaName, relName, dst);
do
{
nbytes = copy_file_range(src_fd, NULL, dest_fd, NULL, SSIZE_MAX, 0);
if (nbytes < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not copy file range from \"%s\" to \"%s\": %s",
- schemaName, relName, src, dst, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not copy file range from \"%s\" to \"%s\": %m",
+ schemaName, relName, src, dst);
}
while (nbytes > 0);
const char *schemaName, const char *relName)
{
if (link(src, dst) < 0)
- pg_fatal("error while creating link for relation \"%s.%s\" (\"%s\" to \"%s\"): %s",
- schemaName, relName, src, dst, strerror(errno));
+ pg_fatal("error while creating link for relation \"%s.%s\" (\"%s\" to \"%s\"): %m",
+ schemaName, relName, src, dst);
}
rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %s",
- schemaName, relName, fromfile, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
+ schemaName, relName, fromfile);
if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %s",
- schemaName, relName, fromfile, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
+ schemaName, relName, fromfile);
if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %s",
- schemaName, relName, tofile, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
+ schemaName, relName, tofile);
/* Save old file size */
src_filesize = statbuf.st_size;
if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
{
if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %s",
- schemaName, relName, fromfile, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
+ schemaName, relName, fromfile);
else
pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
schemaName, relName, fromfile);
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %s",
- schemaName, relName, tofile, strerror(errno));
+ pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
+ schemaName, relName, tofile);
}
/* Advance for next new page */
#if defined(HAVE_COPYFILE) && defined(COPYFILE_CLONE_FORCE)
if (copyfile(existing_file, new_link_file, NULL, COPYFILE_CLONE_FORCE) < 0)
- pg_fatal("could not clone file between old and new data directories: %s",
- strerror(errno));
+ pg_fatal("could not clone file between old and new data directories: %m");
#elif defined(__linux__) && defined(FICLONE)
{
int src_fd;
int dest_fd;
if ((src_fd = open(existing_file, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("could not open file \"%s\": %s",
- existing_file, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m",
+ existing_file);
if ((dest_fd = open(new_link_file, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode)) < 0)
- pg_fatal("could not create file \"%s\": %s",
- new_link_file, strerror(errno));
+ pg_fatal("could not create file \"%s\": %m",
+ new_link_file);
if (ioctl(dest_fd, FICLONE, src_fd) < 0)
- pg_fatal("could not clone file between old and new data directories: %s",
- strerror(errno));
+ pg_fatal("could not clone file between old and new data directories: %m");
close(src_fd);
close(dest_fd);
int dest_fd;
if ((src_fd = open(existing_file, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("could not open file \"%s\": %s",
- existing_file, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m",
+ existing_file);
if ((dest_fd = open(new_link_file, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode)) < 0)
- pg_fatal("could not create file \"%s\": %s",
- new_link_file, strerror(errno));
+ pg_fatal("could not create file \"%s\": %m",
+ new_link_file);
if (copy_file_range(src_fd, NULL, dest_fd, NULL, SSIZE_MAX, 0) < 0)
- pg_fatal("could not copy file range between old and new data directories: %s",
- strerror(errno));
+ pg_fatal("could not copy file range between old and new data directories: %m");
close(src_fd);
close(dest_fd);
unlink(new_link_file); /* might fail */
if (link(existing_file, new_link_file) < 0)
- pg_fatal("could not create hard link between old and new data directories: %s\n"
- "In link mode the old and new data directories must be on the same file system.",
- strerror(errno));
+ pg_fatal("could not create hard link between old and new data directories: %m\n"
+ "In link mode the old and new data directories must be on the same file system.");
unlink(new_link_file);
}
was_load_failure = true;
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- output_path, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
fprintf(script, _("could not load library \"%s\": %s"),
lib,
PQerrorMessage(conn));
if ((output = popen(cmd, "r")) == NULL ||
fgets(cmd_output, sizeof(cmd_output), output) == NULL)
- pg_fatal("could not get data directory using %s: %s",
- cmd, strerror(errno));
+ pg_fatal("could not get data directory using %s: %m", cmd);
rc = pclose(output);
if (rc != 0)
snprintf(filename, sizeof(filename), "%s/postmaster.pid",
cluster->pgdata);
if ((fp = fopen(filename, "r")) == NULL)
- pg_fatal("could not open file \"%s\": %s",
- filename, strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", filename);
for (lineno = 1;
lineno <= Max(LOCK_FILE_LINE_PORT, LOCK_FILE_LINE_SOCKET_DIR);
lineno++)
{
if (fgets(line, sizeof(line), fp) == NULL)
- pg_fatal("could not read line %d from file \"%s\": %s",
- lineno, filename, strerror(errno));
+ pg_fatal("could not read line %d from file \"%s\": %m",
+ lineno, filename);
/* potentially overwrite user-supplied value */
if (lineno == LOCK_FILE_LINE_PORT)
_exit(!exec_prog(log_file, opt_log_file, true, true, "%s", cmd));
else if (child < 0)
/* fork failed */
- pg_fatal("could not create worker process: %s", strerror(errno));
+ pg_fatal("could not create worker process: %m");
#else
/* empty array element are always at the end */
new_arg = exec_thread_args[parallel_jobs - 1];
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_exec_prog,
new_arg, 0, NULL);
if (child == 0)
- pg_fatal("could not create worker thread: %s", strerror(errno));
+ pg_fatal("could not create worker thread: %m");
thread_handles[parallel_jobs - 1] = child;
#endif
}
else if (child < 0)
/* fork failed */
- pg_fatal("could not create worker process: %s", strerror(errno));
+ pg_fatal("could not create worker process: %m");
#else
/* empty array element are always at the end */
new_arg = transfer_thread_args[parallel_jobs - 1];
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_transfer_all_new_dbs,
new_arg, 0, NULL);
if (child == 0)
- pg_fatal("could not create worker thread: %s", strerror(errno));
+ pg_fatal("could not create worker thread: %m");
thread_handles[parallel_jobs - 1] = child;
#endif
#ifndef WIN32
child = waitpid(-1, &work_status, wait_for_child ? 0 : WNOHANG);
if (child == (pid_t) -1)
- pg_fatal("%s() failed: %s", "waitpid", strerror(errno));
+ pg_fatal("%s() failed: %m", "waitpid");
if (child == 0)
return false; /* no children, or no dead children */
if (work_status != 0)
/* get the result */
GetExitCodeThread(thread_handles[thread_num], &res);
if (res != 0)
- pg_fatal("child worker exited abnormally: %s", strerror(errno));
+ pg_fatal("child worker exited abnormally: %m");
/* dispose of handle to stop leaks */
CloseHandle(thread_handles[thread_num]);
* output directories with correct permissions.
*/
if (!GetDataDirectoryCreatePerm(new_cluster.pgdata))
- pg_fatal("could not read permissions of directory \"%s\": %s",
- new_cluster.pgdata, strerror(errno));
+ pg_fatal("could not read permissions of directory \"%s\": %m",
+ new_cluster.pgdata);
umask(pg_mode_mask);
if (errno == ENOENT)
return;
else
- pg_fatal("error while checking for file existence \"%s.%s\" (\"%s\" to \"%s\"): %s",
- map->nspname, map->relname, old_file, new_file,
- strerror(errno));
+ pg_fatal("error while checking for file existence \"%s.%s\" (\"%s\" to \"%s\"): %m",
+ map->nspname, map->relname, old_file, new_file);
}
/* If file is empty, just return */
os_info.old_tablespaces[tblnum]);
else
report_status(PG_FATAL,
- "could not stat tablespace directory \"%s\": %s",
- os_info.old_tablespaces[tblnum], strerror(errno));
+ "could not stat tablespace directory \"%s\": %m",
+ os_info.old_tablespaces[tblnum]);
}
if (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL,
{
found = true;
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s", output_path,
- strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
fprintf(script, "In database: %s\n", active_db->db_name);
if (!check_mode)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s", output_path,
- strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
PQExpBufferData connectbuf;
for (rowno = 0; rowno < ntups; rowno++)
{
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s", output_path,
- strerror(errno));
+ pg_fatal("could not open file \"%s\": %m", output_path);
if (!db_used)
{
PQExpBufferData connectbuf;
#ifndef FRONTEND
elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
#else
- fprintf(stderr, "vsnprintf failed: %s with format string \"%s\"\n",
- strerror(errno), fmt);
+ fprintf(stderr, "vsnprintf failed: %m with format string \"%s\"\n",
+ fmt);
exit(EXIT_FAILURE);
#endif
}
if (base_yyout == NULL)
{
- fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
- progname, output_filename, strerror(errno));
+ fprintf(stderr, _("%s: could not open file \"%s\": %m\n"),
+ progname, output_filename);
output_filename = NULL;
}
else
base_yyout = fopen(output_filename, PG_BINARY_W);
if (base_yyout == NULL)
{
- fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
- progname, output_filename, strerror(errno));
+ fprintf(stderr, _("%s: could not open file \"%s\": %m\n"),
+ progname, output_filename);
free(output_filename);
output_filename = NULL;
free(input_filename);
}
if (base_yyin == NULL)
- fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
- progname, argv[fnr], strerror(errno));
+ fprintf(stderr, _("%s: could not open file \"%s\": %m\n"),
+ progname, argv[fnr]);
else
{
struct cursor *ptr;
#ifndef FRONTEND
elog(ERROR, "could not get current working directory: %m");
#else
- fprintf(stderr, _("could not get current working directory: %s\n"),
- strerror(errno));
+ fprintf(stderr, _("could not get current working directory: %m\n"));
return NULL;
#endif
}
{
if (errno == EINTR)
continue;
- fprintf(stderr, "select failed: %s\n", strerror(errno));
+ fprintf(stderr, "select failed: %m\n");
exit(1);
}
else if (ret == 0) /* select() timeout: check for lock wait */
tv.tv_usec = 0;
if (select(sock + 1, &input_mask, NULL, NULL, &tv) < 0)
{
- fprintf(stderr, "select() failed: %s\n", strerror(errno));
+ fprintf(stderr, "select() failed: %m\n");
exit_nicely(conn);
}
if (FD_ISSET(sock, &input_mask) && PQconsumeInput(conn) != 1)
if (select(sock + 1, &input_mask, &output_mask, NULL, NULL) < 0)
{
- fprintf(stderr, "select() failed: %s\n", strerror(errno));
+ fprintf(stderr, "select() failed: %m\n");
exit_nicely(conn);
}
#endif
if (pg_foreach_ifaddr(callback, NULL) < 0)
- fprintf(stderr, "pg_foreach_ifaddr failed: %s\n", strerror(errno));
+ fprintf(stderr, "pg_foreach_ifaddr failed: %m\n");
return 0;
}