Atomic File Operations Using File Lock
The file module has functions lock files across several operations that are almost exact equivalents to POSIX API functions (see Listing - File Module Function and Listing - POSIX API Equivalent); the primary difference is the advantage of valuable return error codes to the application.
Listing - File Module Function
void FSFile_LockGet (FS_FILE *p_file, FS_ERR *p_err); void FSFile_LockAccept (FS_FILE *p_file, FS_ERR *p_err); void FSFile_LockSet (FS_FILE *p_file, FS_ERR *p_err);
Listing - POSIX API Equivalent
void fs_flockfile (FS_FILE *file); int fs_ftrylockfile (FS_FILE *file); void fs_funlockfile (FS_FILE *file);
For more information about and an example of using file locking, see Atomic File Operations Using File Lock - POSIX.