示例#1
0
static void UnmountPartitions(int device) {
	char mount[11];
	int i;
	for (i = 0; i < MAX_DEVICES; i++) {
		switch (part[device][i].type) {
			case T_FAT:
				part[device][i].type = 0;
				sprintf(mount, "%s:", part[device][i].mount);
				fatUnmount(mount);
				break;
			case T_NTFS:
				part[device][i].type = 0;
				ntfsUnmount(part[device][i].mount, false);
				break;
			case T_EXT2:
				part[device][i].type = 0;
				ext2Unmount(part[device][i].mount);
				break;

			case T_ISO9660:
				part[device][i].type = 0;
				sprintf(mount, "%s:", part[device][i].mount);
				ISO9660_Unmount(mount);
				break;
		}
		part[device][i].name[0] = 0;
		part[device][i].mount[0] = 0;
		part[device][i].sector = 0;
		part[device][i].interface = NULL;
	}
}
void PartitionHandle::UnMount(int pos)
{
	if(!interface)
		return;

	if(pos >= (int) MountNameList.size())
		return;

	if(MountNameList[pos].size() == 0)
		return;

	char DeviceName[20];
	snprintf(DeviceName, sizeof(DeviceName), "%s:", MountNameList[pos].c_str());

	//closing all open Files write back the cache
	fatUnmount(DeviceName);
	//closing all open Files write back the cache
	ntfsUnmount(DeviceName, true);
	//closing all open Files write back the cache
	ext2Unmount(DeviceName);
	//Remove name from list
	MountNameList[pos].clear();
}
void PartitionHandle::UnMount(int pos)
{
	if(!interface || (pos >= (int)MountNameList.size()) || (MountNameList[pos].size() == 0))
		return;

	WBFS_Close();
	char DeviceSyn[10];
	memcpy(DeviceSyn, MountName(pos), 8);
	strcat(DeviceSyn, ":");
	DeviceSyn[9] = '\0';

	if(strncmp(GetFSName(pos), "WBFS", 4) == 0)
	{
		wbfs_t *wbfshandle = GetWbfsHandle(pos);
		if(wbfshandle) wbfs_close(wbfshandle);
		gprintf("WBFS Partition at %s unmounted.\n", DeviceSyn);
	}
	else if(strncmp(GetFSName(pos), "FAT", 3) == 0)
	{
		fatUnmount(DeviceSyn);
		gprintf("FAT Partition at %s unmounted.\n", DeviceSyn);
	}
	else if(strncmp(GetFSName(pos), "NTFS", 4) == 0)
	{
		ntfsUnmount(DeviceSyn, true);
		gprintf("NTFS Partition at %s unmounted.\n", DeviceSyn);
	}
	else if(strncmp(GetFSName(pos), "LINUX", 5) == 0)
	{
		ext2Unmount(DeviceSyn);
		gprintf("EXT Partition at %s unmounted.\n", DeviceSyn);
	}
	/* Remove name from list */
	MountNameList[pos].clear();
	SetWbfsHandle(pos, NULL);
}