13
13
#include <grp.h>
14
14
15
15
16
- static void check_data_dir (migratorContext * ctx , const char * pg_data );
17
- static void check_bin_dir (migratorContext * ctx , ClusterInfo * cluster );
18
- static int check_exec (migratorContext * ctx , const char * dir , const char * cmdName );
16
+ static void check_data_dir (const char * pg_data );
17
+ static void check_bin_dir (ClusterInfo * cluster );
18
+ static int check_exec (const char * dir , const char * cmdName );
19
19
static const char * validate_exec (const char * path );
20
20
21
21
@@ -30,7 +30,7 @@ static const char *validate_exec(const char *path);
30
30
* instead of returning should an error occur.
31
31
*/
32
32
int
33
- exec_prog (migratorContext * ctx , bool throw_error , const char * fmt ,...)
33
+ exec_prog (bool throw_error , const char * fmt ,...)
34
34
{
35
35
va_list args ;
36
36
int result ;
@@ -40,13 +40,13 @@ exec_prog(migratorContext *ctx, bool throw_error, const char *fmt,...)
40
40
vsnprintf (cmd , MAXPGPATH , fmt , args );
41
41
va_end (args );
42
42
43
- pg_log (ctx , PG_INFO , "%s\n" , cmd );
43
+ pg_log (PG_INFO , "%s\n" , cmd );
44
44
45
45
result = system (cmd );
46
46
47
47
if (result != 0 )
48
48
{
49
- pg_log (ctx , throw_error ? PG_FATAL : PG_INFO ,
49
+ pg_log (throw_error ? PG_FATAL : PG_INFO ,
50
50
"\nThere were problems executing %s\n" , cmd );
51
51
return 1 ;
52
52
}
@@ -62,7 +62,7 @@ exec_prog(migratorContext *ctx, bool throw_error, const char *fmt,...)
62
62
* The check is performed by looking for the existence of postmaster.pid file.
63
63
*/
64
64
bool
65
- is_server_running (migratorContext * ctx , const char * datadir )
65
+ is_server_running (const char * datadir )
66
66
{
67
67
char path [MAXPGPATH ];
68
68
int fd ;
@@ -72,7 +72,7 @@ is_server_running(migratorContext *ctx, const char *datadir)
72
72
if ((fd = open (path , O_RDONLY , 0 )) < 0 )
73
73
{
74
74
if (errno != ENOENT )
75
- pg_log (ctx , PG_FATAL , "\ncould not open file \"%s\" for reading\n" ,
75
+ pg_log (PG_FATAL , "\ncould not open file \"%s\" for reading\n" ,
76
76
path );
77
77
78
78
return false;
@@ -92,23 +92,23 @@ is_server_running(migratorContext *ctx, const char *datadir)
92
92
* NOTE: May update the values of all parameters
93
93
*/
94
94
void
95
- verify_directories (migratorContext * ctx )
95
+ verify_directories (void )
96
96
{
97
- prep_status (ctx , "Checking old data directory (%s)" , ctx -> old .pgdata );
98
- check_data_dir (ctx , ctx -> old .pgdata );
99
- check_ok (ctx );
97
+ prep_status ("Checking old data directory (%s)" , old_cluster .pgdata );
98
+ check_data_dir (old_cluster .pgdata );
99
+ check_ok ();
100
100
101
- prep_status (ctx , "Checking old bin directory (%s)" , ctx -> old .bindir );
102
- check_bin_dir (ctx , & ctx -> old );
103
- check_ok (ctx );
101
+ prep_status ("Checking old bin directory (%s)" , old_cluster .bindir );
102
+ check_bin_dir (& old_cluster );
103
+ check_ok ();
104
104
105
- prep_status (ctx , "Checking new data directory (%s)" , ctx -> new .pgdata );
106
- check_data_dir (ctx , ctx -> new .pgdata );
107
- check_ok (ctx );
105
+ prep_status ("Checking new data directory (%s)" , new_cluster .pgdata );
106
+ check_data_dir (new_cluster .pgdata );
107
+ check_ok ();
108
108
109
- prep_status (ctx , "Checking new bin directory (%s)" , ctx -> new .bindir );
110
- check_bin_dir (ctx , & ctx -> new );
111
- check_ok (ctx );
109
+ prep_status ("Checking new bin directory (%s)" , new_cluster .bindir );
110
+ check_bin_dir (& new_cluster );
111
+ check_ok ();
112
112
}
113
113
114
114
@@ -122,7 +122,7 @@ verify_directories(migratorContext *ctx)
122
122
*
123
123
*/
124
124
static void
125
- check_data_dir (migratorContext * ctx , const char * pg_data )
125
+ check_data_dir (const char * pg_data )
126
126
{
127
127
char subDirName [MAXPGPATH ];
128
128
int subdirnum ;
@@ -140,10 +140,10 @@ check_data_dir(migratorContext *ctx, const char *pg_data)
140
140
requiredSubdirs [subdirnum ]);
141
141
142
142
if (stat (subDirName , & statBuf ) != 0 )
143
- report_status (ctx , PG_FATAL , "check for %s failed: %s" ,
143
+ report_status (PG_FATAL , "check for %s failed: %s" ,
144
144
requiredSubdirs [subdirnum ], getErrorText (errno ));
145
145
else if (!S_ISDIR (statBuf .st_mode ))
146
- report_status (ctx , PG_FATAL , "%s is not a directory" ,
146
+ report_status (PG_FATAL , "%s is not a directory" ,
147
147
requiredSubdirs [subdirnum ]);
148
148
}
149
149
}
@@ -158,12 +158,12 @@ check_data_dir(migratorContext *ctx, const char *pg_data)
158
158
* exit().
159
159
*/
160
160
static void
161
- check_bin_dir (migratorContext * ctx , ClusterInfo * cluster )
161
+ check_bin_dir (ClusterInfo * cluster )
162
162
{
163
- check_exec (ctx , cluster -> bindir , "postgres" );
164
- check_exec (ctx , cluster -> bindir , "psql" );
165
- check_exec (ctx , cluster -> bindir , "pg_ctl" );
166
- check_exec (ctx , cluster -> bindir , "pg_dumpall" );
163
+ check_exec (cluster -> bindir , "postgres" );
164
+ check_exec (cluster -> bindir , "psql" );
165
+ check_exec (cluster -> bindir , "pg_ctl" );
166
+ check_exec (cluster -> bindir , "pg_dumpall" );
167
167
}
168
168
169
169
@@ -177,7 +177,7 @@ check_bin_dir(migratorContext *ctx, ClusterInfo *cluster)
177
177
* a valid executable, this function returns 0 to indicated failure.
178
178
*/
179
179
static int
180
- check_exec (migratorContext * ctx , const char * dir , const char * cmdName )
180
+ check_exec (const char * dir , const char * cmdName )
181
181
{
182
182
char path [MAXPGPATH ];
183
183
const char * errMsg ;
@@ -187,7 +187,7 @@ check_exec(migratorContext *ctx, const char *dir, const char *cmdName)
187
187
if ((errMsg = validate_exec (path )) == NULL )
188
188
return 1 ; /* 1 -> first alternative OK */
189
189
else
190
- pg_log (ctx , PG_FATAL , "check for %s failed - %s\n" , cmdName , errMsg );
190
+ pg_log (PG_FATAL , "check for %s failed - %s\n" , cmdName , errMsg );
191
191
192
192
return 0 ; /* 0 -> neither alternative is acceptable */
193
193
}
0 commit comments