Page 1 of 1

[Answered] Virtual File System: Returning an error code ...

Posted: Sat Nov 05, 2016 4:56 pm
by kolban
When we implement a VFS and wish to return an error code, what is the correct way to perform that task?

For example, I am imagining an underlying call to open() to open a file. If the file does not actually exist, what is the correct procedure to return such an indication? In Unix, I believe open() would return "-1" and the global errno would indicate the last error. In the ESP-IDF environment, should we return -1 from our VFS function and set errno explicitly before return?

Re: Virtual File System: Returning an error code ...

Posted: Sun Nov 06, 2016 5:37 am
by ESP_igrr
Yes, setting errno and returning -1 is the correct way. Newlib will check the return value and propagate the error to the calling function (e.g. return NULL from fopen).
I suppose that even though this is the way 'open' syscall operates on other systems, I need to include these semantics into the documentation.

Re: [Answered] Virtual File System: Returning an error code ...

Posted: Fri Mar 23, 2018 6:28 am
by tangqingcai
hi,could you tell me something about file operation in esp32-idf;
i mean that there are some examples in esp32-idf;
but i can not understand how fopen,fprintf,fget,fclose worked;
i do not find the source code;
so i want to know where is the introduction about esp32-idf's file operation api;

Re: [Answered] Virtual File System: Returning an error code ...

Posted: Fri Mar 23, 2018 6:42 am
by WiFive

Re: [Answered] Virtual File System: Returning an error code ...

Posted: Fri Mar 23, 2018 9:30 am
by tangqingcai
ahaha;
thank you very much ,WiFive;
it is all of the standard C library file operation functions;