Page 1 of 1

[libfat] FAT_setAttr dsi exception

Posted: Sun Jan 11, 2015 7:21 pm
by Oibaf
The instruction FAT_setAttr gives "dsi exeption" in all the last versions (1.10.11-13) of libfat.

This is due to a bug in FAT_setAttr (fatfile.c): a NULL pointer is passed to _FAT_directory_entryFromPath which expects a pointer to a variable.

Moreover there is another bug. The code does take into account the endianess of powerPC and therefore the attr variable is always passed with a 0 value.

This code solves both the issues (NEW indicates the new lines).

int FAT_setAttr(const char *file, int attr) {

// Defines...
PARTITION *partition = NULL;
DIR_ENTRY* dirEntry = NULL;

DIR_ENTRY dirEntry_variable; //NEW
char attr_byte; //NEW

dirEntry =&dirEntry_variable; //NEW
attr_byte= (char) attr; //NEW

// Write Data
_FAT_cache_writePartialSector (
partition->cache // Cache to write
, &attr_byte // Value to be written ----> NEW
, _FAT_fat_clusterToSector( partition , entryEnd.cluster ) + entryEnd.sector // cluster
, entryEnd.offset * DIR_ENTRY_DATA_SIZE + DIR_ENTRY_attributes // offset
, 1 // Size in bytes

Re: [libfat] FAT_setAttr dsi exception

Posted: Wed Jan 14, 2015 1:10 pm
by Oibaf
The issue was fixed by Wintermute with 2 patches