18
18
#include <sys/stat.h>
19
19
#include <time.h>
20
20
21
- #include "common/controldata_utils.h"
22
- #include "common/hashfn_unstable.h"
23
21
#include "common/logging.h"
24
22
#include "common/parse_manifest.h"
25
23
#include "fe_utils/simple_list.h"
26
24
#include "getopt_long.h"
25
+ #include "pg_verifybackup.h"
27
26
#include "pgtime.h"
28
27
29
28
/*
45
44
*/
46
45
#define READ_CHUNK_SIZE (128 * 1024)
47
46
48
- /*
49
- * Each file described by the manifest file is parsed to produce an object
50
- * like this.
51
- */
52
- typedef struct manifest_file
53
- {
54
- uint32 status ; /* hash status */
55
- const char * pathname ;
56
- size_t size ;
57
- pg_checksum_type checksum_type ;
58
- int checksum_length ;
59
- uint8 * checksum_payload ;
60
- bool matched ;
61
- bool bad ;
62
- } manifest_file ;
63
-
64
- #define should_verify_checksum (m ) \
65
- (((m)->matched) && !((m)->bad) && (((m)->checksum_type) != CHECKSUM_TYPE_NONE))
66
-
67
- /*
68
- * Define a hash table which we can use to store information about the files
69
- * mentioned in the backup manifest.
70
- */
71
- #define SH_PREFIX manifest_files
72
- #define SH_ELEMENT_TYPE manifest_file
73
- #define SH_KEY_TYPE const char *
74
- #define SH_KEY pathname
75
- #define SH_HASH_KEY (tb , key ) hash_string(key)
76
- #define SH_EQUAL (tb , a , b ) (strcmp(a, b) == 0)
77
- #define SH_SCOPE static inline
78
- #define SH_RAW_ALLOCATOR pg_malloc0
79
- #define SH_DECLARE
80
- #define SH_DEFINE
81
- #include "lib/simplehash.h"
82
-
83
- /*
84
- * Each WAL range described by the manifest file is parsed to produce an
85
- * object like this.
86
- */
87
- typedef struct manifest_wal_range
88
- {
89
- TimeLineID tli ;
90
- XLogRecPtr start_lsn ;
91
- XLogRecPtr end_lsn ;
92
- struct manifest_wal_range * next ;
93
- struct manifest_wal_range * prev ;
94
- } manifest_wal_range ;
95
-
96
- /*
97
- * All the data parsed from a backup_manifest file.
98
- */
99
- typedef struct manifest_data
100
- {
101
- int version ;
102
- uint64 system_identifier ;
103
- manifest_files_hash * files ;
104
- manifest_wal_range * first_wal_range ;
105
- manifest_wal_range * last_wal_range ;
106
- } manifest_data ;
107
-
108
- /*
109
- * All of the context information we need while checking a backup manifest.
110
- */
111
- typedef struct verifier_context
112
- {
113
- manifest_data * manifest ;
114
- char * backup_directory ;
115
- SimpleStringList ignore_list ;
116
- bool skip_checksums ;
117
- bool exit_on_error ;
118
- bool saw_any_error ;
119
- } verifier_context ;
120
-
121
47
static manifest_data * parse_manifest_file (char * manifest_path );
122
48
static void verifybackup_version_cb (JsonManifestParseContext * context ,
123
49
int manifest_version );
@@ -151,13 +77,6 @@ static void parse_required_wal(verifier_context *context,
151
77
char * pg_waldump_path ,
152
78
char * wal_directory );
153
79
154
- static void report_backup_error (verifier_context * context ,
155
- const char * pg_restrict fmt ,...)
156
- pg_attribute_printf (2 , 3 );
157
- static void report_fatal_error (const char * pg_restrict fmt ,...)
158
- pg_attribute_printf (1 , 2 ) pg_attribute_noreturn ();
159
- static bool should_ignore_relpath (verifier_context * context , const char * relpath );
160
-
161
80
static void progress_report (bool finished );
162
81
static void usage (void );
163
82
@@ -980,7 +899,7 @@ parse_required_wal(verifier_context *context, char *pg_waldump_path,
980
899
* Update the context to indicate that we saw an error, and exit if the
981
900
* context says we should.
982
901
*/
983
- static void
902
+ void
984
903
report_backup_error (verifier_context * context , const char * pg_restrict fmt ,...)
985
904
{
986
905
va_list ap ;
@@ -997,7 +916,7 @@ report_backup_error(verifier_context *context, const char *pg_restrict fmt,...)
997
916
/*
998
917
* Report a fatal error and exit
999
918
*/
1000
- static void
919
+ void
1001
920
report_fatal_error (const char * pg_restrict fmt ,...)
1002
921
{
1003
922
va_list ap ;
@@ -1016,7 +935,7 @@ report_fatal_error(const char *pg_restrict fmt,...)
1016
935
* Note that by "prefix" we mean a parent directory; for this purpose,
1017
936
* "aa/bb" is not a prefix of "aa/bbb", but it is a prefix of "aa/bb/cc".
1018
937
*/
1019
- static bool
938
+ bool
1020
939
should_ignore_relpath (verifier_context * context , const char * relpath )
1021
940
{
1022
941
SimpleStringListCell * cell ;
0 commit comments