1717 * Initialize backup catalog.
1818 */
1919int
20- do_init (char * backup_catalog_path )
20+ do_init (CatalogState * catalogState )
2121{
22- char path [MAXPGPATH ];
23- char arclog_path_dir [MAXPGPATH ];
2422 int results ;
2523
26- results = pg_check_dir (backup_catalog_path );
24+ results = pg_check_dir (catalogState -> catalog_path );
25+
2726 if (results == 4 ) /* exists and not empty*/
2827 elog (ERROR , "backup catalog already exist and it's not empty" );
2928 else if (results == -1 ) /*trouble accessing directory*/
3029 {
3130 int errno_tmp = errno ;
3231 elog (ERROR , "cannot open backup catalog directory \"%s\": %s" ,
33- backup_catalog_path , strerror (errno_tmp ));
32+ catalogState -> catalog_path , strerror (errno_tmp ));
3433 }
3534
3635 /* create backup catalog root directory */
37- dir_create_dir (backup_catalog_path , DIR_PERMISSION , false);
36+ dir_create_dir (catalogState -> catalog_path , DIR_PERMISSION , false);
3837
3938 /* create backup catalog data directory */
40- join_path_components (path , backup_catalog_path , BACKUPS_DIR );
41- dir_create_dir (path , DIR_PERMISSION , false);
39+ dir_create_dir (catalogState -> backup_subdir_path , DIR_PERMISSION , false);
4240
4341 /* create backup catalog wal directory */
44- join_path_components (arclog_path_dir , backup_catalog_path , "wal" );
45- dir_create_dir (arclog_path_dir , DIR_PERMISSION , false);
42+ dir_create_dir (catalogState -> wal_subdir_path , DIR_PERMISSION , false);
4643
47- elog (INFO , "Backup catalog '%s' successfully inited" , backup_catalog_path );
44+ elog (INFO , "Backup catalog '%s' successfully inited" , catalogState -> catalog_path );
4845 return 0 ;
4946}
5047
5148int
52- do_add_instance (char * backup_catalog_path , InstanceConfig * instance )
49+ do_add_instance (CatalogState * catalogState , InstanceConfig * instance )
5350{
54- char path [MAXPGPATH ];
55- char arclog_path_dir [MAXPGPATH ];
5651 struct stat st ;
5752
5853 /* PGDATA is always required */
@@ -66,16 +61,15 @@ do_add_instance(char *backup_catalog_path, InstanceConfig *instance)
6661 instance -> xlog_seg_size = get_xlog_seg_size (instance -> pgdata );
6762
6863 /* Ensure that all root directories already exist */
69- if (access (backup_catalog_path , F_OK ) != 0 )
70- elog (ERROR , "Directory does not exist: '%s'" , backup_catalog_path );
64+ /* TODO maybe call do_init() here instead of error?*/
65+ if (access (catalogState -> catalog_path , F_OK ) != 0 )
66+ elog (ERROR , "Directory does not exist: '%s'" , catalogState -> catalog_path );
7167
72- join_path_components (path , backup_catalog_path , BACKUPS_DIR );
73- if (access (path , F_OK ) != 0 )
74- elog (ERROR , "Directory does not exist: '%s'" , path );
68+ if (access (catalogState -> backup_subdir_path , F_OK ) != 0 )
69+ elog (ERROR , "Directory does not exist: '%s'" , catalogState -> backup_subdir_path );
7570
76- join_path_components (arclog_path_dir , backup_catalog_path , "wal" );
77- if (access (arclog_path_dir , F_OK ) != 0 )
78- elog (ERROR , "Directory does not exist: '%s'" , arclog_path_dir );
71+ if (access (catalogState -> wal_subdir_path , F_OK ) != 0 )
72+ elog (ERROR , "Directory does not exist: '%s'" , catalogState -> wal_subdir_path );
7973
8074 if (stat (instance -> backup_instance_path , & st ) == 0 && S_ISDIR (st .st_mode ))
8175 elog (ERROR , "Instance '%s' backup directory already exists: '%s'" ,
0 commit comments