Menu

#133 [libfat] FAT_setAttr dsi exception

confirmed
closed
None
1
2015-01-13
2015-01-11
No

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
);

Discussion

  • Fabio Olimpieri

    Fabio Olimpieri - 2015-01-12

    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.

     
  • Dave Murphy

    Dave Murphy - 2015-01-13
    • status: open --> closed
    • assigned_to: Dave Murphy
     

Log in to post a comment.