/*************************************************************************
Reads the data files and their sizes from a character string given in
the .cnf file. */
ibool
srv_parse_data_file_paths_and_sizes(
/*================================*/
/* out: TRUE if ok, FALSE if parsing
error */
char* str, /* in: the data file path string */
char*** data_file_names, /* out, own: array of data file
names */
ulint** data_file_sizes, /* out, own: array of data file sizes
in megabytes */
ulint** data_file_is_raw_partition,/* out, own: array of flags
showing which data files are raw
partitions */
ulint* n_data_files, /* out: number of data files */
ibool* is_auto_extending, /* out: TRUE if the last data file is
auto-extending */
ulint* max_auto_extend_size) /* out: max auto extend size for the
last file if specified, 0 if not */
{
char* input_str;
char* path;
ulint size;
ulint i = 0;
*is_auto_extending = FALSE;
*max_auto_extend_size = 0;
input_str = str;
/* First calculate the number of data files and check syntax:
path:size[M | G];path:size[M | G]... . Note that a Windows path may
contain a drive name and a ':'. */
while (*str != '\0') {
path = str;
while ((*str != ':' && *str != '\0')
|| (*str == ':'
&& (*(str + 1) == '\\' || *(str + 1) == '/'
|| *(str + 1) == ':'))) {
str++;
}
if (*str == '\0') {
return(FALSE);
}
str++;
str = srv_parse_megabytes(str, &size);
if (0 == strncmp(str, ":autoextend",
(sizeof ":autoextend") - 1)) {
str += (sizeof ":autoextend") - 1;
if (0 == strncmp(str, ":max:",
(sizeof ":max:") - 1)) {
str += (sizeof ":max:") - 1;
str = srv_parse_megabytes(str, &size);
}
if (*str != '\0') {
return(FALSE);
}
}
if (strlen(str) >= 6
&& *str == 'n'
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
}
if (size == 0) {
return(FALSE);
}
i++;
if (*str == ';') {
str++;
} else if (*str != '\0') {
return(FALSE);
}
}
if (i == 0) {
/* If innodb_data_file_path was defined it must contain
at least one data file definition */
return(FALSE);
}
*data_file_names = (char**)ut_malloc(i * sizeof(void*));
*data_file_sizes = (ulint*)ut_malloc(i * sizeof(ulint));
*data_file_is_raw_partition = (ulint*)ut_malloc(i * sizeof(ulint));
*n_data_files = i;
/* Then store the actual values to our arrays */
str = input_str;
i = 0;
while (*str != '\0') {
path = str;
/* Note that we must step over the ':' in a Windows path;
a Windows path normally looks like C:\ibdata\ibdata1:1G, but
a Windows raw partition may have a specification like
\\.\C::1Gnewraw or \\.\PHYSICALDRIVE2:1Gnewraw */
while ((*str != ':' && *str != '\0')
|| (*str == ':'
&& (*(str + 1) == '\\' || *(str + 1) == '/'
|| *(str + 1) == ':'))) {
str++;
}
if (*str == ':') {
/* Make path a null-terminated string */
*str = '\0';
str++;
}
str = srv_parse_megabytes(str, &size);
(*data_file_names)[i] = path;
(*data_file_sizes)[i] = size;
if (0 == strncmp(str, ":autoextend",
(sizeof ":autoextend") - 1)) {
*is_auto_extending = TRUE;
str += (sizeof ":autoextend") - 1;
if (0 == strncmp(str, ":max:",
(sizeof ":max:") - 1)) {
str += (sizeof ":max:") - 1;
str = srv_parse_megabytes(
str, max_auto_extend_size);
}
if (*str != '\0') {
return(FALSE);
}
}
(*data_file_is_raw_partition)[i] = 0;
if (strlen(str) >= 6
&& *str == 'n'
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
(*data_file_is_raw_partition)[i] = SRV_NEW_RAW;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
if ((*data_file_is_raw_partition)[i] == 0) {
(*data_file_is_raw_partition)[i] = SRV_OLD_RAW;
}
}
i++;
if (*str == ';') {
str++;
}
}
return(TRUE);
}
Reads the data files and their sizes from a character string given in
the .cnf file. */
ibool
srv_parse_data_file_paths_and_sizes(
/*================================*/
/* out: TRUE if ok, FALSE if parsing
error */
char* str, /* in: the data file path string */
char*** data_file_names, /* out, own: array of data file
names */
ulint** data_file_sizes, /* out, own: array of data file sizes
in megabytes */
ulint** data_file_is_raw_partition,/* out, own: array of flags
showing which data files are raw
partitions */
ulint* n_data_files, /* out: number of data files */
ibool* is_auto_extending, /* out: TRUE if the last data file is
auto-extending */
ulint* max_auto_extend_size) /* out: max auto extend size for the
last file if specified, 0 if not */
{
char* input_str;
char* path;
ulint size;
ulint i = 0;
*is_auto_extending = FALSE;
*max_auto_extend_size = 0;
input_str = str;
/* First calculate the number of data files and check syntax:
path:size[M | G];path:size[M | G]... . Note that a Windows path may
contain a drive name and a ':'. */
while (*str != '\0') {
path = str;
while ((*str != ':' && *str != '\0')
|| (*str == ':'
&& (*(str + 1) == '\\' || *(str + 1) == '/'
|| *(str + 1) == ':'))) {
str++;
}
if (*str == '\0') {
return(FALSE);
}
str++;
str = srv_parse_megabytes(str, &size);
if (0 == strncmp(str, ":autoextend",
(sizeof ":autoextend") - 1)) {
str += (sizeof ":autoextend") - 1;
if (0 == strncmp(str, ":max:",
(sizeof ":max:") - 1)) {
str += (sizeof ":max:") - 1;
str = srv_parse_megabytes(str, &size);
}
if (*str != '\0') {
return(FALSE);
}
}
if (strlen(str) >= 6
&& *str == 'n'
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
}
if (size == 0) {
return(FALSE);
}
i++;
if (*str == ';') {
str++;
} else if (*str != '\0') {
return(FALSE);
}
}
if (i == 0) {
/* If innodb_data_file_path was defined it must contain
at least one data file definition */
return(FALSE);
}
*data_file_names = (char**)ut_malloc(i * sizeof(void*));
*data_file_sizes = (ulint*)ut_malloc(i * sizeof(ulint));
*data_file_is_raw_partition = (ulint*)ut_malloc(i * sizeof(ulint));
*n_data_files = i;
/* Then store the actual values to our arrays */
str = input_str;
i = 0;
while (*str != '\0') {
path = str;
/* Note that we must step over the ':' in a Windows path;
a Windows path normally looks like C:\ibdata\ibdata1:1G, but
a Windows raw partition may have a specification like
\\.\C::1Gnewraw or \\.\PHYSICALDRIVE2:1Gnewraw */
while ((*str != ':' && *str != '\0')
|| (*str == ':'
&& (*(str + 1) == '\\' || *(str + 1) == '/'
|| *(str + 1) == ':'))) {
str++;
}
if (*str == ':') {
/* Make path a null-terminated string */
*str = '\0';
str++;
}
str = srv_parse_megabytes(str, &size);
(*data_file_names)[i] = path;
(*data_file_sizes)[i] = size;
if (0 == strncmp(str, ":autoextend",
(sizeof ":autoextend") - 1)) {
*is_auto_extending = TRUE;
str += (sizeof ":autoextend") - 1;
if (0 == strncmp(str, ":max:",
(sizeof ":max:") - 1)) {
str += (sizeof ":max:") - 1;
str = srv_parse_megabytes(
str, max_auto_extend_size);
}
if (*str != '\0') {
return(FALSE);
}
}
(*data_file_is_raw_partition)[i] = 0;
if (strlen(str) >= 6
&& *str == 'n'
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
(*data_file_is_raw_partition)[i] = SRV_NEW_RAW;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
if ((*data_file_is_raw_partition)[i] == 0) {
(*data_file_is_raw_partition)[i] = SRV_OLD_RAW;
}
}
i++;
if (*str == ';') {
str++;
}
}
return(TRUE);
}