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/modified lines).
int FAT_setAttr(const char *file, int attr) {
// Defines...
DIR_ENTRY_POSITION entryEnd;
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
);
The NULL pointer was already fixed. See https://github.com/devkitPro/libfat/commit/b42fdc447c6066202ac05a71d466ea480a97d6cf
I can't tell what you're changing and why, can you please supply a diff.
I have just committed the patch.
attr requires a conversion to char when passed to _FAT_fat_clusterToSector.
_FAT_fat_clusterToSector took the fisrt byte of an integer variable. In the little endian system this byte is the least significant but in the big endian system (like the Wii) is the most significant which in the case of attr is always 0.
I checked the patch on the WII.
I figured out what you were talking about & fixed it with this patch - https://github.com/devkitPro/libfat/commit/ef7a8748e614652b892ecc7634575b9e1d90188b