srv_parse_data_file_paths_and_sizes函数说明(innobase-srv0start.c)

/*************************************************************************
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);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值