• AVR Freaks

Hot!SYS_FS_FileStat exception (Harmony bug?)

Author
sebmadgwick
Super Member
  • Total Posts : 151
  • Reward points : 0
  • Joined: 2012/07/08 09:56:59
  • Location: 0
  • Status: offline
2019/04/05 06:40:14 (permalink)
0

SYS_FS_FileStat exception (Harmony bug?)

SYS_FS_FileStat causes an exception unless the the SYS_FS_fStat buffer is first written as zeros or other 'valid' values.
 
The following code will likely cause an exception depending on the uninitialised values of fileStat in the stack.
SYS_FS_fStat fileStat;
SYS_FS_FileStat("/mnt/myDrive/FILE.TXT", &fileStat);

 
The following code will not cause an exception.
SYS_FS_fStat fileStat;
memset(&fileStat, 0, sizeof (fileStat)); // workaround
SYS_FS_FileStat("/mnt/myDrive/FILE.TXT", &fileStat);

 
Has anyone else come across this?  I guess there's nothing to do other than open a support ticket.  I'm using XC32 v2.15 and MPLAB Harmony v2.06.
post edited by sebmadgwick - 2019/04/05 08:27:48
#1

2 Replies Related Threads

    Luca Pascarella
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2007/05/28 00:53:17
    • Location: The Netherlands
    • Status: offline
    Re: SYS_FS_FileStat exception (Harmony bug) 2019/04/05 07:15:39 (permalink)
    0
    The SYS_FS_FSTAT structure has two fields lfname and lfsize that must be initialized before use.

    For example:
    // If the support for long file name is enabled you must provide a buffer where store it
    SYS_FS_FSTAT fileStat;
    char longFileName[300];

    fileStat.stat.lfname = lp.longFileName;
    fileStat.stat.lfsize = 300;

    // Now you can call
    SYS_FS_FileStat("/mnt/myDrive/FILE.TXT", &fileStat);

     
    If I'm not wrong, a recent release of FatFs by elm-chan.org implements a different approach with an internal buffer for long file names. But Harmony still uses a very old version of that library (R0.11a - 2015).
    post edited by Luca Pascarella - 2019/04/05 07:22:59
    #2
    sebmadgwick
    Super Member
    • Total Posts : 151
    • Reward points : 0
    • Joined: 2012/07/08 09:56:59
    • Location: 0
    • Status: offline
    Re: SYS_FS_FileStat exception (Harmony bug) 2019/04/05 08:27:19 (permalink)
    0
    Thank you, Luca Pascarella.  I just discovered this myself and came back to post an update.
     
    The Harmony documentation describes the requirement to initialise lfname and lfsize in the comments for SYS_FS_DirSearch but not for SYS_FS_FileStat.
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5