示例#1
0
int SDCard_Init() {
#ifdef DEBUG_FAT
    gprintf("\nSDCard_Init()");
#endif
    //closing all open Files write back the cache and then shutdown em!
    fatUnmount("SD:/");
    //right now mounts first FAT-partition
	if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS)) {
		fat_sd_mount = MOUNT_SD;
		fat_sd_sec = _FAT_startSector;
#ifdef DEBUG_FAT
		gprintf(":1");
#endif
		return 1;
	}
	else if (fatMount("SD", &__io_sdhc, 0, CACHE, SDHC_SECTOR_SIZE)) {
		fat_sd_mount = MOUNT_SDHC;
		fat_sd_sec = _FAT_startSector;
#ifdef DEBUG_FAT
		gprintf(":1");
#endif
		return 1;
	}
#ifdef DEBUG_FAT
	gprintf(":-1");
#endif
	return -1;
}
示例#2
0
bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) {
	int i;
	int defaultDevice = -1;
	const DISC_INTERFACE *disc;

	for (i = 0; 
		_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL; 
		i++)
	{
		disc = _FAT_disc_interfaces[i].getInterface();
		if (disc->startup() && fatMount (_FAT_disc_interfaces[i].name, disc, 0, cacheSize)) {
			// The first device to successfully mount is set as the default
			if (defaultDevice < 0) {
				defaultDevice = i;
			}
		}
	}
	
	if (defaultDevice < 0) {
		// None of our devices mounted
		return false;
	}

	return true;
}
示例#3
0
int USBDevice_Init() {
#ifdef DEBUG_FAT
    gprintf("\nUSBDevice_Init()");
#endif
	//closing all open Files write back the cache and then shutdown em!
    fatUnmount("USB:/");
    //right now mounts first FAT-partition

	//try first mount with cIOS
//    if (!fatMount("USB", &__io_wiiums, 0, CACHE, SECTORS)) {
//		//try now mount with libogc
		if (!fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS)) {
#ifdef DEBUG_FAT
		    gprintf(":-1");
#endif
		    return -1;
		}
//	}

	fat_usb_mount = 1;
	fat_usb_sec = _FAT_startSector;
#ifdef DEBUG_FAT
	gprintf(":0");
#endif
	return 0;
}
示例#4
0
bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) {
	int i;
	int defaultDevice = -1;
	const DISC_INTERFACE *disc;

	for (i = 0;
		_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL;
		i++)
	{
		disc = _FAT_disc_interfaces[i].getInterface();
		if (fatMount (_FAT_disc_interfaces[i].name, disc, 0, cacheSize, DEFAULT_SECTORS_PAGE)) {
			// The first device to successfully mount is set as the default
			if (defaultDevice < 0) {
				defaultDevice = i;
			}
		}
	}

	if (defaultDevice < 0) {
		// None of our devices mounted
		return false;
	}

	if (setAsDefaultDevice) {
		char filePath[MAXPATHLEN * 2];
		strcpy (filePath, _FAT_disc_interfaces[defaultDevice].name);
		strcat (filePath, ":/");
#ifdef ARGV_MAGIC
		if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 && strrchr( __system_argv->argv[0], '/' )!=NULL ) {
			// Check the app's path against each of our mounted devices, to see
			// if we can support it. If so, change to that path.
			for (i = 0;
				_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL;
				i++)
			{
				if ( !strncasecmp( __system_argv->argv[0], _FAT_disc_interfaces[i].name,
					strlen(_FAT_disc_interfaces[i].name)))
				{
					char *lastSlash;
					strcpy(filePath, __system_argv->argv[0]);
					lastSlash = strrchr( filePath, '/' );

					if ( NULL != lastSlash) {
						if ( *(lastSlash - 1) == ':') lastSlash++;
						*lastSlash = 0;
					}
				}
			}
		}
#endif
		chdir (filePath);
	}

	return true;
}
bool PartitionHandle::Mount(int pos, const char * name)
{
	if(!valid(pos))
		return false;

	if(!name)
		return false;

	UnMount(pos);

	if(pos >= (int) MountNameList.size())
		MountNameList.resize(GetPartitionCount());

	MountNameList[pos] = name;

	if(strncmp(GetFSName(pos), "FAT", 3) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
	{
		if (fatMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS))
		{
			if(strcmp(GetFSName(pos), "GUID-Entry") == 0)
				PartitionList[pos].FSName = "FAT";
			return true;
		}
	}

	if(strncmp(GetFSName(pos), "NTFS", 4) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
	{
		if(ntfsMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER))
		{
			PartitionList[pos].FSName = "NTFS";
			return true;
		}
	}

	if(strncmp(GetFSName(pos), "LINUX", 5) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
	{
		if(ext2Mount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, EXT2_FLAG_DEFAULT))
		{
			PartitionList[pos].FSName = "LINUX";
			return true;
		}
	}
	MountNameList[pos].clear();

	return false;
}
示例#6
0
int WBFSDevice_Init(u32 sector) {
    //closing all open Files write back the cache and then shutdown em!
    fatUnmount("WBFS:/");
    //right now mounts first FAT-partition

	//try first mount with cIOS
//    if (!fatMount("WBFS", &__io_wiiums, 0, CACHE, SECTORS)) {
		//try now mount with libogc
		if (!fatMount("WBFS", &__io_usbstorage2, 0, CACHE, SECTORS)) {
			return -1;
		}
//	}

	fat_wbfs_mount = 1;
	fat_wbfs_sec = _FAT_startSector;
	if (sector && fat_wbfs_sec != sector) {
		// This is an error situation...actually, but is ignored in Config loader also
		// Should ask Oggzee about it...
	}
	return 0;
}
示例#7
0
int setDevice (fatdev device)
{
        unmountDevice();

        if (!(device.io->isInserted()))
        {
                return 0;
        }
        
        if (matchStr(device.root, "dvd"))
        {
                DI_Mount();
                if (!(ISO9660_Mount()))
                {
                        setError(1);
                        return 0;
                }
        }
        else
        {                       
                if (!fatMount(device.root, device.io, 0, 8, 512))
                {
                        setError(2);
                        return 0;
                }
        }
        
        inuse = &device;

        memset(&bPath, 0, sizeof(bPath));
        sprintf(bPath, "%s:/", inuse->root);
        
        getFiles();
        
        return 1;
}
示例#8
0
void Sys_PlatformInit( void )
{
	// Init libxenon
	xenos_init(VIDEO_MODE_AUTO);

	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);
	
	
	http_output_start();
		
#if 0
	threading_init();
	network_init_sys();
#endif	
	
	usb_init();
	usb_do_poll();

	xenon_ata_init();
	xenon_atapi_init();

	// fatInitDefault();
	// XTAFMount();	
	
	// fatInit(16, 1);
	
	fatMount ("uda", &usb2mass_ops_0, 0, 256, 64);
	
	ListDevices();
	
	Sys_SetEnv("HOME", "uda:/");
	
	console_close();
}
示例#9
0
static void AddPartition(sec_t sector, int device, int type, int *devnum) {
	int i;

	if (*devnum >= MAX_DEVICES)
		return;

	for (i = 0; i < *devnum; i++)
		if (part[device][i].sector == sector) return; // to avoid mount same partition again

	DISC_INTERFACE *disc = (DISC_INTERFACE *) & xenon_ata_ops;

	if (device == DEVICE_USB)
		disc = (DISC_INTERFACE *) & usb2mass_ops;
	
	else if(device == DEVICE_ATAPI)
		disc = (DISC_INTERFACE *) & xenon_atapi_ops;

	char mount[10];
	sprintf(mount, "%s%i", prefix[device], *devnum);
	char *name;

	switch (type) {
		case T_FAT:
			if (!fatMount(mount, disc, sector, 2, 64))
				return;
			fatGetVolumeLabel(mount, part[device][*devnum].name);
			break;
		case T_NTFS:
			if (!ntfsMount(mount, disc, sector, 2, 64, NTFS_DEFAULT | NTFS_RECOVER))
				return;

			name = (char *) ntfsGetVolumeName(mount);

			if (name && name[0])
				strcpy(part[device][*devnum].name, name);
			else
				part[device][*devnum].name[0] = 0;
			break;
		case T_EXT2:
			if (!ext2Mount(mount, disc, sector, 2, 128, EXT2_FLAG_DEFAULT))
				return;

			name = (char *) ext2GetVolumeName(mount);

			if (name && name[0])
				strcpy(part[device][*devnum].name, name);
			else
				part[device][*devnum].name[0] = 0;
			break;
		case T_ISO9660:
			if (!ISO9660_Mount(mount, disc))
				return;

			name = (char *) ISO9660_GetVolumeLabel(mount);

			if (name && name[0])
				strcpy(part[device][*devnum].name, name);
			else
				strcpy(part[device][*devnum].name, "DVD");
			break;
	}

	int c = strlen(part[device][*devnum].name) - 1;

	while (c >= 0 && part[device][*devnum].name[c] == ' ')
		part[device][*devnum].name[c--] = 0;

	strcpy(part[device][*devnum].mount, mount);
	part[device][*devnum].interface = disc;
	part[device][*devnum].sector = sector;
	part[device][*devnum].type = type;
	++*devnum;
}
示例#10
0
bool fatMountSimple (const char* name, const DISC_INTERFACE* interface) {
	return fatMount (name, interface, 0, DEFAULT_CACHE_PAGES, DEFAULT_SECTORS_PAGE);
}
bool PartitionHandle::Mount(int pos, const char *name, bool forceFAT)
{
	if(valid(pos))
		UnMount(pos);

	if(!name)
		return false;

	if(pos >= (int)MountNameList.size())
		MountNameList.resize(pos + 1);

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

	//! Some stupid partition manager think they don't need to edit the freaken MBR.
	//! So we need to check the first 64 sectors and see if some partition is there.
	//! libfat does that by default so let's use it.
	if(forceFAT && (strlen(GetFSName(pos)) == 0 || strcmp(GetFSName(pos), "Unknown") == 0))
	{
		if(fatMount(MountNameList[pos].c_str(), interface, 0, CACHE, SECTORS))
		{
			sec_t FAT_startSector = FindFirstValidPartition(interface);
			AddPartition("FAT", FAT_startSector, 0xdeadbeaf, true, 0x0c, 0);
			gprintf("FAT Partition at %s (forceFAT) mounted.\n", DeviceSyn);
			SetWbfsHandle(pos, NULL);
			return true;
		}
	}
	if(!valid(pos))
		return false;

	SetWbfsHandle(pos, NULL);
	if(strncmp(GetFSName(pos), "FAT", 3) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
	{
		if(fatMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS))
		{
			gprintf("FAT Partition at %s mounted.\n", DeviceSyn);
			PartitionList[pos].FSName = "FAT";
			return true;
		}
	}
	else if(strncmp(GetFSName(pos), "NTFS", 4) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
	{
		if(ntfsMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER))
		{
			gprintf("NTFS Partition at %s mounted.\n", DeviceSyn);
			PartitionList[pos].FSName = "NTFS";
			return true;
		}
	}
	else if(strncmp(GetFSName(pos), "LINUX", 5) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
	{
		if(ext2Mount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, EXT2_FLAG_DEFAULT))
		{
			gprintf("EXT Partition at %s mounted.\n", DeviceSyn);
			PartitionList[pos].FSName = "LINUX";
			return true;
		}
	}
	else if(strncmp(GetFSName(pos), "WBFS", 4) == 0)
	{
		if(interface == &__io_usbstorage2_port0 || interface == &__io_usbstorage2_port1)
			SetWbfsHandle(pos, wbfs_open_partition(__WBFS_ReadUSB, __WBFS_WriteUSB, NULL, USBStorage2_GetSectorSize(), GetSecCount(pos), GetLBAStart(pos), 0));
		else if(interface == &__io_sdhc)
			SetWbfsHandle(pos, wbfs_open_partition(__WBFS_ReadSDHC, __WBFS_WriteSDHC, NULL, 512, GetSecCount(pos), GetLBAStart(pos), 0));
		if(GetWbfsHandle(pos))
		{
			gprintf("WBFS Partition at %s mounted.\n", DeviceSyn);
			PartitionList[pos].FSName = "WBFS";
			return true;
		}
	}
	/* FAIL */
	MountNameList[pos].clear();
	return false;
}