fab-agon-emulator icon indicating copy to clipboard operation
fab-agon-emulator copied to clipboard

Inconsistent handling of f_open

Open stevesims opened this issue 10 months ago • 1 comments

It's been observed that the emulator can overwrite files, where on a real Agon you will see an Access denied error being reported.

This applies to saving files from BASIC, and copying or renaming files where the destination file already exists. Other applications that are using the mos_save API are also affected (it is strongly suggested that nano exhibits this behaviour too).

The underlying cause of this seems to incorrect behaviour of the fatfs f_open function.

Specifically when the MOS API uses f_open to create new files up to write them, it sets the flags FA_WRITE and FA_CREATE_NEW. When FA_CREATE_NEW is set and the file already exists, fatfs is supposed to return FR_EXISTS. It seems that in the emulator it must be returning FR_OK.

Essentially it seems that calling f_open with the FA_CREATE_NEW is currently behaving identically as if the FA_CREATE_ALWAYS flag was set, which is incorrect.

stevesims avatar Apr 01 '24 10:04 stevesims

related to this, I believe that f_opendir is succeeding in the emulator for non-existent paths instead of reporting FR_NOPATH

stevesims avatar Apr 01 '24 11:04 stevesims