add: user_debug_team_created(team->id);
context: fork_team(void){	struct team *parentTeam = thread_get_current_thread()->team, *team;	struct thread *parentThread = thread_get_current_thread();	struct process_group *group = NULL;	struct fork_arg *forkArgs;	struct area_info info;	thread_id threadID;	cpu_status state;	status_t status;	int32 cookie;	TRACE(("fork_team()\n"));	if (parentTeam == team_get_kernel_team())		return B_NOT_ALLOWED;	// create a new team	// ToDo: this is very similar to team_create_team() - maybe we can do something about it :)	team = create_team_struct(parentTeam->name, false);	if (team == NULL)		return B_NO_MEMORY;	state = disable_interrupts();	GRAB_TEAM_LOCK();	hash_insert(team_hash, team);	insert_team_into_parent(parentTeam, team);	insert_team_into_group(parentTeam->group, team);	sUsedTeams++;	RELEASE_TEAM_LOCK();	restore_interrupts(state);	forkArgs = (struct fork_arg *)malloc(sizeof(struct fork_arg));	if (forkArgs == NULL) {		status = B_NO_MEMORY;		goto err1;	}	// create a new io_context for this team	team->io_context = vfs_new_io_context(parentTeam->io_context);	if (!team->io_context) {		status = B_NO_MEMORY;		goto err2;	}	// create an address space for this team	status = vm_create_aspace(team->name, team->id, USER_BASE, USER_SIZE, false, &team->aspace);	if (status < B_OK)		goto err3;	// copy all areas of the team	// ToDo: should be able to handle stack areas differently (ie. don't have them copy-on-write)	// ToDo: all stacks of other threads than the current one could be left out	cookie = 0;	while (get_next_area_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {		void *address;		area_id area = vm_copy_area(team->aspace->id, info.name, &address, B_CLONE_ADDRESS,							info.protection, info.area);		if (area < B_OK) {			status = area;			break;		}		if (info.area == parentThread->user_stack_area)			forkArgs->user_stack_area = area;	}	if (status < B_OK)		goto err4;	forkArgs->user_stack_base = parentThread->user_stack_base;	forkArgs->user_stack_size = parentThread->user_stack_size;	forkArgs->user_local_storage = parentThread->user_local_storage;	arch_store_fork_frame(&forkArgs->arch_info);	team->user_env_base = parentTeam->user_env_base;	// ToDo: copy image list	// create a kernel thread under the context of the new team	threadID = spawn_kernel_thread_etc(fork_team_thread_start, parentThread->name,					parentThread->priority, forkArgs, team->id);	if (threadID < 0) {		status = threadID;		goto err4;	}	resume_thread(threadID);	return threadID;err4:	vm_delete_aspace(team->aspace);err3:	vfs_free_io_context(team->io_context);err2:	free(forkArgs);err1:	// remove the team structure from the team hash table and delete the team structure	state = disable_interrupts();	GRAB_TEAM_LOCK();	remove_team_from_group(team, &group);	remove_team_from_parent(parentTeam, team);	hash_remove(team_hash, team);	RELEASE_TEAM_LOCK();	restore_interrupts(state);	team_delete_process_group(group);	delete_team_struct(team);	return status;}