Исправил ошибку записи конфигурации

pull/4/head
Igor Belitskiy 2 years ago
parent 00c7bb8202
commit e600fab7cc

@ -975,15 +975,14 @@ void wrapper_system_save() {
char* save_format_key(int index) { char* save_format_key(int index) {
char* key = NULL; if (strstr(main_config.quota_volume[index], "-") != NULL) {
if (strstr(main_config.quota_volume[index], "-") == NULL) { return yon_char_unite("CGROUP_QUOTA[", main_config.quota_volume[index] , "]", NULL);
key = yon_char_unite("CGROUP_QUOTA[", main_config.quota_volume[index] , "]", NULL);
} }
return key; return NULL;
} }
char* save_format_value(int index) { char* save_format_value(int index) {
char* value = ""; char* value = yon_char_new("");
char split_simvol[2] = {0}; char split_simvol[2] = {0};
split_simvol[0] = 0; split_simvol[0] = 0;
split_simvol[1] = 0; split_simvol[1] = 0;
@ -1019,30 +1018,46 @@ char* save_format_value(int index) {
split_simvol[0] = ','; split_simvol[0] = ',';
split_simvol[1] = '\0'; split_simvol[1] = '\0';
} }
value = add_io_str_format_ubconfig(value, "IOReadBandwidthMax", main_config.i_o_limit_read, main_config.i_o_limit_read_size, main_config.disk, index);
value = add_io_str_format_ubconfig(value, "IOWriteBandwidthMax", main_config.i_o_limit_write, main_config.i_o_limit_write_size, main_config.disk, index); char* value_read = add_io_str_format_ubconfig("IOReadBandwidthMax", main_config.i_o_limit_read, main_config.i_o_limit_read_size, main_config.disk, index);
char* value_write = add_io_str_format_ubconfig("IOWriteBandwidthMax", main_config.i_o_limit_write, main_config.i_o_limit_write_size, main_config.disk, index);
if (strlen(value_read) > 5){
if (strlen(value) > 5) {
value = yon_char_unite(value, ",", value_read, NULL);
}
else {
value = yon_char_unite(value_read, NULL);
}
}
if (strlen(value_write)> 5) {
if (strlen(value) > 5) {
value = yon_char_unite(value, ",", value_write, NULL);
}
else {
value = yon_char_unite(value_write, NULL);
}
}
return value; return value;
} }
char* add_io_str_format_ubconfig(char* cmd_io, char* key, int** i_o_limit, int** i_o_limit_size, char*** disk, int index) { char* add_io_str_format_ubconfig(char* key, int** i_o_limit, int** i_o_limit_size, char*** disk, int index) {
char split_simvol[2] = {0}; char split_simvol[2] = {0};
if (i_o_limit== NULL) {return cmd_io;} char* cmd_io = "";
if (i_o_limit_size[index] == NULL) {return cmd_io;} if (i_o_limit== NULL) {return NULL;}
if (i_o_limit[index] == NULL) {return cmd_io;} if (i_o_limit_size[index] == NULL) {return NULL;}
if (i_o_limit[index] == NULL) {return NULL;}
int len_array = 0; int len_array = 0;
for (int i = 0;i_o_limit[index][i] != -2; i++) { for (int i = 0;i_o_limit[index][i] != -2; i++) {
len_array += 1; len_array += 1;
} }
for (int i=0; i<len_array; i++) { for (int i=0; i<len_array; i++) {
if (i==0 && strlen(cmd_io) < 3) {
cmd_io = yon_char_unite(cmd_io, key, "=", NULL);
}
else if (i==0 && strlen(cmd_io) > 3) {
cmd_io = yon_char_unite(cmd_io, ",", key, "=", NULL);
}
int read_limit = i_o_limit[index][i]; int read_limit = i_o_limit[index][i];
char* read_disk = disk[index][i]; char* read_disk = disk[index][i];
int read_limit_size = i_o_limit_size[index][i]; int read_limit_size = i_o_limit_size[index][i];
if (read_limit >= 0 && read_disk && read_limit_size >= 0) { if (read_limit >= 0 && read_disk && read_limit_size >= 0) {
if (i==0 && strlen(cmd_io) < 3) {
cmd_io = yon_char_unite(cmd_io, key, "=", NULL);
}
char* num_and_pow_size = philos_format_cfg_str_size_memory("",read_limit, read_limit_size); char* num_and_pow_size = philos_format_cfg_str_size_memory("",read_limit, read_limit_size);
cmd_io = yon_char_unite(cmd_io, split_simvol, read_disk, " ",num_and_pow_size, NULL); cmd_io = yon_char_unite(cmd_io, split_simvol, read_disk, " ",num_and_pow_size, NULL);
split_simvol[0] = ','; split_simvol[0] = ',';
@ -1091,24 +1106,23 @@ int template_format_str_save(char* source_set_cmd, char* source_remove_cmd) {
} }
char* template_format_str_set_save(char* source_set_cmd) { char* template_format_str_set_save(char* source_set_cmd) {
char* cmd = yon_char_new(source_set_cmd); char* cmd = yon_char_new("");
for (size_t index = 0; index < main_config.size_tree_view; index++) { for (size_t index = 0; index < main_config.size_tree_view; index++) {
char* key = NULL; char* key = save_format_key(index);
char* value = NULL; char* value = save_format_value(index);
key = yon_char_new(save_format_key(index));
value = yon_char_new(save_format_value(index));
if (key != NULL && value != NULL) { if (key != NULL && value != NULL) {
cmd = yon_char_unite(cmd, " " , key, "=\"" , value, "\" ", NULL); cmd = yon_char_unite(cmd, " " , key, "=\"" , value, "\" ", NULL);
} }
if (key != NULL) { if (key != NULL) {
free(key); free(key);
} }
else if (value != NULL) { if (value != NULL) {
free(value); free(value);
} }
} }
if (cmd != NULL && check_save()== 0) {
if (strlen(cmd) > 1 && check_save()== 0) { cmd = yon_char_unite(source_set_cmd, " " ,cmd, NULL);
puts(cmd);
return cmd; return cmd;
} }
free(cmd); free(cmd);

@ -44,7 +44,7 @@
#define CMD_GET_GROUP "cut -d: -f1 /etc/group" #define CMD_GET_GROUP "cut -d: -f1 /etc/group"
typedef char *string; typedef char *string;
string version_application; string version_application="1.2";
static char *local; static char *local;
@ -213,6 +213,6 @@ char* template_format_str_remove_save(char* source_remove_cmd);
char* template_format_str_set_save(char* source_set_cmd); char* template_format_str_set_save(char* source_set_cmd);
char* save_format_key(int index); char* save_format_key(int index);
void get_param_io_limit(char** arr_values, int index_start, int size, int index_n1, char *key_find); void get_param_io_limit(char** arr_values, int index_start, int size, int index_n1, char *key_find);
char* add_io_str_format_ubconfig(char* cmd_io, char* key, int** i_o_limit, int** i_o_limit_size, char*** disk_read, int index); char* add_io_str_format_ubconfig(char* key, int** i_o_limit, int** i_o_limit_size, char*** disk_read, int index);
char* format_io_limit_in_tree_view(config_str* disk, int** i_o_limit, int** i_o_limit_size, int index); char* format_io_limit_in_tree_view(config_str* disk, int** i_o_limit, int** i_o_limit_size, int index);
gboolean select_page_notebook(GtkNotebook* self, gboolean object, gpointer user_data); gboolean select_page_notebook(GtkNotebook* self, gboolean object, gpointer user_data);

@ -169,7 +169,7 @@ void add_show(GtkWidget *self, char* glade_path) {
char* add_get_select_device_to_level_2() { char* add_get_select_device_to_level_2() {
char* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(add_widgets->cbxTempQuotaLevel2)); char* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(add_widgets->cbxTempQuotaLevel2));
int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbxTempQuotaLevel2)); int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbxTempQuotaLevel2));
if (disk_id != -1) { if (disk_id >= 0) {
return text; return text;
} }
else { else {

Loading…
Cancel
Save