Commit 55f0e6bf authored by Michael Widenius's avatar Michael Widenius

Fixes for netware by Guenter Knauf

parent ffab2a90
...@@ -57,6 +57,7 @@ extern "C" { ...@@ -57,6 +57,7 @@ extern "C" {
#undef HAVE_RWLOCK_INIT #undef HAVE_RWLOCK_INIT
#undef HAVE_SCHED_H #undef HAVE_SCHED_H
#undef HAVE_SYS_MMAN_H #undef HAVE_SYS_MMAN_H
#undef HAVE_SYS_UN_H
#undef HAVE_SYNCH_H #undef HAVE_SYNCH_H
#undef HAVE_MMAP #undef HAVE_MMAP
#undef HAVE_RINT #undef HAVE_RINT
......
...@@ -108,6 +108,7 @@ init_db.sql: $(top_srcdir)/scripts/mysql_system_tables.sql \ ...@@ -108,6 +108,7 @@ init_db.sql: $(top_srcdir)/scripts/mysql_system_tables.sql \
@echo "CREATE DATABASE test;" >> $@; @echo "CREATE DATABASE test;" >> $@;
@echo "use mysql;" >> $@; @echo "use mysql;" >> $@;
@cat $(top_srcdir)/scripts/mysql_system_tables.sql >> $@; @cat $(top_srcdir)/scripts/mysql_system_tables.sql >> $@;
@cat $(top_srcdir)/scripts/mysql_system_tables_data.sql | grep -v '@current_hostname' >> $@;
# Build test_db.sql from init_db.sql plus # Build test_db.sql from init_db.sql plus
# some test data # some test data
......
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#include <proc.h> #include <proc.h>
#include <ctype.h> #include <ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h> #include <fcntl.h>
#include <assert.h> #include <assert.h>
#include <nks/vm.h>
#include "my_manage.h" #include "my_manage.h"
...@@ -356,17 +358,17 @@ pid_t get_server_pid(char *pid_file) ...@@ -356,17 +358,17 @@ pid_t get_server_pid(char *pid_file)
// terminate string // terminate string
if ((p = strchr(buf, '\n')) != NULL) if ((p = strchr(buf, '\n')) != NULL)
{ {
*p = NULL; *p = 0;
// check for a '\r' // check for a '\r'
if ((p = strchr(buf, '\r')) != NULL) if ((p = strchr(buf, '\r')) != NULL)
{ {
*p = NULL; *p = 0;
} }
} }
else else
{ {
buf[err] = NULL; buf[err] = 0;
} }
id = strtol(buf, NULL, 0); id = strtol(buf, NULL, 0);
...@@ -471,7 +473,7 @@ void get_basedir(char *argv0, char *basedir) ...@@ -471,7 +473,7 @@ void get_basedir(char *argv0, char *basedir)
if ((p = strindex(temp, "/bin/")) != NULL) if ((p = strindex(temp, "/bin/")) != NULL)
{ {
*p = NULL; *p = 0;
strcpy(basedir, temp); strcpy(basedir, temp);
} }
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
global variables global variables
******************************************************************************/ ******************************************************************************/
char autoclose; int autoclose;
char basedir[PATH_MAX]; char basedir[PATH_MAX];
char datadir[PATH_MAX]; char datadir[PATH_MAX];
char err_log[PATH_MAX]; char err_log[PATH_MAX];
...@@ -99,7 +99,7 @@ void start_defaults(int argc, char *argv[]) ...@@ -99,7 +99,7 @@ void start_defaults(int argc, char *argv[])
} }
// default option // default option
default_option[0] = NULL; default_option[0] = 0;
for (i=0; (argc > 1) && default_options[i]; i++) for (i=0; (argc > 1) && default_options[i]; i++)
{ {
if(!strnicmp(argv[1], default_options[i], strlen(default_options[i]))) if(!strnicmp(argv[1], default_options[i], strlen(default_options[i])))
...@@ -110,11 +110,11 @@ void start_defaults(int argc, char *argv[]) ...@@ -110,11 +110,11 @@ void start_defaults(int argc, char *argv[])
} }
// set after basedir is established // set after basedir is established
datadir[0] = NULL; datadir[0] = 0;
err_log[0] = NULL; err_log[0] = 0;
out_log[0] = NULL; out_log[0] = 0;
mysqld[0] = NULL; mysqld[0] = 0;
sql_file[0] = NULL; sql_file[0] = 0;
} }
/****************************************************************************** /******************************************************************************
......
/* /*
Copyright (c) 2003 Novell, Inc. All Rights Reserved. Copyright (c) 2003 Novell, Inc. All Rights Reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
...@@ -10,74 +10,74 @@ ...@@ -10,74 +10,74 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <netdb.h> #include <netdb.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <monitor.h> #include <monitor.h>
#include <strings.h> #include <strings.h>
#include <getopt.h> #include <getopt.h>
#include <screen.h> #include <screen.h>
#include <dirent.h> #include <dirent.h>
#include "my_config.h" #include "my_config.h"
#include "my_manage.h" #include "my_manage.h"
#include "mysql_version.h" #include "mysql_version.h"
/****************************************************************************** /******************************************************************************
global variables global variables
******************************************************************************/ ******************************************************************************/
char autoclose; char autoclose;
char basedir[PATH_MAX]; char basedir[PATH_MAX];
char checktables; char checktables;
char datadir[PATH_MAX]; char datadir[PATH_MAX];
char pid_file[PATH_MAX]; char pid_file[PATH_MAX];
char address[PATH_MAX]; char address[PATH_MAX];
char port[PATH_MAX]; char port[PATH_MAX];
char err_log[PATH_MAX]; char err_log[PATH_MAX];
char safe_log[PATH_MAX]; char safe_log[PATH_MAX];
char mysqld[PATH_MAX]; char mysqld[PATH_MAX];
char hostname[PATH_MAX]; char hostname[PATH_MAX];
char default_option[PATH_MAX]; char default_option[PATH_MAX];
FILE *log_fd= NULL; FILE *log_fd= NULL;
/******************************************************************************
prototypes
******************************************************************************/ /******************************************************************************
prototypes
******************************************************************************/
void usage(void); void usage(void);
void vlog(char *, va_list); void vlog(char *, va_list);
void log(char *, ...); void log(char *, ...);
void start_defaults(int, char *[]); void start_defaults(int, char *[]);
void finish_defaults(); void finish_defaults();
void read_defaults(arg_list_t *); void read_defaults(arg_list_t *);
void parse_args(int, char *[]); void parse_args(int, char *[]);
void get_options(int, char *[]); void get_options(int, char *[]);
void check_data_vol(); void check_data_vol();
void check_setup(); void check_setup();
void check_tables(); void check_tables();
void mysql_start(int, char *[]); void mysql_start(int, char *[]);
void parse_setvar(char *arg); void parse_setvar(char *arg);
/****************************************************************************** /******************************************************************************
functions functions
******************************************************************************/ ******************************************************************************/
/****************************************************************************** /******************************************************************************
usage() usage()
Show usage. Show usage.
...@@ -114,86 +114,86 @@ options:\n\ ...@@ -114,86 +114,86 @@ options:\n\
/****************************************************************************** /******************************************************************************
vlog() vlog()
Log the message. Log the message.
******************************************************************************/ ******************************************************************************/
void vlog(char *format, va_list ap) void vlog(char *format, va_list ap)
{ {
vfprintf(stdout, format, ap); vfprintf(stdout, format, ap);
fflush(stdout); fflush(stdout);
if (log_fd) if (log_fd)
{ {
vfprintf(log_fd, format, ap); vfprintf(log_fd, format, ap);
fflush(log_fd); fflush(log_fd);
} }
} }
/****************************************************************************** /******************************************************************************
log() log()
Log the message. Log the message.
******************************************************************************/ ******************************************************************************/
void log(char *format, ...) void log(char *format, ...)
{ {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vlog(format, ap); vlog(format, ap);
va_end(ap); va_end(ap);
} }
/****************************************************************************** /******************************************************************************
start_defaults() start_defaults()
Start setting the defaults. Start setting the defaults.
******************************************************************************/ ******************************************************************************/
void start_defaults(int argc, char *argv[]) void start_defaults(int argc, char *argv[])
{ {
struct stat buf; struct stat buf;
int i; int i;
// default options // default options
static char *default_options[]= static char *default_options[]=
{ {
"--no-defaults", "--no-defaults",
"--defaults-file=", "--defaults-file=",
"--defaults-extra-file=", "--defaults-extra-file=",
NULL NULL
}; };
// autoclose // autoclose
autoclose= FALSE; autoclose= FALSE;
// basedir // basedir
get_basedir(argv[0], basedir); get_basedir(argv[0], basedir);
// check-tables // check-tables
checktables= FALSE; checktables= FALSE;
// hostname // hostname
if (gethostname(hostname, PATH_MAX) < 0) if (gethostname(hostname, PATH_MAX) < 0)
{ {
// default // default
strcpy(hostname, "mysql"); strcpy(hostname, "mysql");
} }
// address // address
snprintf(address, PATH_MAX, "0.0.0.0"); snprintf(address, PATH_MAX, "0.0.0.0");
// port // port
snprintf(port, PATH_MAX, "%d", MYSQL_PORT); snprintf(port, PATH_MAX, "%d", MYSQL_PORT);
// default option // default option
default_option[0]= NULL; default_option[0]= 0;
for (i= 0; (argc > 1) && default_options[i]; i++) for (i= 0; (argc > 1) && default_options[i]; i++)
{ {
if (!strnicmp(argv[1], default_options[i], strlen(default_options[i]))) if (!strnicmp(argv[1], default_options[i], strlen(default_options[i])))
...@@ -203,73 +203,73 @@ void start_defaults(int argc, char *argv[]) ...@@ -203,73 +203,73 @@ void start_defaults(int argc, char *argv[])
} }
} }
// set after basedir is established // set after basedir is established
datadir[0]= NULL; datadir[0]= 0;
pid_file[0]= NULL; pid_file[0]= 0;
err_log[0]= NULL; err_log[0]= 0;
safe_log[0]= NULL; safe_log[0]= 0;
mysqld[0]= NULL; mysqld[0]= 0;
} }
/****************************************************************************** /******************************************************************************
finish_defaults() finish_defaults()
Finish settig the defaults. Finish settig the defaults.
******************************************************************************/ ******************************************************************************/
void finish_defaults() void finish_defaults()
{ {
struct stat buf; struct stat buf;
int i; int i;
// datadir // datadir
if (!datadir[0]) if (!datadir[0])
snprintf(datadir, PATH_MAX, "%s/data", basedir); snprintf(datadir, PATH_MAX, "%s/data", basedir);
// pid-file // pid-file
if (!pid_file[0]) if (!pid_file[0])
snprintf(pid_file, PATH_MAX, "%s/%s.pid", datadir, hostname); snprintf(pid_file, PATH_MAX, "%s/%s.pid", datadir, hostname);
// err-log // err-log
if (!err_log[0]) if (!err_log[0])
snprintf(err_log, PATH_MAX, "%s/%s.err", datadir, hostname); snprintf(err_log, PATH_MAX, "%s/%s.err", datadir, hostname);
// safe-log // safe-log
if (!safe_log[0]) if (!safe_log[0])
snprintf(safe_log, PATH_MAX, "%s/%s.safe", datadir, hostname); snprintf(safe_log, PATH_MAX, "%s/%s.safe", datadir, hostname);
// mysqld // mysqld
if (!mysqld[0]) if (!mysqld[0])
snprintf(mysqld, PATH_MAX, "%s/bin/mysqld-max", basedir); snprintf(mysqld, PATH_MAX, "%s/bin/mysqld-max", basedir);
if (stat(mysqld, &buf)) if (stat(mysqld, &buf))
{ {
snprintf(mysqld, PATH_MAX, "%s/bin/mysqld", basedir); snprintf(mysqld, PATH_MAX, "%s/bin/mysqld", basedir);
} }
} }
/****************************************************************************** /******************************************************************************
read_defaults() read_defaults()
Read the defaults. Read the defaults.
******************************************************************************/ ******************************************************************************/
void read_defaults(arg_list_t *pal) void read_defaults(arg_list_t *pal)
{ {
arg_list_t al; arg_list_t al;
char defaults_file[PATH_MAX]; char defaults_file[PATH_MAX];
char mydefaults[PATH_MAX]; char mydefaults[PATH_MAX];
char line[PATH_MAX]; char line[PATH_MAX];
FILE *fp; FILE *fp;
// defaults output file // defaults output file
snprintf(defaults_file, PATH_MAX, "%s/bin/defaults.out", basedir); snprintf(defaults_file, PATH_MAX, "%s/bin/defaults.out", basedir);
remove(defaults_file); remove(defaults_file);
// mysqladmin file // mysqladmin file
snprintf(mydefaults, PATH_MAX, "%s/bin/my_print_defaults", basedir); snprintf(mydefaults, PATH_MAX, "%s/bin/my_print_defaults", basedir);
// args // args
init_args(&al); init_args(&al);
...@@ -290,13 +290,13 @@ void read_defaults(arg_list_t *pal) ...@@ -290,13 +290,13 @@ void read_defaults(arg_list_t *pal)
{ {
while (fgets(line, PATH_MAX, fp)) while (fgets(line, PATH_MAX, fp))
{ {
char *p; char *p;
// remove end-of-line character // remove end-of-line character
if ((p= strrchr(line, '\n')) != NULL) if ((p= strrchr(line, '\n')) != NULL)
*p= '\0'; *p= '\0';
// add the option as an argument // add the option as an argument
add_arg(pal, line); add_arg(pal, line);
} }
...@@ -305,37 +305,37 @@ void read_defaults(arg_list_t *pal) ...@@ -305,37 +305,37 @@ void read_defaults(arg_list_t *pal)
// remove file // remove file
remove(defaults_file); remove(defaults_file);
} }
/****************************************************************************** /******************************************************************************
parse_args() parse_args()
Get the options. Get the options.
******************************************************************************/ ******************************************************************************/
void parse_args(int argc, char *argv[]) void parse_args(int argc, char *argv[])
{ {
int index= 0; int index= 0;
int c; int c;
// parse options // parse options
enum opts enum opts
{ {
OPT_BASEDIR= 0xFF, OPT_BASEDIR= 0xFF,
OPT_DATADIR, OPT_DATADIR,
OPT_PID_FILE, OPT_PID_FILE,
OPT_BIND_ADDRESS, OPT_BIND_ADDRESS,
OPT_PORT, OPT_PORT,
OPT_ERR_LOG, OPT_ERR_LOG,
OPT_SAFE_LOG, OPT_SAFE_LOG,
OPT_MYSQLD, OPT_MYSQLD,
OPT_HELP, OPT_HELP,
OPT_SETVAR OPT_SETVAR
}; };
static struct option options[]= static struct option options[]=
{ {
{"autoclose", no_argument, &autoclose, TRUE}, {"autoclose", no_argument, &autoclose, TRUE},
{"basedir", required_argument, 0, OPT_BASEDIR}, {"basedir", required_argument, 0, OPT_BASEDIR},
{"check-tables", no_argument, &checktables, TRUE}, {"check-tables", no_argument, &checktables, TRUE},
...@@ -349,51 +349,51 @@ void parse_args(int argc, char *argv[]) ...@@ -349,51 +349,51 @@ void parse_args(int argc, char *argv[])
{"help", no_argument, 0, OPT_HELP}, {"help", no_argument, 0, OPT_HELP},
{"set-variable", required_argument, 0, OPT_SETVAR}, {"set-variable", required_argument, 0, OPT_SETVAR},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
// we have to reset getopt_long because we use it multiple times // we have to reset getopt_long because we use it multiple times
optind= 1; optind= 1;
// turn off error reporting // turn off error reporting
opterr= 0; opterr= 0;
while ((c= getopt_long(argc, argv, "b:h:P:", options, &index)) >= 0) while ((c= getopt_long(argc, argv, "b:h:P:", options, &index)) >= 0)
{ {
switch (c) { switch (c) {
case OPT_BASEDIR: case OPT_BASEDIR:
case 'b': case 'b':
strcpy(basedir, optarg); strcpy(basedir, optarg);
break; break;
case OPT_DATADIR: case OPT_DATADIR:
case 'h': case 'h':
strcpy(datadir, optarg); strcpy(datadir, optarg);
break; break;
case OPT_PID_FILE: case OPT_PID_FILE:
strcpy(pid_file, optarg); strcpy(pid_file, optarg);
break; break;
case OPT_BIND_ADDRESS: case OPT_BIND_ADDRESS:
strcpy(address, optarg); strcpy(address, optarg);
break; break;
case OPT_PORT: case OPT_PORT:
case 'P': case 'P':
strcpy(port, optarg); strcpy(port, optarg);
break; break;
case OPT_ERR_LOG: case OPT_ERR_LOG:
strcpy(err_log, optarg); strcpy(err_log, optarg);
break; break;
case OPT_SAFE_LOG: case OPT_SAFE_LOG:
strcpy(safe_log, optarg); strcpy(safe_log, optarg);
break; break;
case OPT_MYSQLD: case OPT_MYSQLD:
strcpy(mysqld, optarg); strcpy(mysqld, optarg);
break; break;
case OPT_SETVAR: case OPT_SETVAR:
parse_setvar(optarg); parse_setvar(optarg);
...@@ -403,13 +403,13 @@ void parse_args(int argc, char *argv[]) ...@@ -403,13 +403,13 @@ void parse_args(int argc, char *argv[])
usage(); usage();
break; break;
default: default:
// ignore // ignore
break; break;
} }
} }
} }
/* /*
parse_setvar(char *arg) parse_setvar(char *arg)
Pasrsing for port just to display the port num on the mysqld_safe screen Pasrsing for port just to display the port num on the mysqld_safe screen
...@@ -430,148 +430,148 @@ void parse_setvar(char *arg) ...@@ -430,148 +430,148 @@ void parse_setvar(char *arg)
/****************************************************************************** /******************************************************************************
get_options() get_options()
Get the options.
Get the options. ******************************************************************************/
void get_options(int argc, char *argv[])
******************************************************************************/ {
void get_options(int argc, char *argv[])
{
arg_list_t al; arg_list_t al;
// start defaults // start defaults
start_defaults(argc, argv); start_defaults(argc, argv);
// default file arguments // default file arguments
init_args(&al); init_args(&al);
add_arg(&al, "ignore"); add_arg(&al, "ignore");
read_defaults(&al); read_defaults(&al);
parse_args(al.argc, al.argv); parse_args(al.argc, al.argv);
free_args(&al); free_args(&al);
// command-line arguments // command-line arguments
parse_args(argc, argv); parse_args(argc, argv);
// finish defaults // finish defaults
finish_defaults(); finish_defaults();
} }
/****************************************************************************** /******************************************************************************
check_data_vol() check_data_vol()
Check the database volume. Check the database volume.
******************************************************************************/ ******************************************************************************/
void check_data_vol() void check_data_vol()
{ {
// warn if the data is on a Traditional volume // warn if the data is on a Traditional volume
struct volume_info vol; struct volume_info vol;
char buff[PATH_MAX]; char buff[PATH_MAX];
char *p; char *p;
// clear struct // clear struct
memset(&vol, 0, sizeof(vol)); memset(&vol, 0, sizeof(vol));
// find volume name // find volume name
strcpy(buff, datadir); strcpy(buff, datadir);
if (p= strchr(buff, ':')) if (p= strchr(buff, ':'))
{ {
// terminate after volume name // terminate after volume name
*p= 0; *p= 0;
} }
else else
{ {
// assume SYS volume // assume SYS volume
strcpy(buff, "SYS"); strcpy(buff, "SYS");
} }
// retrieve information // retrieve information
netware_vol_info_from_name(&vol, buff); netware_vol_info_from_name(&vol, buff);
if ((vol.flags & VOL_NSS_PRESENT) == 0) if ((vol.flags & VOL_NSS_PRESENT) == 0)
{ {
log("Error: Either the data directory does not exist or is not on an NSS volume!\n\n"); log("Error: Either the data directory does not exist or is not on an NSS volume!\n\n");
exit(-1); exit(-1);
} }
} }
/****************************************************************************** /******************************************************************************
check_setup() check_setup()
Check the current setup. Check the current setup.
******************************************************************************/ ******************************************************************************/
void check_setup() void check_setup()
{ {
struct stat info; struct stat info;
char temp[PATH_MAX]; char temp[PATH_MAX];
// remove any current pid_file // remove any current pid_file
if (!stat(pid_file, &info) && (remove(pid_file) < 0)) if (!stat(pid_file, &info) && (remove(pid_file) < 0))
{ {
log("ERROR: Unable to remove current pid file!\n\n"); log("ERROR: Unable to remove current pid file!\n\n");
exit(-1); exit(-1);
} }
// check the data volume // check the data volume
check_data_vol(); check_data_vol();
// check for a database // check for a database
snprintf(temp, PATH_MAX, "%s/mysql/host.frm", datadir); snprintf(temp, PATH_MAX, "%s/mysql/host.frm", datadir);
if (stat(temp, &info)) if (stat(temp, &info))
{ {
log("ERROR: No database found in the data directory!\n\n"); log("ERROR: No database found in the data directory!\n\n");
exit(-1); exit(-1);
} }
} }
/****************************************************************************** /******************************************************************************
check_tables() check_tables()
Check the database tables. Check the database tables.
******************************************************************************/ ******************************************************************************/
void check_tables() void check_tables()
{ {
arg_list_t al; arg_list_t al;
char mycheck[PATH_MAX]; char mycheck[PATH_MAX];
char table[PATH_MAX]; char table[PATH_MAX];
char db[PATH_MAX]; char db[PATH_MAX];
DIR *datadir_entry, *db_entry, *table_entry; DIR *datadir_entry, *db_entry, *table_entry;
// status // status
log("checking tables...\n"); log("checking tables...\n");
// list databases // list databases
if ((datadir_entry= opendir(datadir)) == NULL) if ((datadir_entry= opendir(datadir)) == NULL)
{ {
return; return;
} }
while ((db_entry= readdir(datadir_entry)) != NULL) while ((db_entry= readdir(datadir_entry)) != NULL)
{ {
if (db_entry->d_name[0] == '.') if (db_entry->d_name[0] == '.')
{ {
// Skip // Skip
} }
else if (S_ISDIR(db_entry->d_type)) else if (S_ISDIR(db_entry->d_type))
{ {
// create long db name // create long db name
snprintf(db, PATH_MAX, "%s/%s", datadir, db_entry->d_name); snprintf(db, PATH_MAX, "%s/%s", datadir, db_entry->d_name);
// list tables // list tables
if ((db_entry= opendir(db)) == NULL) if ((db_entry= opendir(db)) == NULL)
{ {
continue; continue;
} }
while ((table_entry= readdir(db_entry)) != NULL) while ((table_entry= readdir(db_entry)) != NULL)
{ {
// create long table name // create long table name
snprintf(table, PATH_MAX, "%s/%s", db, strlwr(table_entry->d_name)); snprintf(table, PATH_MAX, "%s/%s", db, strlwr(table_entry->d_name));
...@@ -581,7 +581,7 @@ void check_tables() ...@@ -581,7 +581,7 @@ void check_tables()
// mysqladmin file // mysqladmin file
snprintf(mycheck, PATH_MAX, "%s/bin/myisamchk", basedir); snprintf(mycheck, PATH_MAX, "%s/bin/myisamchk", basedir);
// args // args
init_args(&al); init_args(&al);
add_arg(&al, mycheck); add_arg(&al, mycheck);
...@@ -594,7 +594,7 @@ void check_tables() ...@@ -594,7 +594,7 @@ void check_tables()
add_arg(&al, "-O"); add_arg(&al, "-O");
add_arg(&al, "sort_buffer=64M"); add_arg(&al, "sort_buffer=64M");
add_arg(&al, table); add_arg(&al, table);
spawn(mycheck, &al, TRUE, NULL, NULL, NULL); spawn(mycheck, &al, TRUE, NULL, NULL, NULL);
free_args(&al); free_args(&al);
...@@ -619,20 +619,20 @@ void check_tables() ...@@ -619,20 +619,20 @@ void check_tables()
free_args(&al); free_args(&al);
} }
} }
} }
} }
} }
/****************************************************************************** /******************************************************************************
mysql_start() mysql_start()
Start the mysql server. Start the mysql server.
******************************************************************************/ ******************************************************************************/
void mysql_start(int argc, char *argv[]) void mysql_start(int argc, char *argv[])
{ {
arg_list_t al; arg_list_t al;
int i, j, err; int i, j, err;
struct stat info; struct stat info;
...@@ -641,16 +641,16 @@ void mysql_start(int argc, char *argv[]) ...@@ -641,16 +641,16 @@ void mysql_start(int argc, char *argv[])
char stamp[PATH_MAX]; char stamp[PATH_MAX];
char skip; char skip;
// private options // private options
static char *private_options[]= static char *private_options[]=
{ {
"--autoclose", "--autoclose",
"--check-tables", "--check-tables",
"--help", "--help",
"--err-log=", "--err-log=",
"--mysqld=", "--mysqld=",
NULL NULL
}; };
// args // args
init_args(&al); init_args(&al);
...@@ -661,22 +661,22 @@ void mysql_start(int argc, char *argv[]) ...@@ -661,22 +661,22 @@ void mysql_start(int argc, char *argv[])
{ {
skip= FALSE; skip= FALSE;
// skip private arguments // skip private arguments
for (j= 0; private_options[j]; j++) for (j= 0; private_options[j]; j++)
{ {
if (!strnicmp(argv[i], private_options[j], strlen(private_options[j]))) if (!strnicmp(argv[i], private_options[j], strlen(private_options[j])))
{ {
skip= TRUE; skip= TRUE;
break; break;
} }
} }
if (!skip) if (!skip)
{ {
add_arg(&al, "%s", argv[i]); add_arg(&al, "%s", argv[i]);
} }
} }
// spawn // spawn
do do
{ {
// check the database tables // check the database tables
...@@ -684,10 +684,10 @@ void mysql_start(int argc, char *argv[]) ...@@ -684,10 +684,10 @@ void mysql_start(int argc, char *argv[])
check_tables(); check_tables();
// status // status
time(&cal); time(&cal);
localtime_r(&cal, &lt); localtime_r(&cal, &lt);
strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt); strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt);
log("mysql started : %s\n", stamp); log("mysql started : %s\n", stamp);
// spawn mysqld // spawn mysqld
spawn(mysqld, &al, TRUE, NULL, NULL, err_log); spawn(mysqld, &al, TRUE, NULL, NULL, err_log);
...@@ -695,57 +695,57 @@ void mysql_start(int argc, char *argv[]) ...@@ -695,57 +695,57 @@ void mysql_start(int argc, char *argv[])
while (!stat(pid_file, &info)); while (!stat(pid_file, &info));
// status // status
time(&cal); time(&cal);
localtime_r(&cal, &lt); localtime_r(&cal, &lt);
strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt); strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt);
log("mysql stopped : %s\n\n", stamp); log("mysql stopped : %s\n\n", stamp);
// free args // free args
free_args(&al); free_args(&al);
} }
/****************************************************************************** /******************************************************************************
main() main()
******************************************************************************/ ******************************************************************************/
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char temp[PATH_MAX]; char temp[PATH_MAX];
// get the options // get the options
get_options(argc, argv); get_options(argc, argv);
// keep the screen up // keep the screen up
if (!autoclose) if (!autoclose)
setscreenmode(SCR_NO_MODE); setscreenmode(SCR_NO_MODE);
// create log file // create log file
log_fd= fopen(safe_log, "w+"); log_fd= fopen(safe_log, "w+");
// header // header
log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE);
// status // status
log("address : %s\n", address); log("address : %s\n", address);
log("port : %s\n", port); log("port : %s\n", port);
log("daemon : %s\n", mysqld); log("daemon : %s\n", mysqld);
log("base directory : %s\n", basedir); log("base directory : %s\n", basedir);
log("data directory : %s\n", datadir); log("data directory : %s\n", datadir);
log("pid file : %s\n", pid_file); log("pid file : %s\n", pid_file);
log("error file : %s\n", err_log); log("error file : %s\n", err_log);
log("log file : %s\n", safe_log); log("log file : %s\n", safe_log);
log("\n"); log("\n");
// check setup // check setup
check_setup(); check_setup();
// start the MySQL server // start the MySQL server
mysql_start(argc, argv); mysql_start(argc, argv);
// close log file // close log file
if (log_fd) if (log_fd)
fclose(log_fd); fclose(log_fd);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment