| | 705 | arg1 = ovcp_request_get_arg(request, 1); |
| | 706 | cgname = (char *)ovcp_data_get(arg1); |
| | 707 | |
| | 708 | if(!ovcp_data_is_string(arg1) || cgname == NULL) |
| | 709 | return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC); |
| | 710 | |
| | 711 | arg2 = ovcp_request_get_arg(request, 2); |
| | 712 | cgvalue = (char *)ovcp_data_get(arg2); |
| | 713 | |
| | 714 | if(!ovcp_data_is_string(arg2) || cgvalue == NULL) |
| | 715 | return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC); |
| | 716 | |
| | 717 | |
| 710 | | arg1 = ovcp_request_get_arg(request, 1); |
| 711 | | |
| 712 | | |
| 713 | | if(ovcp_data_is_struct(arg1)) |
| 714 | | { |
| 715 | | while(cgroup_params[i] != NULL) |
| 716 | | { |
| 717 | | struct_element = ovcp_struct_get_element(arg1, cgroup_params[i]); |
| 718 | | |
| 719 | | if(struct_element != NULL) |
| 720 | | { |
| 721 | | if(ovcp_data_is_string(struct_element)) |
| 722 | | { |
| 723 | | value = ovcp_data_get(struct_element); |
| 724 | | sconcat(filepath, BUF_SIZE, global_settings.config_dir, "/", name, "/cgroup/", cgroup_params[i], NULL); |
| 725 | | |
| 726 | | file_write_many(filepath, value, "\n", NULL); |
| 727 | | |
| 728 | | //try to apply the new limits directly |
| 729 | | sconcat(filepath, BUF_SIZE, global_settings.cgroupdir, name, cgroup_params[i], NULL); |
| 730 | | if(file_exist(filepath)) |
| 731 | | { |
| 732 | | file_write_many(filepath, value, "\n", NULL); |
| 733 | | } |
| 734 | | } |
| 735 | | else |
| 736 | | { |
| 737 | | response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, |
| 738 | | "vserver.set_cgroup: "OVCP_ERROR_WRONGTYPE_DESC); |
| 739 | | break; |
| 740 | | } |
| 741 | | } |
| 742 | | |
| 743 | | i++; |
| 744 | | } |
| 745 | | |
| | 723 | response = ovcp_response_new(); |
| | 724 | |
| | 725 | sconcat(filepath, BUF_SIZE, global_settings.config_dir, "/", name, "/cgroup/", cgname, NULL); |
| | 726 | |
| | 727 | if(strcmp(cgvalue, "0") == 0) |
| | 728 | { |
| | 729 | if (file_exist(filepath)) |
| | 730 | { |
| | 731 | unlink(filepath); |
| | 732 | } |
| | 733 | |
| | 734 | //try to apply the new limits directly |
| | 735 | sconcat(filepath, BUF_SIZE, global_settings.cgroupdir, "/", name, "/", cgname, NULL); |
| | 736 | if(file_exist(filepath)) |
| | 737 | { |
| | 738 | unlink(filepath); |
| | 739 | } |
| 749 | | response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, |
| 750 | | "vserver.set_cgroup: "OVCP_ERROR_WRONGTYPE_DESC); |
| 751 | | } |
| 752 | | |
| 753 | | |
| 754 | | if(response == NULL) |
| 755 | | { |
| 756 | | response = ovcp_response_new(); |
| 757 | | ovcp_response_add_boolean(response, TRUE); |
| 758 | | } |
| 759 | | |
| 760 | | |
| | 743 | file_write_many(filepath, cgvalue, "\n", NULL); |
| | 744 | //try to apply the new limits directly |
| | 745 | sconcat(filepath, BUF_SIZE, global_settings.cgroupdir, "/", name, NULL); |
| | 746 | if(dir_exist(filepath)) |
| | 747 | { |
| | 748 | sconcat(filepath, BUF_SIZE, global_settings.cgroupdir, "/", name, "/", cgname, NULL); |
| | 749 | file_write_many(filepath, cgvalue, "\n", NULL); |
| | 750 | } |
| | 751 | } |
| | 752 | |
| | 753 | ovcp_response_add_boolean(response, TRUE); |
| | 754 | |
| | 755 | free(filepath); |