forked from nkolban/esp32-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## Missing Posix functions | ||
LibCurl is a moving target and on occassion, is updated to utilize functions that are not part of the ESP-IDF. For example, at the time of writing, the latest version of LibCurl uses the Posix `access(2)` system call that it previously did not. This call is not present in ESP-IDF. To circumvent the problem, a shim file has been provided in `./posix/posix_shims.c` that provides simple implementations for some missing Posix functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# POSIX | ||
Posix is the specification for Unix like functions. The ESP-IDF provides many implementations for Posix functions but some are omitted and thus should not be used in ESP32 based applications. However there are times when we received 3rd party code that uses a Posix function that we don't have in our environment. Our choices then become: | ||
|
||
* Contact the 3rd party provider and ask them to alter their code to remove it, replace it or make it optional. | ||
* Contact Espressif and ask them to add support for the missing Posix function. | ||
* Provide a shim that satisfies the Posix function using the capabailities that are available to us. | ||
|
||
In the source file called `posix_shims.c` we provide some of those shims. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <unistd.h> | ||
#include <errno.h> | ||
#include <sys/stat.h> | ||
|
||
/** | ||
* @brief Provide a shim for the Posix access(2) function. | ||
* @param [in] pathname The file to check. | ||
* @param [in] mode The mode of access requested. | ||
* @return 0 on success, -1 on error with errno set. | ||
*/ | ||
int access(const char *pathname, int mode) { | ||
struct stat statBuf; | ||
if (stat(pathname, &statBuf) == -1) { | ||
errno = ENOENT; | ||
return -1; | ||
} | ||
return 0; // Indicate that all we have access to the file. | ||
} // access |