1313#include <grp.h>
1414
1515
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 );
1919static const char * validate_exec (const char * path );
2020
2121
@@ -30,7 +30,7 @@ static const char *validate_exec(const char *path);
3030 *instead of returning should an error occur.
3131 */
3232int
33- exec_prog (migratorContext * ctx , bool throw_error ,const char * fmt ,...)
33+ exec_prog (bool throw_error ,const char * fmt ,...)
3434{
3535va_list args ;
3636int result ;
@@ -40,13 +40,13 @@ exec_prog(migratorContext *ctx, bool throw_error, const char *fmt,...)
4040vsnprintf (cmd ,MAXPGPATH ,fmt ,args );
4141va_end (args );
4242
43- pg_log (ctx , PG_INFO ,"%s\n" ,cmd );
43+ pg_log (PG_INFO ,"%s\n" ,cmd );
4444
4545result = system (cmd );
4646
4747if (result != 0 )
4848{
49- pg_log (ctx , throw_error ?PG_FATAL :PG_INFO ,
49+ pg_log (throw_error ?PG_FATAL :PG_INFO ,
5050"\nThere were problems executing %s\n" ,cmd );
5151return 1 ;
5252}
@@ -62,7 +62,7 @@ exec_prog(migratorContext *ctx, bool throw_error, const char *fmt,...)
6262 * The check is performed by looking for the existence of postmaster.pid file.
6363 */
6464bool
65- is_server_running (migratorContext * ctx , const char * datadir )
65+ is_server_running (const char * datadir )
6666{
6767char path [MAXPGPATH ];
6868int fd ;
@@ -72,7 +72,7 @@ is_server_running(migratorContext *ctx, const char *datadir)
7272if ((fd = open (path ,O_RDONLY ,0 ))< 0 )
7373{
7474if (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" ,
7676path );
7777
7878return false;
@@ -92,23 +92,23 @@ is_server_running(migratorContext *ctx, const char *datadir)
9292 * NOTE: May update the values of all parameters
9393 */
9494void
95- verify_directories (migratorContext * ctx )
95+ verify_directories (void )
9696{
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 ();
100100
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 ();
104104
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 ();
108108
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 ();
112112}
113113
114114
@@ -122,7 +122,7 @@ verify_directories(migratorContext *ctx)
122122 *
123123 */
124124static void
125- check_data_dir (migratorContext * ctx , const char * pg_data )
125+ check_data_dir (const char * pg_data )
126126{
127127char subDirName [MAXPGPATH ];
128128int subdirnum ;
@@ -140,10 +140,10 @@ check_data_dir(migratorContext *ctx, const char *pg_data)
140140requiredSubdirs [subdirnum ]);
141141
142142if (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" ,
144144requiredSubdirs [subdirnum ],getErrorText (errno ));
145145else 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" ,
147147requiredSubdirs [subdirnum ]);
148148}
149149}
@@ -158,12 +158,12 @@ check_data_dir(migratorContext *ctx, const char *pg_data)
158158 *exit().
159159 */
160160static void
161- check_bin_dir (migratorContext * ctx , ClusterInfo * cluster )
161+ check_bin_dir (ClusterInfo * cluster )
162162{
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" );
167167}
168168
169169
@@ -177,7 +177,7 @@ check_bin_dir(migratorContext *ctx, ClusterInfo *cluster)
177177 *a valid executable, this function returns 0 to indicated failure.
178178 */
179179static int
180- check_exec (migratorContext * ctx , const char * dir ,const char * cmdName )
180+ check_exec (const char * dir ,const char * cmdName )
181181{
182182char path [MAXPGPATH ];
183183const char * errMsg ;
@@ -187,7 +187,7 @@ check_exec(migratorContext *ctx, const char *dir, const char *cmdName)
187187if ((errMsg = validate_exec (path ))== NULL )
188188return 1 ;/* 1 -> first alternative OK */
189189else
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 );
191191
192192return 0 ;/* 0 -> neither alternative is acceptable */
193193}