This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/AM5726: FATFS flags details

Part Number: AM5726

Tool/software: TI-RTOS

Hi everybody , 

Please see the following file flags located in ff.h of the TI RTOS FATS:

/* File access control and file status flags (FIL.flag) */

 

#define      FA_READ             0x01

#define      FA_WRITE            0x02

#define      FA_OPEN_EXISTING    0x00

#define      FA_CREATE_NEW       0x04

#define      FA_CREATE_ALWAYS    0x08

#define      FA_OPEN_ALWAYS      0x10

#define _FA_MODIFIED             0x20

#define _FA_DIRTY                0x40

 

Please explain the meaning of each flag and how each of the flags correlates with standard file system file flags like given in:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen          

thank you very much 

regards

Carlo

  • The RTOS team have been notified. They will respond here.
  • Hi,

    In FATFS, the ff.h and ff.c files are open sources with those control flags defined. The stand is here: . Those flags defined are different from the the two links you mentioned for POSIX, the meaning and relationship you can see here:

    Regards, Eric

  • Hi, Eric.

    Thanks for the response.

    However, something is missing.

    The ff.h header defines the following file access flags:

    /* File access control and file status flags (FIL.flag) */

    #define FA_READ 0x01
    #define FA_WRITE 0x02
    #define FA_OPEN_EXISTING 0x00
    #define FA_CREATE_NEW 0x04
    #define FA_CREATE_ALWAYS 0x08
    #define FA_OPEN_ALWAYS 0x10
    #define _FA_MODIFIED 0x20
    #define _FA_DIRTY 0x40

    There is no definition for FA_OPEN_APPEND here.

    Additionally, the link you've posted doesn't define _FA_MODIFIED and _FA_DIRTY.

    I want to be able to link between those definitions and the flags as defined for C standard. We use GNU build tools, if you go to the file 

    C:\ti\gcc-arm-none-eabi-6-2017-q1-update\arm-none-eabi\include\sys\_default_fcntl.h

    You'll see that:

    #define _FOPEN (-1) /* from sys/file.h, kernel use only */

    #define _FREAD 0x0001 /* read enabled */
    #define _FWRITE 0x0002 /* write enabled */
    #define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
    #define _FMARK 0x0010 /* internal; mark during gc() */
    #define _FDEFER 0x0020 /* internal; defer for next gc pass */
    #define _FASYNC 0x0040 /* signal pgrp when data ready */
    #define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
    #define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
    #define _FCREAT 0x0200 /* open with file create */
    #define _FTRUNC 0x0400 /* open with truncation */
    #define _FEXCL 0x0800 /* error on open if file exists */
    #define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
    #define _FSYNC 0x2000 /* do all writes synchronously */
    #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
    #define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
    #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */

    #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)

    /*
    * Flag values for open(2) and fcntl(2)
    * The kernel adds 1 to the open modes to turn it into some
    * combination of FREAD and FWRITE.
    */
    #define O_RDONLY 0 /* +1 == FREAD */
    #define O_WRONLY 1 /* +1 == FWRITE */
    #define O_RDWR 2 /* +1 == FREAD|FWRITE */
    #define O_APPEND _FAPPEND
    #define O_CREAT _FCREAT
    #define O_TRUNC _FTRUNC
    #define O_EXCL _FEXCL
    #define O_SYNC _FSYNC

  • Hi,

    The FATFS is open source and keeps updating. In TI processor SDK, we used 0.12 release as seen from ff.h. The latest FATFS is 0.13b, from release note: elm-chan.org/.../updates.txt

    R0.12a (July 10, 2016)
    Added support for creating exFAT volume with some changes of f_mkfs().
    Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.

    So the FA_OPEN_APPEND was added later. That is why it is not there in the TI version FATFS. For the
    #define _FA_MODIFIED 0x20
    #define _FA_DIRTY 0x40
    It was removed from the latest FATFS, I didn't find the history.

    So with the current TI version, you need the relationship of _FA_MODIFIED and _FA_DIRTY to POSIX C? How do you want to use this relation? Like a common high level API, to translate into different mode in either FATFS or POSIX?

    Regards, Eric
  • Hi, Eric.
    You are right, I want to understand the relation of _FA_MODIFIED, _FA_DIRTY to standard POXIS high level file API, like fopen(...).
    Thanks
  • Anatoly,

    Those two flags are from FATFS open source code, I asked the question on the FATFS forum and will update here.

    Regards, Eric