mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-22 18:09:17 +01:00
remove unused code, r18 args fix
This commit is contained in:
parent
af94077a7a
commit
e89b232b5f
@ -108,35 +108,6 @@ static u32 accessTime(){
|
|||||||
return accessCounter;
|
return accessCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FlushAndInvalidateCachePage(CACHE* cache,unsigned int page) {
|
|
||||||
if(cache->cacheEntries[page].dirty == true) {
|
|
||||||
// Write the page back to disc
|
|
||||||
_FAT_disc_writeSectors (cache->disc, cache->cacheEntries[page].sector, cache->cacheEntries[page].count, cache->cacheEntries[page].cache);
|
|
||||||
}
|
|
||||||
//Invalidate
|
|
||||||
cache->cacheEntries[page].sector = CACHE_FREE;
|
|
||||||
cache->cacheEntries[page].last_access = 0;
|
|
||||||
cache->cacheEntries[page].count = 0;
|
|
||||||
cache->cacheEntries[page].dirty = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InvalidateCachePagesSharingSectors(CACHE* cache, sec_t sector, sec_t numSectors, unsigned int valid_page) {
|
|
||||||
return;
|
|
||||||
unsigned int i;
|
|
||||||
if(cache==NULL)return;
|
|
||||||
CACHE_ENTRY* cacheEntries = cache->cacheEntries;
|
|
||||||
unsigned int numberOfPages = cache->numberOfPages;
|
|
||||||
|
|
||||||
for (i = 0; i < numberOfPages ; i++) {
|
|
||||||
if(i==valid_page) continue;
|
|
||||||
if ( ( cacheEntries[i].sector > sector+numSectors ) ||
|
|
||||||
( cacheEntries[i].sector+cacheEntries[i].count < sector ) ) continue;
|
|
||||||
|
|
||||||
FlushAndInvalidateCachePage(cache,i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Retrieve a sector's page from the cache. If it is not found in the cache,
|
Retrieve a sector's page from the cache. If it is not found in the cache,
|
||||||
load it into the cache and return the page it was loaded to.
|
load it into the cache and return the page it was loaded to.
|
||||||
@ -173,7 +144,7 @@ static unsigned int _FAT_cache_getSector (CACHE* cache, sec_t sector, void* buff
|
|||||||
}
|
}
|
||||||
cacheEntries[oldUsed].dirty = false;
|
cacheEntries[oldUsed].dirty = false;
|
||||||
}
|
}
|
||||||
InvalidateCachePagesSharingSectors(cache,sector,sectorsPerPage,oldUsed);
|
|
||||||
// Load the new sector into the cache
|
// Load the new sector into the cache
|
||||||
if (!_FAT_disc_readSectors (cache->disc, sector, sectorsPerPage, cacheEntries[oldUsed].cache)) {
|
if (!_FAT_disc_readSectors (cache->disc, sector, sectorsPerPage, cacheEntries[oldUsed].cache)) {
|
||||||
return false;
|
return false;
|
||||||
@ -234,7 +205,7 @@ bool _FAT_cache_getSectors (CACHE* cache, sec_t sector, sec_t numSectors, void*
|
|||||||
|
|
||||||
cacheEntries[oldUsed].sector = sector;
|
cacheEntries[oldUsed].sector = sector;
|
||||||
cacheEntries[oldUsed].count = cache->sectorsPerPage;
|
cacheEntries[oldUsed].count = cache->sectorsPerPage;
|
||||||
InvalidateCachePagesSharingSectors(cache,cacheEntries[oldUsed].sector,cacheEntries[oldUsed].count,oldUsed);
|
|
||||||
if (!_FAT_disc_readSectors (cache->disc, sector, cacheEntries[oldUsed].count, cacheEntries[oldUsed].cache)) {
|
if (!_FAT_disc_readSectors (cache->disc, sector, cacheEntries[oldUsed].count, cacheEntries[oldUsed].cache)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
libfat.c
|
libfat.c
|
||||||
Simple functionality for startup, mounting and unmounting of FAT-based devices.
|
Simple functionality for startup, mounting and unmounting of FAT-based devices.
|
||||||
|
|
||||||
Copyright (c) 2006 Michael "Chishm" Chisholm
|
Copyright (c) 2006 Michael "Chishm" Chisholm
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
are permitted provided that the following conditions are met:
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
|
|||||||
PARTITION* partition;
|
PARTITION* partition;
|
||||||
devoptab_t* devops;
|
devoptab_t* devops;
|
||||||
char* nameCopy;
|
char* nameCopy;
|
||||||
|
|
||||||
if(!interface->startup())
|
if(!interface->startup())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -92,15 +92,15 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
|
|||||||
interface->shutdown();
|
interface->shutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an entry for this device to the devoptab table
|
// Add an entry for this device to the devoptab table
|
||||||
memcpy (devops, &dotab_fat, sizeof(dotab_fat));
|
memcpy (devops, &dotab_fat, sizeof(dotab_fat));
|
||||||
strcpy (nameCopy, name);
|
strcpy (nameCopy, name);
|
||||||
devops->name = nameCopy;
|
devops->name = nameCopy;
|
||||||
devops->deviceData = partition;
|
devops->deviceData = partition;
|
||||||
|
|
||||||
AddDevice (devops);
|
AddDevice (devops);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,21 +112,21 @@ void fatUnmount (const char* name) {
|
|||||||
devoptab_t *devops;
|
devoptab_t *devops;
|
||||||
PARTITION* partition;
|
PARTITION* partition;
|
||||||
const DISC_INTERFACE *disc;
|
const DISC_INTERFACE *disc;
|
||||||
|
|
||||||
devops = (devoptab_t*)GetDeviceOpTab (name);
|
devops = (devoptab_t*)GetDeviceOpTab (name);
|
||||||
if (!devops) {
|
if (!devops) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform a quick check to make sure we're dealing with a libfat controlled device
|
// Perform a quick check to make sure we're dealing with a libfat controlled device
|
||||||
if (devops->open_r != dotab_fat.open_r) {
|
if (devops->open_r != dotab_fat.open_r) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RemoveDevice (name) == -1) {
|
if (RemoveDevice (name) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
partition = (PARTITION*)devops->deviceData;
|
partition = (PARTITION*)devops->deviceData;
|
||||||
disc = partition->disc;
|
disc = partition->disc;
|
||||||
_FAT_partition_destructor (partition);
|
_FAT_partition_destructor (partition);
|
||||||
@ -139,8 +139,8 @@ bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) {
|
|||||||
int defaultDevice = -1;
|
int defaultDevice = -1;
|
||||||
const DISC_INTERFACE *disc;
|
const DISC_INTERFACE *disc;
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL;
|
_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL;
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
disc = _FAT_disc_interfaces[i].getInterface();
|
disc = _FAT_disc_interfaces[i].getInterface();
|
||||||
@ -151,26 +151,26 @@ bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultDevice < 0) {
|
if (defaultDevice < 0) {
|
||||||
// None of our devices mounted
|
// None of our devices mounted
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setAsDefaultDevice) {
|
if (setAsDefaultDevice) {
|
||||||
char filePath[MAXPATHLEN * 2];
|
char filePath[MAXPATHLEN * 2];
|
||||||
strcpy (filePath, _FAT_disc_interfaces[defaultDevice].name);
|
strcpy (filePath, _FAT_disc_interfaces[defaultDevice].name);
|
||||||
strcat (filePath, ":/");
|
strcat (filePath, ":/");
|
||||||
#ifdef ARGV_MAGIC
|
#ifdef ARGV_MAGIC
|
||||||
if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 ) {
|
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
|
// Check the app's path against each of our mounted devices, to see
|
||||||
// if we can support it. If so, change to that path.
|
// if we can support it. If so, change to that path.
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL;
|
_FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL;
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
if ( !strncasecmp( __system_argv->argv[0], _FAT_disc_interfaces[i].name,
|
if ( !strncasecmp( __system_argv->argv[0], _FAT_disc_interfaces[i].name,
|
||||||
strlen(_FAT_disc_interfaces[i].name)))
|
strlen(_FAT_disc_interfaces[i].name)))
|
||||||
{
|
{
|
||||||
char *lastSlash;
|
char *lastSlash;
|
||||||
strcpy(filePath, __system_argv->argv[0]);
|
strcpy(filePath, __system_argv->argv[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user