[Commits] r627 - trunk/daemon/src

new-commit at lists.openvcp.org new-commit at lists.openvcp.org
Fri Sep 12 20:41:15 UTC 2008


Author: cryptronic
Date: 2008-09-12 20:41:14 +0000 (Fri, 12 Sep 2008)
New Revision: 627

Modified:
   trunk/daemon/src/set.c
Log:
Added a new scheduler info for idle_time support

Modified: trunk/daemon/src/set.c
===================================================================
--- trunk/daemon/src/set.c	2008-06-08 09:16:40 UTC (rev 626)
+++ trunk/daemon/src/set.c	2008-09-12 20:41:14 UTC (rev 627)
@@ -51,22 +51,22 @@
 	char *filepath, *limitname, *limit, *name, *dir;
 	int i = 0, ret;
 	char rlimit_name[BUF_SIZE];
-	
+
 	struct vc_rlimit current_limit;
-	
+
 	current_limit.hard = 0;
 	current_limit.soft = 0;
 	current_limit.min = 0;
-	
+
 	xid_t xid;
-	
-	struct vlimit_st 
-	{ 
-		unsigned int id; 
+
+	struct vlimit_st
+	{
+		unsigned int id;
 		char *name;
 	};
-	
-	struct vlimit_st rlimit_params[] = 
+
+	struct vlimit_st rlimit_params[] =
 	{
 		{0, "cpu"},{1, "fsize"},{2, "data"}, {3, "stack"},
 		{4, "core"},{5, "rss"},{6, "nproc"},{7, "nofile"},
@@ -75,66 +75,66 @@
 
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-	
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	limitname = (char *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_string(arg1) || limitname == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-	
+
 	arg2 = ovcp_request_get_arg(request, 2);
 	limit = (char *)ovcp_data_get(arg2);
-		
+
 	if(!ovcp_data_is_string(arg2) || limit == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-			
-	
+
+
 	while(rlimit_params[i].name != NULL)
 	{
 		sconcat(rlimit_name, BUF_SIZE, rlimit_params[i].name, ".hard", NULL);
-		
+
 		if(strcmp(rlimit_name, limitname) == 0)
 			break;
 
 		sconcat(rlimit_name, BUF_SIZE, rlimit_params[i].name, ".soft", NULL);
-		
+
 		if(strcmp(rlimit_name, limitname) == 0)
 			break;
 
 		sconcat(rlimit_name, BUF_SIZE, rlimit_params[i].name, ".min", NULL);
-		
+
 		if(strcmp(rlimit_name, limitname) == 0)
 			break;
-			
+
 		i++;
 	}
-	
+
 	if(rlimit_params[i].name == NULL)
 		return ovcp_response_error(OVCP_ERROR_WRONGRLIMIT, "set_rlimit: "OVCP_ERROR_WRONGRLIMIT_DESC);
-	
 
-	
+
+
 	xid = vserver_xid(name);
-	
-		
+
+
 	if((ret = vc_get_rlimit (xid, rlimit_params[i].id, &current_limit)) != -1)
 	{
-		
+
 		if(strcmp(rlimit_name+strlen(rlimit_name)-4, "hard") == 0)
 		{
-			ovcp_log(OVCP_DEBUG, "Current HARD: %X", (unsigned int)current_limit.hard);			
+			ovcp_log(OVCP_DEBUG, "Current HARD: %X", (unsigned int)current_limit.hard);
 			current_limit.hard = atoi(limit);
 		}
 		else
 		if(strcmp(rlimit_name+strlen(rlimit_name)-4, "soft") == 0)
 		{
 			ovcp_log(OVCP_DEBUG, "Current SOFT: %X", (unsigned int)current_limit.soft);
-			current_limit.soft = atoi(limit);					
+			current_limit.soft = atoi(limit);
 		}
 		else
 		if(strcmp(rlimit_name+strlen(rlimit_name)-3, "min") == 0)
@@ -146,17 +146,17 @@
 		vc_set_rlimit (xid, rlimit_params[i].id, &current_limit);
 	}
 
-	
+
 	response = ovcp_response_new();
-	
-	
+
+
 	dir = concat(global_settings.config_dir, "/", name, "/rlimits", NULL);
 	filepath = concat(dir, "/", limitname, NULL);
 
 	if(!dir_exist(dir))
 		mkdir(dir, 0755);
 
-	
+
 	if(strcmp(limit, "0") == 0)
 	{
 		if (file_exist(filepath))
@@ -164,14 +164,14 @@
 	}
 	else
 	{
-		file_write_many(filepath, limit, "\n", NULL); 
+		file_write_many(filepath, limit, "\n", NULL);
 	}
-	
+
 	ovcp_response_add_boolean(response, TRUE);
-	
+
 	free(filepath);
 	free(dir);
-	
+
 	return response;
 }
 
@@ -183,30 +183,30 @@
 	struct ovcp_ipt_rule rule;
 	struct ovcp_data_st *arg0, *arg1, *struct_element;
 	char *name, *value, **ips;
-	
-	
-	char *filter_params[] = {"direction", "proto", "srcip", 
+
+
+	char *filter_params[] = {"direction", "proto", "srcip",
 				"srcport", "destip", "destport",
 				"target", "match", "match-value",
 				NULL};
-	
-	
+
+
 	memset(&rule, 0, sizeof(struct ovcp_ipt_rule));
 	rule.srcport = -1;
 	rule.destport = -1;
-	
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
 
+
 	arg1 = ovcp_request_get_arg(request, 1);
-	
-	
+
+
 	if(ovcp_data_is_struct(arg1))
 	{
 		while(filter_params[i] != NULL)
@@ -218,7 +218,7 @@
 				if(ovcp_data_is_string(struct_element))
 				{
 					value = ovcp_data_get(struct_element);
-					
+
 					if(strcmp("direction", filter_params[i]) == 0)
 					{
 						if(strcmp("INPUT", value) == 0)
@@ -229,7 +229,7 @@
 						{
 							rule.direction = IPT_DIRECTION_OUT;
 						}
-						
+
 					}
 					else
 					if(strcmp("proto", filter_params[i]) == 0)
@@ -245,7 +245,7 @@
 						else
 						{
 							rule.proto = IPT_PROTO_ICMP;
-						}											
+						}
 					}
 					else
 					if(strcmp("srcip", filter_params[i]) == 0)
@@ -254,7 +254,7 @@
 					}
 					else
 					if(strcmp("srcport", filter_params[i]) == 0)
-					{	
+					{
 						rule.srcport = atoi(value);
 					}
 					else
@@ -282,7 +282,7 @@
 					else
 					if(strcmp("match", filter_params[i]) == 0)
 					{
-					
+
 						if(strcmp("LIMIT", value) == 0)
 						{
 							rule.match = IPT_MATCH_LIMIT;
@@ -299,9 +299,9 @@
 					else
 					if(strcmp("match-value", filter_params[i]) == 0)
 					{
-						
+
 						rule.match_value = 0;
-						
+
 						if(rule.match == IPT_MATCH_STATE)
 						{
 							if(strstr(value, "ESTABLISHED"))
@@ -315,7 +315,7 @@
 							if(strstr(value, "RELATED"))
 							{
 								rule.match_value = rule.match_value ^ IPT_STATE_RELATED;
-							}		
+							}
 						}
 						else
 						{
@@ -323,57 +323,57 @@
 						}
 						printf("Match Value: %d", rule.match_value);
 					}
-									
+
 				}
 				else
 				{
-					response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, 
+					response = ovcp_response_error(OVCP_ERROR_WRONGTYPE,
 							"vserver.set_rule: "OVCP_ERROR_WRONGTYPE_DESC);
 					break;
 				}
 			}
-			
+
 			i++;
 		}
-		
+
 	}
 	else
 	{
-		response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, 
+		response = ovcp_response_error(OVCP_ERROR_WRONGTYPE,
 						"vserver.set_rule: "OVCP_ERROR_WRONGTYPE_DESC);
-	}	
+	}
 
 
 	ips = parse_ips(name, &ips_num);
-	
-  
 
+
+
 	i=0;
 	while(i < ips_num)
 	{
 		if(rule.srcip != NULL && strcmp(ips[i], rule.srcip) == 0)
 			break;
 		if(rule.destip != NULL && strcmp(ips[i], rule.destip) == 0)
-			break;		
+			break;
 		i++;
 	}
-	
+
 	free_strings(ips, ips_num);
-	
+
 	if((rule.srcip == NULL && rule.destip == NULL) || i == ips_num)
 	{
-		response = ovcp_response_error(OVCP_ERROR_RULENPERM, 
-						"vserver.set_rule: "OVCP_ERROR_RULENPERM_DESC); 
+		response = ovcp_response_error(OVCP_ERROR_RULENPERM,
+						"vserver.set_rule: "OVCP_ERROR_RULENPERM_DESC);
 	}
 	else
 	{
 		ovcp_iptable_rule(&rule);
 		ovcp_store_rule(name, rule);
 
-		response = ovcp_response_new();	
+		response = ovcp_response_new();
 		ovcp_response_add_boolean(response, TRUE);
 	}
-	
+
 	return response;
 }
 
@@ -384,23 +384,23 @@
 	char *name, *id, *sql_error;
 	char sql_query[BUF_SIZE];
 	int ret;
-	
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	id = (char *)ovcp_data_get(arg1);
-	
+
 	if(!ovcp_data_is_string(arg1) || id == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-	
-	
-	
+
+
+
 	snprintf(sql_query, BUF_SIZE, "DELETE FROM iptable_rules where name='%s' and id=%d", name, atoi(id));
 
 	ret = sqlite3_exec(ovcp_db, sql_query, NULL, 0, &sql_error);
@@ -411,14 +411,14 @@
 		sqlite3_free(sql_error);
 		return NULL;
 	}
-	
+
 	ovcp_create_tables(ovcp_db);
 
-	
+
 	response = ovcp_response_new();
 	ovcp_response_add_boolean(response, TRUE);
-	
-	
+
+
 	return response;
 }
 
@@ -428,35 +428,35 @@
 	struct ovcp_response_st *response;
 	struct ovcp_data_st *arg0, *arg1;
 	char *filepath, *flag, *name;
-	
-	
+
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	flag = (char *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_string(arg1) || flag == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-		
+
 	response = ovcp_response_new();
-		
-		
+
+
 	filepath = concat(global_settings.config_dir, "/", name, "/flags", NULL);
-	
-	file_attach(filepath, flag); 		
+
+	file_attach(filepath, flag);
 	file_attach(filepath, "\n");
 
 	ovcp_response_add_boolean(response, TRUE);
-	
+
 	free(filepath);
-	
-	
+
+
 	return response;
 }
 
@@ -466,44 +466,44 @@
 	struct ovcp_data_st *arg0, *arg1;
 	char *filepath, *flagfile, *flag, *p, *name;
 	int flagfile_fd;
-	
-	
+
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	flag = (char *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_string(arg1) || flag == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-		
 
 
+
 	filepath = concat(global_settings.config_dir, "/", name, "/flags", NULL);
 	flagfile = file_read(filepath);
-	
+
 	flagfile_fd = open(filepath, O_CREAT | O_TRUNC | O_WRONLY);
 
 	if(flagfile_fd != -1 && flagfile != NULL)
-	{	
+	{
 		p = strstr(flagfile, flag);
 		if(p != NULL)
 		{
 			write(flagfile_fd, flagfile, p-flagfile);
 			write(flagfile_fd, p+strlen(flag)+1, strlen(p+strlen(flag)+1));
-			
-			response = ovcp_response_new();	
+
+			response = ovcp_response_new();
 			ovcp_response_add_boolean(response, TRUE);
-		
+
 		}
 		else
 		{
-			response = ovcp_response_error(OVCP_ERROR_FLAGNFOUND, 
+			response = ovcp_response_error(OVCP_ERROR_FLAGNFOUND,
 							"vserver.remove_flag: "OVCP_ERROR_FLAGNFOUND_DESC);
 			write(flagfile_fd, flagfile, strlen(flagfile));
 		}
@@ -511,17 +511,17 @@
 	}
 	else
 	{
-		response = ovcp_response_error(OVCP_ERROR_FILEMISSING, 
+		response = ovcp_response_error(OVCP_ERROR_FILEMISSING,
 						"vserver.remove_flag: "OVCP_ERROR_FILEMISSING_DESC);
 	}
 
-	
+
 	if(flagfile != NULL) free(flagfile);
 	free(filepath);
-	
-	
-	
-	return response; 
+
+
+
+	return response;
 }
 
 
@@ -531,10 +531,10 @@
 	struct ovcp_data_st *arg0, *arg1;
 	char path[BUF_SIZE], *name;
 	int *value;
-	
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
@@ -542,7 +542,7 @@
 
 	arg1 = ovcp_request_get_arg(request, 1);
 	value = (int *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_boolean(arg1))
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 
@@ -562,8 +562,8 @@
 	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name,"/apps/init/mark", NULL);
 
 
-	response = ovcp_response_new();	
-	
+	response = ovcp_response_new();
+
 	if(*value == 1)
 	{
 
@@ -573,16 +573,16 @@
 			ovcp_response_add_boolean(response, FALSE);
 	}
 	else
-	{	
+	{
 
 		if(unlink(path) != -1)
 			ovcp_response_add_boolean(response, TRUE);
 		else
-			ovcp_response_add_boolean(response, FALSE);	
-	}	
+			ovcp_response_add_boolean(response, FALSE);
+	}
 
 
-	
+
 	return response;
 }
 
@@ -593,17 +593,17 @@
 	struct ovcp_data_st *arg0, *arg1, *struct_element;
 	char filepath[BUF_SIZE], *value, *name;
 	int i = 0;
-	
+
 	char *sched_params[] = {"fill-rate", "fill-rate2",
 				"interval", "interval2",
 				"priority-bias", "tokens",
 				"tokens-max", "tokens-min",
-				NULL};
+				"idle-time", NULL};
 
 
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
@@ -612,11 +612,11 @@
 	sconcat(filepath, BUF_SIZE, global_settings.config_dir, "/", name, "/sched/", NULL);
 	if(!dir_exist(filepath))
 		mkdir(filepath, 0755);
-		
 
+
 	arg1 = ovcp_request_get_arg(request, 1);
 
-	
+
 	if(ovcp_data_is_struct(arg1))
 	{
 		while(sched_params[i] != NULL)
@@ -629,36 +629,36 @@
 				{
 					value = ovcp_data_get(struct_element);
 					sconcat(filepath, BUF_SIZE, global_settings.config_dir, "/", name, "/sched/", sched_params[i], NULL);
-				
+
 					file_write_many(filepath, value, "\n", NULL);
 				}
 				else
 				{
-					response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, 
+					response = ovcp_response_error(OVCP_ERROR_WRONGTYPE,
 							"vserver.set_schedule: "OVCP_ERROR_WRONGTYPE_DESC);
 					break;
 				}
 			}
-			
+
 			i++;
 		}
-		
+
 	}
 	else
 	{
-		response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, 
+		response = ovcp_response_error(OVCP_ERROR_WRONGTYPE,
 						"vserver.set_schedule: "OVCP_ERROR_WRONGTYPE_DESC);
 	}
-	
-	
+
+
 	if(response == NULL)
 	{
-		response = ovcp_response_new();	
+		response = ovcp_response_new();
 		ovcp_response_add_boolean(response, TRUE);
-	}	
+	}
 
 
-	
+
 	return response;
 }
 
@@ -670,52 +670,52 @@
 	struct ovcp_data_st *arg0, *arg1, *struct_element, *struct_member;
 	char path[BUF_SIZE], *name, *value;
 	int i = 0, iface_id = 0;
-	
+
 	char *iface_params[] = { "bcast", "dev", "disabled", "ip",
 				 "mask", "name", "nodev", "novlandev",
 				 "prefix", "scope", "vlandev", NULL };
-	
-	
-	
+
+
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
-		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);		
+		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
 
 	arg1 = ovcp_request_get_arg(request, 1);
 
-	
+
 	if(ovcp_data_is_struct(arg1))
 	{
-	
+
 		snprintf(path, BUF_SIZE, "%s/%s/interfaces/%d", global_settings.config_dir, name, i);
-			
+
 	   	while(dir_exist(path))
 		{
 	      		i++;
 			snprintf(path, BUF_SIZE, "%s/%s/interfaces/%d", global_settings.config_dir, name, i);
 		}
-		
+
 		iface_id = i;
 
 		if(mkdir(path, 0755) != 0)
-			return ovcp_response_error(OVCP_ERROR_DIRNCREATED, 
+			return ovcp_response_error(OVCP_ERROR_DIRNCREATED,
 						"vserver.add_ip: "OVCP_ERROR_DIRNCREATED_DESC);
-		
+
 		i = 0;
-		
+
 		while(iface_params[i] != NULL)
 		{
 			struct_member = ovcp_struct_get_member(arg1, iface_params[i]);
-			
+
 			if(struct_member != NULL)
 			{
-				
+
 				struct_element = ovcp_member_get(struct_member);
-				
+
 				snprintf(path, BUF_SIZE, "%s/%s/interfaces/%d/%s", global_settings.config_dir, name, iface_id, iface_params[i]);
 
 				if(ovcp_data_is_string(struct_element))
@@ -727,27 +727,27 @@
 				{
 					file_touch(path);
 				}
-				
+
 			}
-			
+
 			i++;
 		}
 	}
 	else
 	{
-		response = ovcp_response_error(OVCP_ERROR_WRONGTYPE, 
+		response = ovcp_response_error(OVCP_ERROR_WRONGTYPE,
 						"vserver.add_ip: "OVCP_ERROR_WRONGTYPE_DESC);
 	}
-	
-	
+
+
 	if(response == NULL)
 	{
-		response = ovcp_response_new();	
+		response = ovcp_response_new();
 		ovcp_response_add_int(response, iface_id);
-	}	
+	}
 
 
-	
+
 	return response;
 }
 
@@ -758,41 +758,41 @@
 	struct ovcp_response_st *response = NULL;
 	struct ovcp_data_st *arg0, *arg1;
 	char path[BUF_SIZE], *name, *iface_id;
-	
-	
 
+
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	iface_id = (char *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_string(arg1) || iface_id == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-		
-	
+
+
 	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/interfaces/", iface_id, NULL);
 
 	if(dir_exist(path))
 	{
 		dir_remove(path);
-		response = ovcp_response_new();	
-		ovcp_response_add_boolean(response, TRUE);		
+		response = ovcp_response_new();
+		ovcp_response_add_boolean(response, TRUE);
 	}
 	else
 	{
-		response = ovcp_response_error(OVCP_ERROR_IFACENEXIST, 
+		response = ovcp_response_error(OVCP_ERROR_IFACENEXIST,
 						"vserver.remove_ip: "OVCP_ERROR_IFACENEXIST_DESC);
 	}
-	
+
 	return response;
-   
-   
+
+
 }
 
 
@@ -804,102 +804,102 @@
 	char *directory, *space_total, *inodes_total, *reserved;
 	char *pathoflimit, *limit_id = NULL;
 	int i;
-	
+
 	DIR *dlimitdir;
 	struct dirent *dlimitentry;
 
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
 
+
 	arg1 = ovcp_request_get_arg(request, 1);
 
 	if(!ovcp_data_is_struct(arg1))
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-		
 
+
 	struct_element = ovcp_struct_get_element(arg1, "directory");
 
 	if(struct_element != NULL && ovcp_data_is_string(struct_element))
 		directory = (char *)ovcp_data_get(struct_element);
-	else 
+	else
 		return ovcp_response_error(OVCP_ERROR_ARGMISS,
-				"vserver.set_space: "OVCP_ERROR_ARGMISS_DESC);	
-	
+				"vserver.set_space: "OVCP_ERROR_ARGMISS_DESC);
+
 	if(directory[0] != '/')
 		return ovcp_response_error(OVCP_ERROR_DIRNOSLASH,
 				"vserver.set_space: "OVCP_ERROR_DIRNOSLASH_DESC);
-		
+
 	struct_element = ovcp_struct_get_element(arg1, "space_total");
 
 	if(struct_element != NULL && ovcp_data_is_string(struct_element))
 		space_total = (char *)ovcp_data_get(struct_element);
-	else 
+	else
 		return ovcp_response_error(OVCP_ERROR_ARGMISS,
 				"vserver.set_space: "OVCP_ERROR_ARGMISS_DESC);
-		
-		
+
+
 	struct_element = ovcp_struct_get_element(arg1, "inodes_total");
 
 	if(struct_element != NULL && ovcp_data_is_string(struct_element))
 		inodes_total = (char *)ovcp_data_get(struct_element);
-	else 
+	else
 		return ovcp_response_error(OVCP_ERROR_ARGMISS,
 				"vserver.set_space: "OVCP_ERROR_ARGMISS_DESC);
-		
-		
-		
+
+
+
 	struct_element = ovcp_struct_get_element(arg1, "reserved");
 
 	if(struct_element != NULL && ovcp_data_is_string(struct_element))
 		reserved = (char *)ovcp_data_get(struct_element);
-	else 
+	else
 	return ovcp_response_error(OVCP_ERROR_ARGMISS,
 					"vserver.set_space: "OVCP_ERROR_ARGMISS_DESC);
-	
-	
 
+
+
 	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/dlimits", NULL);
 
 	if(!dir_exist(path))
 		mkdir(path, 0755);
 
-	
+
 	directory = concat(global_settings.root_dir, "/", name, directory, NULL);
 	trim_slashes(directory);
 
 	dlimitdir = opendir(path);
-	
+
 	while((dlimitentry = readdir(dlimitdir)) != NULL)
 	{
 		if(dlimitentry->d_name[0] == '.')
 			continue;
-			
-		sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/dlimits/", dlimitentry->d_name, "/directory", NULL);		
+
+		sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/dlimits/", dlimitentry->d_name, "/directory", NULL);
 		pathoflimit = file_read(path);
-		
+
 		if(pathoflimit == NULL)
 			continue;
-		
+
 		trim_string(pathoflimit);
 		trim_slashes(pathoflimit);
-		
 
+
 		if(strcmp(pathoflimit, directory) == 0)
 		{
 			free(pathoflimit);
 			limit_id = strdup(dlimitentry->d_name);
 			break;
 		}
-		
+
 		free(pathoflimit);
 	}
-	
+
 	if(limit_id == NULL)
 	{
 		i = 0;
@@ -916,7 +916,7 @@
 	closedir(dlimitdir);
 
 
-	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/dlimits/", limit_id, NULL);		
+	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/dlimits/", limit_id, NULL);
 
 	if(!dir_exist(path))
 	{
@@ -924,17 +924,17 @@
 	}
 	else
 	{
-	
+
 		if(atoi(space_total) == 0)
 		{
 			dir_remove(path);
-			
-			response = ovcp_response_new();	
-			ovcp_response_add_boolean(response, TRUE);	
-							
-			free(directory);	
+
+			response = ovcp_response_new();
+			ovcp_response_add_boolean(response, TRUE);
+
+			free(directory);
 			free(limit_id);
-	
+
 			return response;
 		}
 	}
@@ -950,15 +950,15 @@
 
 	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/dlimits/", limit_id, "/reserved", NULL);
 	file_write_many(path, reserved, "\n", NULL);
-	
 
 
-	response = ovcp_response_new();	
+
+	response = ovcp_response_new();
 	ovcp_response_add_boolean(response, TRUE);
-						
-	free(directory);	
+
+	free(directory);
 	free(limit_id);
-	
+
 	return response;
 }
 
@@ -969,22 +969,22 @@
 	char *name, *pw;
 	char cmd[BUF_SIZE];
 	FILE *cmdp;
-	
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	pw = (char *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_string(arg1) || pw == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-		
-	
+
+
 	snprintf(cmd, BUF_SIZE, "vserver %s exec chpasswd", name);
 
 	cmdp = popen(cmd, "w");
@@ -992,9 +992,9 @@
 	if(cmdp != NULL)
 	{
 		fprintf(cmdp, "root:%s\n", pw);
-		pclose(cmdp);	
-	
-		response = ovcp_response_new();	
+		pclose(cmdp);
+
+		response = ovcp_response_new();
 		ovcp_response_add_boolean(response, TRUE);
 	}
 	else
@@ -1005,7 +1005,7 @@
 
 
 
-	return response; 
+	return response;
 }
 
 
@@ -1019,23 +1019,23 @@
 	int i = 0, len;
 
 
-	
+
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
-		
+
 	if(!ovcp_data_is_string(arg0) || name == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
 	if(!vserver_exist(name))
 		return ovcp_response_error(OVCP_ERROR_VSNOTEXIST, OVCP_ERROR_VSNOTEXIST_DESC);
-		
+
 	arg1 = ovcp_request_get_arg(request, 1);
 	hostname = (char *)ovcp_data_get(arg1);
-		
+
 	if(!ovcp_data_is_string(arg1) || hostname == NULL)
 		return ovcp_response_error(OVCP_ERROR_ARGMISS, OVCP_ERROR_ARGMISS_DESC);
-	
+
 	arg2 = ovcp_request_get_arg(request, 2);
-	
+
 	if(ovcp_data_is_string(arg2))
 	{
 		ip = (char *)ovcp_data_get(arg2);
@@ -1045,7 +1045,7 @@
 		sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/interfaces/0/ip", NULL);
 		ip = file_read(path);
 	}
-	
+
 	len = strlen(hostname);
 
 	while(hostname[i] != '.' && i < len && i < BUF_SIZE)
@@ -1083,7 +1083,7 @@
 	file_write(path, hostname); file_attach(path, "\n");
 
 
-	response = ovcp_response_new();	
+	response = ovcp_response_new();
 	ovcp_response_add_boolean(response, TRUE);
 
 



More information about the Commits mailing list