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?
[Answered] Virtual File System: Returning an error code ...
[Answered] Virtual File System: Returning an error code ...
Last edited by kolban on Sun Nov 06, 2016 4:37 pm, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Virtual File System: Returning an error code ...
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.
I suppose that even though this is the way 'open' syscall operates on other systems, I need to include these semantics into the documentation.
-
- Posts: 12
- Joined: Thu Mar 23, 2017 3:05 am
Re: [Answered] Virtual File System: Returning an error code ...
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;
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;
-
- Posts: 12
- Joined: Thu Mar 23, 2017 3:05 am
Re: [Answered] Virtual File System: Returning an error code ...
ahaha;
thank you very much ,WiFive;
it is all of the standard C library file operation functions;
thank you very much ,WiFive;
it is all of the standard C library file operation functions;
Who is online
Users browsing this forum: No registered users and 85 guests