mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
Merge pull request #393 from postgrespro/join_path_components
replace snprintf by join_path_components
This commit is contained in:
+2
-2
@@ -829,7 +829,7 @@ IsDir(const char *dirpath, const char *entry, fio_location location)
|
||||
char path[MAXPGPATH];
|
||||
struct stat st;
|
||||
|
||||
snprintf(path, MAXPGPATH, "%s/%s", dirpath, entry);
|
||||
join_path_components(path, dirpath, entry);
|
||||
|
||||
return fio_stat(path, &st, false, location) == 0 && S_ISDIR(st.st_mode);
|
||||
}
|
||||
@@ -941,7 +941,7 @@ catalog_get_backup_list(const char *instance_name, time_t requested_backup_id)
|
||||
join_path_components(data_path, backup_instance_path, data_ent->d_name);
|
||||
|
||||
/* read backup information from BACKUP_CONTROL_FILE */
|
||||
snprintf(backup_conf_path, MAXPGPATH, "%s/%s", data_path, BACKUP_CONTROL_FILE);
|
||||
join_path_components(backup_conf_path, data_path, BACKUP_CONTROL_FILE);
|
||||
backup = readBackupControlFile(backup_conf_path);
|
||||
|
||||
if (!backup)
|
||||
|
||||
+1
-1
@@ -1017,7 +1017,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
|
||||
|
||||
GetXLogFileName(xlogfname, reader_data->tli, reader_data->xlogsegno, wal_seg_size);
|
||||
|
||||
snprintf(reader_data->xlogpath, MAXPGPATH, "%s/%s", wal_archivedir, xlogfname);
|
||||
join_path_components(reader_data->xlogpath, wal_archivedir, xlogfname);
|
||||
snprintf(reader_data->gz_xlogpath, MAXPGPATH, "%s.gz", reader_data->xlogpath);
|
||||
|
||||
/* We fall back to using .partial segment in case if we are running
|
||||
|
||||
+6
-7
@@ -1480,7 +1480,7 @@ update_recovery_options_before_v12(pgBackup *backup,
|
||||
}
|
||||
|
||||
elog(LOG, "update recovery settings in recovery.conf");
|
||||
snprintf(path, lengthof(path), "%s/recovery.conf", instance_config.pgdata);
|
||||
join_path_components(path, instance_config.pgdata, "recovery.conf");
|
||||
|
||||
fp = fio_fopen(path, "w", FIO_DB_HOST);
|
||||
if (fp == NULL)
|
||||
@@ -1537,8 +1537,7 @@ update_recovery_options(pgBackup *backup,
|
||||
|
||||
time2iso(current_time_str, lengthof(current_time_str), current_time, false);
|
||||
|
||||
snprintf(postgres_auto_path, lengthof(postgres_auto_path),
|
||||
"%s/postgresql.auto.conf", instance_config.pgdata);
|
||||
join_path_components(postgres_auto_path, instance_config.pgdata, "postgresql.auto.conf");
|
||||
|
||||
if (fio_stat(postgres_auto_path, &st, false, FIO_DB_HOST) < 0)
|
||||
{
|
||||
@@ -1648,7 +1647,7 @@ update_recovery_options(pgBackup *backup,
|
||||
if (params->recovery_settings_mode == PITR_REQUESTED)
|
||||
{
|
||||
elog(LOG, "creating recovery.signal file");
|
||||
snprintf(path, lengthof(path), "%s/recovery.signal", instance_config.pgdata);
|
||||
join_path_components(path, instance_config.pgdata, "recovery.signal");
|
||||
|
||||
fp = fio_fopen(path, PG_BINARY_W, FIO_DB_HOST);
|
||||
if (fp == NULL)
|
||||
@@ -1664,7 +1663,7 @@ update_recovery_options(pgBackup *backup,
|
||||
if (params->restore_as_replica)
|
||||
{
|
||||
elog(LOG, "creating standby.signal file");
|
||||
snprintf(path, lengthof(path), "%s/standby.signal", instance_config.pgdata);
|
||||
join_path_components(path, instance_config.pgdata, "standby.signal");
|
||||
|
||||
fp = fio_fopen(path, PG_BINARY_W, FIO_DB_HOST);
|
||||
if (fp == NULL)
|
||||
@@ -2160,7 +2159,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
|
||||
{
|
||||
char pid_file[MAXPGPATH];
|
||||
|
||||
snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pgdata);
|
||||
join_path_components(pid_file, pgdata, "postmaster.pid");
|
||||
elog(WARNING, "Pid file \"%s\" is mangled, cannot determine whether postmaster is running or not",
|
||||
pid_file);
|
||||
success = false;
|
||||
@@ -2201,7 +2200,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
|
||||
*/
|
||||
if (incremental_mode == INCR_LSN)
|
||||
{
|
||||
snprintf(backup_label, MAXPGPATH, "%s/backup_label", pgdata);
|
||||
join_path_components(backup_label, pgdata, "backup_label");
|
||||
if (fio_access(backup_label, F_OK, FIO_DB_HOST) == 0)
|
||||
{
|
||||
elog(WARNING, "Destination directory contains \"backup_control\" file. "
|
||||
|
||||
+2
-2
@@ -418,7 +418,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
|
||||
FIN_CRC32C(ControlFile.crc);
|
||||
|
||||
/* overwrite pg_control */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", backup_path, XLOG_CONTROL_FILE);
|
||||
join_path_components(fullpath, backup_path, XLOG_CONTROL_FILE);
|
||||
writeControlFile(&ControlFile, fullpath, FIO_LOCAL_HOST);
|
||||
|
||||
/* Update pg_control checksum in backup_list */
|
||||
@@ -569,7 +569,7 @@ check_postmaster(const char *pgdata)
|
||||
pid_t pid;
|
||||
char pid_file[MAXPGPATH];
|
||||
|
||||
snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pgdata);
|
||||
join_path_components(pid_file, pgdata, "postmaster.pid");
|
||||
|
||||
fp = fopen(pid_file, "r");
|
||||
if (fp == NULL)
|
||||
|
||||
+1
-1
@@ -1184,7 +1184,7 @@ pgut_rmtree(const char *path, bool rmtopdir, bool strict)
|
||||
/* now we have the names we can start removing things */
|
||||
for (filename = filenames; *filename; filename++)
|
||||
{
|
||||
snprintf(pathbuf, MAXPGPATH, "%s/%s", path, *filename);
|
||||
join_path_components(pathbuf, path, *filename);
|
||||
|
||||
if (lstat(pathbuf, &statbuf) != 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user