APM:Libraries
Functions | Variables
posix.c File Reference

POSIX wrapper for FatFS. More...

#include <string.h>
#include "posix.h"
#include "stdio.h"
Include dependency graph for posix.c:

Go to the source code of this file.

Functions

int isatty (int fileno)
 Test POSIX fileno if it is a Serial Console/TTY. More...
 
int fgetc (FILE *stream)
 Get byte from a TTY device or FatFs file stream open() or fopen() sets stream->get = fatfs_getc() for FatFs functions See fdevopen() sets stream->get for TTY devices. More...
 
int getc (FILE *fp)
 
int fputc (int c, FILE *stream)
 Put a byte to TTY device or FatFs file stream open() or fopen() sets stream->put = fatfs_outc() for FatFs functions See fdevopen() sets stream->put get for TTY devices. More...
 
void clearerr (FILE *stream)
 
int getchar ()
 functions normally defined as macros More...
 
int putchar (int c)
 put a character to stdout See fdevopen() sets stream->put get for TTY devices More...
 
int putc (int c, FILE *stream)
 Un-Get byte from a TTY device or FatFs file stream. More...
 
char * fgets (char *str, int size, FILE *stream)
 get a string from stdin See fdevopen() sets stream->put get for TTY devices More...
 
char * gets (char *p)
 
int fputs (const char *str, FILE *stream)
 put a string to stdout See fdevopen() sets stream->put get for TTY devices More...
 
int puts (const char *str)
 put a string to stdout See fdevopen() sets stream->put get for TTY devices More...
 
int feof (FILE *stream)
 feof reports if the stream is at EOF More...
 
int fgetpos (FILE *stream, size_t *pos)
 POSIX get position of file stream. More...
 
int fseek (FILE *stream, long offset, int whence)
 POSIX seek to file possition. More...
 
int fsetpos (FILE *stream, size_t *pos)
 POSIX set position of file stream. More...
 
long ftell (FILE *stream)
 POSIX file position of open stream. More...
 
off_t lseek (int fileno, off_t position, int whence)
 POSIX seek to file position. More...
 
void rewind (FILE *stream)
 POSIX rewind file to the beginning. More...
 
int close (int fileno)
 POSIX Close a file with fileno handel. More...
 
int fileno (FILE *stream)
 Convert POSIX stream pointer to POSIX fileno (index of __iob[]) More...
 
FILE * fileno_to_stream (int fileno)
 Convert POSIX fileno to POSIX FILE stream pointer. NOT POSIX. More...
 
FILE * fopen (const char *path, const char *mode)
 POSIX Open a file with path name and ascii file mode string. More...
 
size_t __wrap_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
 POSIX read nmemb elements from buf, size bytes each, to the stream fd. More...
 
int ftruncate (int fd, off_t length)
 POSIX truncate open file to length. More...
 
size_t fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 POSIX write nmemb elements from buf, size bytes each, to the stream fd. More...
 
int open (const char *pathname, int flags)
 POSIX Open a file with integer mode flags. More...
 
ssize_t read (int fd, void *buf, size_t count)
 POSIX read count bytes from *buf to fileno fd. More...
 
void sync (void)
 POSIX Sync all pending file changes and metadata on ALL files. More...
 
int syncfs (int fd)
 POSIX Sync pending file changes and metadata for specified fileno. More...
 
int truncate (const char *path, off_t length)
 POSIX truncate named file to length. More...
 
ssize_t write (int fd, const void *buf, size_t count)
 POSIX Write count bytes from *buf to fileno fd. More...
 
FILE * __wrap_freopen (const char *filename, const char *mode, FILE *stream)
 
int __wrap_fclose (FILE *stream)
 POSIX close a file stream. More...
 
int stat (const char *name, struct stat *buf)
 Display struct stat, from POSIX stat(0 or fstat(), in ASCII. NOT POSIX. More...
 
int utime (const char *filename, const struct utimbuf *times)
 Set Modification and Access time of a file. More...
 
int64_t fs_getfree ()
 
int64_t fs_gettotal ()
 
char * basename (const char *str)
 POSIX Basename of filename. More...
 
char * baseext (char *str)
 File extention of a file name. NOT POSIX. More...
 
int chdir (const char *pathname)
 POSIX change directory. More...
 
int chmod (const char *pathname, mode_t mode)
 POSIX chmod function - change file access permission Unfortunately file f_open modes and f_chmod modes are not the same Files that are open have way more options - but only while the file is open. More...
 
int dirname (char *str)
 POSIX directory name of a filename. Return the index of the last '/' character. More...
 
char * getcwd (char *pathname, int len)
 POSIX get current working directory. More...
 
int mkdir (const char *pathname, mode_t mode)
 POSIX make a directory. More...
 
int rename (const char *oldpath, const char *newpath)
 POSIX rename a file by name. More...
 
int rmdir (const char *pathname)
 POSIX delete a directory. More...
 
int unlink (const char *pathname)
 POSIX delete a file. More...
 
int remove (const char *pathname)
 
int closedir (DIR *dirp)
 POSIX closedir. More...
 
DIRopendir (const char *pathdir)
 
dirent_t * readdir (DIR *dirp)
 
void clrerror (FILE *stream)
 clrerror resets stream EOF and error flags More...
 
int ferror (FILE *stream)
 ferror reports if the stream has an error flag set More...
 
void perror (const char *s)
 POSIX perror() - convert POSIX errno to text with user message. More...
 
char * strerror (int errnum)
 POSIX strerror() - convert POSIX errno to text with user message. More...
 
char * __wrap_strerror_r (int errnum, char *buf, size_t buflen)
 POSIX strerror_r() - convert POSIX errno to text with user message. More...
 
FILE * fdevopen (int(*put)(char, FILE *), int(*get)(FILE *))
 Device open functions. More...
 
int fatfs_getc (FILE *stream)
 Formt SD card. More...
 
int fatfs_putc (char c, FILE *stream)
 Private FatFs function called by fputc() to put a byte from file stream NOT POSIX open() assigns stream->put = fatfs_putc() More...
 
int fatfs_to_errno (FRESULT Result)
 Convert FafFs error result to POSIX errno. NOT POSIX. More...
 
int fatfs_to_fileno (FIL *fh)
 Convert FatFS file handle to POSIX fileno. NOT POSIX. More...
 
static time_t replace_mktime (const struct tm *t)
 
time_t fat_time_to_unix (uint16_t date, uint16_t time)
 Convert FatFs file date and time to POSIX epoch seconds. NOT POSIX. More...
 
void unix_time_to_fat (time_t epoch, uint16_t *date, uint16_t *time)
 Convert Linux POSIX time_t to FAT32 date and time. NOT POSIX. More...
 
FILfileno_to_fatfs (int fileno)
 Convert POSIX fileno to FatFS handle NOT POSIX. More...
 
int free_file_descriptor (int fileno)
 Free POSIX fileno FILE descriptor. NOT POSIX. More...
 
int new_file_descriptor (void)
 Allocate a POSIX FILE descriptor. NOT POSIX. More...
 
int posix_fopen_modes_to_open (const char *mode)
 Convert POSIX fopen mode to POSIX open mode flags. NOT POSIX. More...
 
int fprintf (FILE *fp, const char *fmt,...)
 fprintf character write function More...
 
int fsync (int fileno)
 

Variables

int errno
 Note: fdevopen assigns stdin,stdout,stderr. More...
 
FILE * __iob [MAX_FILES]
 POSIX fileno to POSIX FILE stream table. More...
 
const char * sys_errlist []
 POSIX error messages for each errno value. More...
 
static DIR _dp
 POSIX opendir. More...
 
static dirent_t _de
 POSIX opendir. More...
 

Detailed Description

POSIX wrapper for FatFS.

Copyright © 2015 Mike Gore, GPL License
You are free to use this code under the terms of GPL
please retain a copy of this notice in any code you use it in.

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file posix.c.

Function Documentation

◆ __wrap_fclose()

int __wrap_fclose ( FILE *  stream)

POSIX close a file stream.

  • man page flose (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
0 on sucess.
-1 on error witrh errno set.

Definition at line 1236 of file posix.c.

Here is the call graph for this function:

◆ __wrap_fread()

size_t __wrap_fread ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

POSIX read nmemb elements from buf, size bytes each, to the stream fd.

  • man page fread (3).
Parameters
[in]ptrbuffer.
[in]nmembnumber of items to read.
[in]sizesize of each item in bytes.
[in]streamPOSIX file stream.
Returns
count on sucess.
0 or < size on error with errno set.

Definition at line 793 of file posix.c.

Here is the call graph for this function:

◆ __wrap_freopen()

FILE* __wrap_freopen ( const char *  filename,
const char *  mode,
FILE *  stream 
)

Definition at line 1218 of file posix.c.

Here is the call graph for this function:

◆ __wrap_strerror_r()

char* __wrap_strerror_r ( int  errnum,
char *  buf,
size_t  buflen 
)

POSIX strerror_r() - convert POSIX errno to text with user message.

  • man page strerror (3).
Parameters
[in]errnumindex for sys_errlist[]
[in]bufuser buffer for error message
[in]buflenlength of user buffer for error message
See also
sys_errlist[].
Returns
char *

Definition at line 1869 of file posix.c.

◆ baseext()

char* baseext ( char *  str)

File extention of a file name. NOT POSIX.

Parameters
[in]strstring to find extension in.
Returns
pointer to basename extension.

Definition at line 1467 of file posix.c.

◆ basename()

char* basename ( const char *  str)

POSIX Basename of filename.

  • POSIX file and directory manipulation- man page (3).
Parameters
[in]strstring to find basename in.
Returns
pointer to basename of string.

Definition at line 1446 of file posix.c.

◆ chdir()

int chdir ( const char *  pathname)

POSIX change directory.

  • man page chdir (2).
Parameters
[in]pathnamedirectory to change to
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 1489 of file posix.c.

Referenced by SITL::JSBSim::start_JSBSim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chmod()

int chmod ( const char *  pathname,
mode_t  mode 
)

POSIX chmod function - change file access permission Unfortunately file f_open modes and f_chmod modes are not the same Files that are open have way more options - but only while the file is open.

  • so this is a bit of a hack - we can only set read only - if on one has write perms

man page chmod (2).

Parameters
[in]pathnamefilename string.
[in]modePOSIX chmod modes.
Returns
fileno on success.

Definition at line 1514 of file posix.c.

Referenced by mkdir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearerr()

void clearerr ( FILE *  stream)

Definition at line 296 of file posix.c.

◆ close()

int close ( int  fileno)

POSIX Close a file with fileno handel.

  • POSIX file functions- man page close (2).
Parameters
[in]filenofileno of file.
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 675 of file posix.c.

Referenced by __wrap_fclose(), __wrap_freopen(), HALSITL::UARTDriver::_check_reconnect(), Linux::GPIO_Sysfs::_export_pin(), PX4::PX4Storage::_mtd_load(), VRBRAIN::VRBRAINStorage::_mtd_load(), PX4::PX4Storage::_mtd_write(), VRBRAIN::VRBRAINStorage::_mtd_write(), Linux::OpticalFlow_Onboard::_run_optflow(), Linux::Storage::_storage_create(), PX4::PX4Storage::_storage_open(), VRBRAIN::VRBRAINStorage::_storage_open(), HALSITL::UARTDriver::_tcp_start_client(), HALSITL::UARTDriver::_tcp_start_connection(), Linux::Storage::_timer_tick(), AP_RPM_PX4_PWM::AP_RPM_PX4_PWM(), AP_RangeFinder_BBB_PRU::detect(), AP_RangeFinder_PX4_PWM::detect(), VRBRAIN::VRBRAINRCOutput::enable_px4io_sbus_out(), PX4::PX4RCOutput::enable_px4io_sbus_out(), PX4::PX4UARTDriver::end(), VRBRAIN::VRBRAINUARTDriver::end(), GCS_MAVLINK::handle_preflight_reboot(), Linux::RCOutput_ZYNQ::init(), Linux::RCInput_ZYNQ::init(), Linux::RCInput_PRU::init(), Linux::RCOutput_PRU::init(), Linux::Storage::init(), Linux::RCOutput_AioPRU::init(), Linux::RCInput_SBUS::init(), Linux::RCInput_AioPRU::init(), Linux::GPIO_RPI::init(), Linux::GPIO_BBB::init(), Linux::RCInput_RPI::map_peripheral(), Linux::Memory_table::Memory_table(), Linux::VideoIn::open_device(), Linux::Poller::Poller(), AP_BoardConfig::px4_setup_pwm(), AP_BoardConfig::px4_setup_safety_mask(), PX4::PX4RCInput::rc_bind(), Linux::GPIO_Sysfs::read(), PX4::PX4Util::run_debug_shell(), VRBRAIN::VRBRAINUtil::run_debug_shell(), AnalogSource_Navio2::set_channel(), AP_Camera::setup_feedback_callback(), Linux::TimerPollable::setup_timer(), PX4::NSHShellStream::shell_thread(), VRBRAIN::NSHShellStream::shell_thread(), SITL::JSBSim::start_JSBSim(), SITL::last_letter::start_last_letter(), Linux::GPIO_Sysfs::write(), Linux::Util::write_file(), AP_RangeFinder_PX4_PWM::~AP_RangeFinder_PX4_PWM(), AP_RPM_PX4_PWM::~AP_RPM_PX4_PWM(), Linux::DigitalSource_Sysfs::~DigitalSource_Sysfs(), Linux::I2CBus::~I2CBus(), Linux::Led_Sysfs::~Led_Sysfs(), Linux::Pollable::~Pollable(), Linux::Poller::~Poller(), Linux::PWM_Sysfs_Base::~PWM_Sysfs_Base(), Linux::RCInput_UART::~RCInput_UART(), and Linux::SPIBus::~SPIBus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closedir()

int closedir ( DIR dirp)

POSIX closedir.

  • POSIX - directory scanning functions- man page closedir (2).
Parameters
[in]dirpDIR * directory handle
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 1730 of file posix.c.

Referenced by Linux::I2CDeviceManager::get_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clrerror()

void clrerror ( FILE *  stream)

clrerror resets stream EOF and error flags

  • POSIX error functions- man page clrerror(3).
Parameters
[in]streamPOSIX stream pointer.
Returns
EOF on error with errno set.

Definition at line 1799 of file posix.c.

◆ dirname()

int dirname ( char *  str)

POSIX directory name of a filename. Return the index of the last '/' character.

  • Example:
    dir[0] = 0;
    ret = dirname(path)
    if(ret)
    strncpy(dir,path,ret);
Parameters
[in]strstring to examine.
Returns
0 if no directory part.
index of last '/' character.

Definition at line 1552 of file posix.c.

Referenced by Linux::I2CDeviceManager::get_device().

Here is the caller graph for this function:

◆ fat_time_to_unix()

time_t fat_time_to_unix ( uint16_t  date,
uint16_t  time 
)

Convert FatFs file date and time to POSIX epoch seconds. NOT POSIX.

  • man page timegm (3).
Parameters
[in]dateFatFs date.
[in]timeFatFs time.
See also
timegm()
Returns
epoch seconds

Definition at line 2282 of file posix.c.

Referenced by stat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fatfs_getc()

int fatfs_getc ( FILE *  stream)

Formt SD card.

  • FatFS to POSIX bridge functions
    Parameters
    [in]*namedevice name void Private FatFs function called by fgetc() to get a byte from file stream FIXME buffer this function call NOT POSIX open() assigns stream->get = fatfs_getc()
  • man page fgetc (3).
  • Notes: fgetc does all tests prior to caling us, including ungetc.
Parameters
[in]streamPOSIX stream pointer.
Returns
character.
EOF on error with errno set.

Definition at line 1997 of file posix.c.

Referenced by open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fatfs_putc()

int fatfs_putc ( char  c,
FILE *  stream 
)

Private FatFs function called by fputc() to put a byte from file stream NOT POSIX open() assigns stream->put = fatfs_putc()

  • man page fputc (3).
  • Notes: fputc does all tests prior to caling us.
Parameters
[in]ccharacter.
[in]streamPOSIX stream pointer.
Returns
character
EOF on error with errno set.

Definition at line 2087 of file posix.c.

Referenced by fputc(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fatfs_to_errno()

int fatfs_to_errno ( FRESULT  Result)

Convert FafFs error result to POSIX errno. NOT POSIX.

  • man page errno (3).
Parameters
[in]ResultFatFs Result code.
Returns
POSIX errno.
EBADMSG if no conversion possible.

Definition at line 2127 of file posix.c.

Referenced by chdir(), chmod(), close(), closedir(), fatfs_getc(), fatfs_putc(), fsync(), ftruncate(), getcwd(), lseek(), mkdir(), open(), opendir(), read(), readdir(), remove(), rename(), rmdir(), stat(), syncfs(), truncate(), unlink(), utime(), and write().

Here is the caller graph for this function:

◆ fatfs_to_fileno()

int fatfs_to_fileno ( FIL fh)

Convert FatFS file handle to POSIX fileno. NOT POSIX.

Parameters
[in]fhFatFS file pointer.
Returns
fileno on success.
-1 on error with errno set to EBADF.

Definition at line 2204 of file posix.c.

◆ fdevopen()

FILE* fdevopen ( int(*)(char, FILE *)  put,
int(*)(FILE *)  get 
)

Device open functions.

Assign stdin,stdout,stderr or any use defined I/O NOT POSIX

Parameters
[in]*putuart putc function pointer
[in]*getuart gutc function pointer

Definition at line 1888 of file posix.c.

Here is the call graph for this function:

◆ feof()

int feof ( FILE *  stream)

feof reports if the stream is at EOF

  • POSIX file position functions- man page feof (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
1 if EOF set, 0 otherwise.

Definition at line 500 of file posix.c.

◆ ferror()

int ferror ( FILE *  stream)

ferror reports if the stream has an error flag set

  • man page ferror (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
1 if EOF set, 0 otherwise.

Definition at line 1811 of file posix.c.

◆ fgetc()

int fgetc ( FILE *  stream)

Get byte from a TTY device or FatFs file stream open() or fopen() sets stream->get = fatfs_getc() for FatFs functions See fdevopen() sets stream->get for TTY devices.

  • man page fgetc (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.
EOF on error with errno set.

Definition at line 205 of file posix.c.

Referenced by fgets(), getc(), getchar(), and read().

Here is the caller graph for this function:

◆ fgetpos()

int fgetpos ( FILE *  stream,
size_t *  pos 
)

POSIX get position of file stream.

  • man page fgetpos (3).
Parameters
[in]streamPOSIX file stream.
[in]posposition pointer for return.
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 517 of file posix.c.

Here is the call graph for this function:

◆ fgets()

char* fgets ( char *  str,
int  size,
FILE *  stream 
)

get a string from stdin See fdevopen() sets stream->put get for TTY devices

POSIX string I/O

  • man page fgets (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.

Definition at line 398 of file posix.c.

Referenced by Linux::UtilRPI::_check_rpi_version(), atob(), Linux::Util::get_hw_arm32(), gets(), and AP_Param::parse_param_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileno()

int fileno ( FILE *  stream)

Convert POSIX stream pointer to POSIX fileno (index of __iob[])

  • man page fileno (3)
    Parameters
    [in]streamstream pointer
    Returns
    int fileno on success
    -1 with errno = EBAFD if stream is NULL or not found

Definition at line 714 of file posix.c.

Referenced by __wrap_fclose(), __wrap_fread(), __wrap_freopen(), fileno_to_stream(), fopen(), free_file_descriptor(), fseek(), ftell(), fwrite(), and open().

Here is the caller graph for this function:

◆ fileno_to_fatfs()

FIL* fileno_to_fatfs ( int  fileno)

Convert POSIX fileno to FatFS handle NOT POSIX.

  • FatFS file handle is pointed to by the avr-libc stream->udata.
Parameters
[in]filenofileno of file
Returns
FIL * FatFS file handle on success.
NULL if POSIX fileno is invalid NULL

Definition at line 2331 of file posix.c.

Referenced by close(), fsync(), ftell(), ftruncate(), lseek(), open(), read(), sync(), syncfs(), and write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileno_to_stream()

FILE* fileno_to_stream ( int  fileno)

Convert POSIX fileno to POSIX FILE stream pointer. NOT POSIX.

  • inverse of POSIX fileno()
  • man page fileno (3)
Parameters
[in]filenoPOSIX fileno is the index of __iob[].
See also
fileno()
Returns
FILE * on success
NULL on error with errno set, NULL if fileno out of bounds

Definition at line 744 of file posix.c.

Referenced by close(), fileno_to_fatfs(), fopen(), free_file_descriptor(), fsync(), lseek(), open(), read(), syncfs(), and write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fopen()

FILE* fopen ( const char *  path,
const char *  mode 
)

POSIX Open a file with path name and ascii file mode string.

  • man page fopen(3).
Parameters
[in]pathfilename string.
[in]modePOSIX open mode strings.
Returns
stream * on success.
NULL on error with errno set.

Definition at line 772 of file posix.c.

Referenced by __wrap_freopen(), Linux::UtilRPI::_check_rpi_version(), Linux::RCInput::_process_rc_pulse(), SITL::JSBSim::create_templates(), AP_RangeFinder_BBB_PRU::detect(), Linux::Util::get_hw_arm32(), main(), AP_Param::parse_param_line(), AP_GPS_NMEA::read(), Linux::Util::read_file(), and srxl_decode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fprintf()

int fprintf ( FILE *  fp,
const char *  fmt,
  ... 
)

fprintf character write function

  • POSIX fprintf function
    Parameters
    [in]*pprintf user buffer
    [in]chcharacter TODO if fputc fails we might want to also set an error in the *p structure - error in the stream will already be set fprintf function Example user defined printf function using fputc for I/O This method allows I/O to devices and strings without typical C++ overhead
    [in]*fpFILE stream pointer
    [in]fmtprintf forat string
    [in]...vararg list or arguments
    Returns
    size of printed result

Definition at line 2539 of file posix.c.

Referenced by HALSITL::UARTDriver::_check_connection(), HALSITL::UARTDriver::_check_reconnect(), Linux::UtilRPI::_check_rpi_version(), Linux::Perf::_debug_counters(), Linux::Scheduler::_debug_stack(), HALSITL::SITL_State::_parse_command_line(), Linux::RCInput::_process_rc_pulse(), HALSITL::SITL_State::_setup_fdm(), _sig_fpe(), HALSITL::SITL_State::_sitl_setup(), Linux::Storage::_storage_create(), HALSITL::UARTDriver::_tcp_start_client(), HALSITL::UARTDriver::_tcp_start_connection(), VRBRAIN::DeviceBus::adjust_timer(), PX4::DeviceBus::adjust_timer(), BM_Crop8bpp(), BM_YuyvToGrey(), consumer_thread(), SITL::JSBSim::create_templates(), Linux::Scheduler::delay(), SITL::JSBSim::drain_control_socket(), SITL::Gazebo::drain_sockets(), DataFlash_Class::dump_structure_field(), DataFlash_Class::dump_structures(), fail(), SITL::Gazebo::Gazebo(), Linux::Memory_table::Memory_table(), UARTDevice::open(), parse_gpio_pin_number(), Linux::Poller::Poller(), SITL::JSBSim::send_servos(), ConsoleDevice::set_blocking(), UARTDevice::set_blocking(), Linux::UARTDriver::set_device_path(), SITL::Gazebo::set_interface_ports(), SITL::Gripper_Servo::update(), SITL::Gripper_EPM::update_from_demand(), SITL::Vicon::update_vicon_position_estimate(), and Linux::Poller::wakeup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fputc()

int fputc ( int  c,
FILE *  stream 
)

Put a byte to TTY device or FatFs file stream open() or fopen() sets stream->put = fatfs_outc() for FatFs functions See fdevopen() sets stream->put get for TTY devices.

  • man page fputc (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.

Definition at line 264 of file posix.c.

Referenced by fprintf(), fputs(), putc(), putchar(), puts(), and write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fputs()

int fputs ( const char *  str,
FILE *  stream 
)

put a string to stdout See fdevopen() sets stream->put get for TTY devices

  • man page fputs (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.

Definition at line 452 of file posix.c.

Here is the call graph for this function:

◆ free_file_descriptor()

int free_file_descriptor ( int  fileno)

Free POSIX fileno FILE descriptor. NOT POSIX.

Parameters
[in]filenoPOSIX file number __iob[] index.
Returns
fileno on success.
-1 on failure.

Definition at line 2366 of file posix.c.

Referenced by close(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fs_getfree()

int64_t fs_getfree ( )

Definition at line 1405 of file posix.c.

Here is the call graph for this function:

◆ fs_gettotal()

int64_t fs_gettotal ( )

Definition at line 1420 of file posix.c.

Here is the call graph for this function:

◆ fseek()

int fseek ( FILE *  stream,
long  offset,
int  whence 
)

POSIX seek to file possition.

  • man page fseek (3).
Parameters
[in]streamPOSIX file stream.
[in]offsetoffset to seek to.
[in]whence
  • SEEK_SET The offset is set to offset bytes.
  • SEEK_CUR The offset is set to its current location plus offset bytes.
  • SEEK_END The offset is set to the size of the file plus offset bytes.
Returns
file position on sucess.
-1 on error.

Definition at line 540 of file posix.c.

Referenced by fsetpos(), and rewind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsetpos()

int fsetpos ( FILE *  stream,
size_t *  pos 
)

POSIX set position of file stream.

  • man page fsetpos (3).
Parameters
[in]streamPOSIX file stream.
[in]posposition pointer.
Returns
0 with *pos set to position on sucess.
-1 on error with errno set.

Definition at line 566 of file posix.c.

Here is the call graph for this function:

◆ fsync()

int fsync ( int  fileno)

Definition at line 2562 of file posix.c.

Referenced by Linux::Storage::_storage_create(), and Linux::Storage::_timer_tick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ftell()

long ftell ( FILE *  stream)

POSIX file position of open stream.

  • man page fteel (3).
Parameters
[in]streamPOSIX file stream.
Returns
file position on sucess.
-1 on error with errno set.

Definition at line 580 of file posix.c.

Referenced by fgetpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ftruncate()

int ftruncate ( int  fd,
off_t  length 
)

POSIX truncate open file to length.

  • man page ftruncate (3).
Parameters
[in]fdopen file number.
[in]lengthlength to truncate to.
Returns
0 on success.
-1 on fail.

Definition at line 817 of file posix.c.

Referenced by HALSITL::EEPROMStorage::_eeprom_open(), and Linux::Storage::_storage_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fwrite()

size_t fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

POSIX write nmemb elements from buf, size bytes each, to the stream fd.

  • man page write (2).
Parameters
[in]ptrbuffer.
[in]nmembnumber of items to write.
[in]sizesize of each item in bytes.
[in]streamPOSIX file stream.
Returns
count written on sucess.
0 or < size on error with errno set.

Definition at line 858 of file posix.c.

Referenced by AP_GPS_NMEA::read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getc()

int getc ( FILE *  fp)

Definition at line 250 of file posix.c.

Here is the call graph for this function:

◆ getchar()

int getchar ( )

functions normally defined as macros

get a character from stdin See fdevopen() sets stream->get for TTY devices

  • man page getchar (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.

Definition at line 314 of file posix.c.

Here is the call graph for this function:

◆ getcwd()

char* getcwd ( char *  pathname,
int  len 
)

POSIX get current working directory.

  • man page getcwd (2).
Parameters
[in]pathnamedirectory to change to
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 1597 of file posix.c.

Here is the call graph for this function:

◆ gets()

char* gets ( char *  p)

char *gets(p) – get line from stdin

Definition at line 429 of file posix.c.

Here is the call graph for this function:

◆ isatty()

int isatty ( int  fileno)

Test POSIX fileno if it is a Serial Console/TTY.

  • POSIX character I/O functions
    • man page isatty (3).
Parameters
[in]filenoPOSIX fileno of open file.
Returns
1 if fileno is a serial TTY/Console (uart in avr-libc terms).
0 if POSIX fileno is NOT a Serial TTY.
Todo:
Perhaps we should verify console functions have been added ?

Definition at line 185 of file posix.c.

Referenced by __wrap_fclose(), fileno_to_fatfs(), free_file_descriptor(), ftell(), ftruncate(), lseek(), new_file_descriptor(), sync(), and syncfs().

Here is the caller graph for this function:

◆ lseek()

off_t lseek ( int  fileno,
off_t  position,
int  whence 
)

POSIX seek to file position.

  • man page lseek (2).
Parameters
[in]filenoPOSIX fileno of open file.
[in]positionoffset to seek to.
[in]whence
  • SEEK_SET The offset is set to offset bytes.
  • SEEK_CUR The offset is set to its current location plus offset bytes.
  • SEEK_END The offset is set to the size of the file plus offset bytes.
Returns
file position on sucess.
-1 on error.

Definition at line 612 of file posix.c.

Referenced by PX4::PX4Storage::_mtd_write(), VRBRAIN::VRBRAINStorage::_mtd_write(), Linux::Storage::_timer_tick(), HALSITL::SITL_State::_update_gps_file(), fseek(), and Linux::Memory_table::Memory_table().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkdir()

int mkdir ( const char *  pathname,
mode_t  mode 
)

POSIX make a directory.

  • man page mkdir (2).
Parameters
[in]pathnamedirectory to create
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 1620 of file posix.c.

Referenced by mkdir_p(), and sdcard_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_file_descriptor()

int new_file_descriptor ( void  )

Allocate a POSIX FILE descriptor. NOT POSIX.

Returns
fileno on success.
-1 on failure with errno set.

Definition at line 2410 of file posix.c.

Referenced by open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

int open ( const char *  pathname,
int  flags 
)

POSIX Open a file with integer mode flags.

  • man page open (2).
Parameters
[in]pathnamefilename string.
[in]flagsPOSIX open modes.
Returns
fileno on success.
-1 on error with errno set.

Seek to end of the file

Definition at line 885 of file posix.c.

Referenced by HALSITL::EEPROMStorage::_eeprom_open(), Linux::GPIO_Sysfs::_export_pin(), AP_InertialSensor_PX4::_init_sensor(), PX4::PX4Storage::_mtd_load(), VRBRAIN::VRBRAINStorage::_mtd_load(), Linux::GPIO_Sysfs::_open_pin_value(), Linux::OpticalFlow_Onboard::_run_optflow(), Linux::Storage::_storage_create(), VRBRAIN::VRBRAINStorage::_storage_open(), PX4::PX4Storage::_storage_open(), Linux::RCInput_SBUS::_timer_tick(), VRBRAIN::VRBRAINStorage::_timer_tick(), PX4::PX4Storage::_timer_tick(), HALSITL::UARTDriver::_uart_start_connection(), HALSITL::SITL_State::_update_gps_file(), AP_RangeFinder_PX4_PWM::AP_RangeFinder_PX4_PWM(), AP_RPM_PX4_PWM::AP_RPM_PX4_PWM(), VRBRAIN::VRBRAINUARTDriver::begin(), PX4::PX4UARTDriver::begin(), AP_RangeFinder_BBB_PRU::detect(), AP_RangeFinder_PX4_PWM::detect(), dsm_decode(), VRBRAIN::VRBRAINRCOutput::enable_px4io_sbus_out(), PX4::PX4RCOutput::enable_px4io_sbus_out(), fopen(), GCS_MAVLINK::handle_preflight_reboot(), Linux::RCOutput_ZYNQ::init(), PX4::PX4RCOutput::init(), VRBRAIN::VRBRAINRCOutput::init(), Linux::RCInput_ZYNQ::init(), Linux::RCInput_PRU::init(), Linux::PWM_Sysfs_Base::init(), Linux::RCOutput_PRU::init(), Linux::Storage::init(), VRBRAIN::VRBRAINGPIO::init(), Linux::RCOutput_AioPRU::init(), Linux::Led_Sysfs::init(), ToneAlarm_PX4::init(), Linux::RCInput_SBUS::init(), Linux::RCInput_115200::init(), Linux::RCInput_AioPRU::init(), PX4::PX4GPIO::init(), OreoLED_PX4::init(), Linux::GPIO_RPI::init(), PX4::PX4AnalogIn::init(), VRBRAIN::VRBRAINAnalogIn::init(), Linux::GPIO_BBB::init(), AP_Gripper_EPM::init_gripper(), AnalogSource_IIO::init_pins(), Linux::RCInput_RPI::map_peripheral(), Linux::Memory_table::Memory_table(), Linux::SPIBus::open(), Linux::RCInput_Navio2::open_channel(), Linux::VideoIn::open_device(), AP_BoardConfig::px4_setup_pwm(), AP_BoardConfig::px4_setup_safety_mask(), PX4::PX4RCInput::rc_bind(), Linux::RCInput_UART::RCInput_UART(), AnalogSource_Navio2::set_channel(), Linux::CameraSensor::set_format(), VRBRAIN::VRBRAINUtil::set_imu_temp(), PX4::PX4Util::set_imu_temp(), setup(), AP_Camera::setup_feedback_callback(), srxl_decode(), SITL::JSBSim::start_JSBSim(), SITL::last_letter::start_last_letter(), AP_OpticalFlow_Pixart::timer(), Linux::ToneAlarm::ToneAlarm(), and Linux::Util::write_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opendir()

DIR* opendir ( const char *  pathdir)

Definition at line 1749 of file posix.c.

Referenced by Linux::I2CDeviceManager::get_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perror()

void perror ( const char *  s)

POSIX perror() - convert POSIX errno to text with user message.

  • man page errno (3).
Parameters
[in]sUser message displayed before the error message
See also
sys_errlist[].
Returns
void.

Definition at line 1827 of file posix.c.

Referenced by dsm_decode(), Linux::RCOutput_Bebop::init(), srxl_decode(), SITL::JSBSim::start_JSBSim(), and SITL::last_letter::start_last_letter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_fopen_modes_to_open()

int posix_fopen_modes_to_open ( const char *  mode)

Convert POSIX fopen mode to POSIX open mode flags. NOT POSIX.

  • man page fopen (3).
  • man page open (2).
  • Valid modes.
  • Read
    • "r", "rb"
  • Read and Write
    • "r+", "r+b", "rb+"
  • Write
    • "w", "wb"
  • Write and Read.
    • "w+", "w+b", "wb+"
    • "w+" implies write/read access.
  • Append
    • "a", "ab"
  • Append and Read
    • "a+", "a+b", "ab+"
  • Note: ORDER IS IMPORTANT! so w+ is NOT the same as r+.
  • ALWAYS do a fflush or fseek between rear write operations if + is used..
Parameters
[in]modePOSIX file mode string.
Returns
open mode flags.
-1 on error.
Warning
read and write BOTH share the same stream buffer and buffer index pointers.

Definition at line 2473 of file posix.c.

Referenced by fopen().

Here is the caller graph for this function:

◆ putc()

int putc ( int  c,
FILE *  stream 
)

Un-Get byte from a TTY device or FatFs file stream.

  • man page ungetc (3).
Parameters
[in]cCharacter to unget
[in]streamPOSIX stream pointer.
Returns
character.
EOF on error with errno set. Put a character to a stream See fdevopen() sets stream->put get for TTY devices
  • man page putc (3).
Parameters
[in]streamPOSIX stream pointer.

Definition at line 379 of file posix.c.

Here is the call graph for this function:

◆ putchar()

int putchar ( int  c)

put a character to stdout See fdevopen() sets stream->put get for TTY devices

  • man page putchar (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.

Definition at line 329 of file posix.c.

Here is the call graph for this function:

◆ puts()

int puts ( const char *  str)

put a string to stdout See fdevopen() sets stream->put get for TTY devices

  • man page puts (3).
Parameters
[in]streamPOSIX stream pointer.
Returns
character.

Definition at line 475 of file posix.c.

Here is the call graph for this function:

◆ read()

ssize_t read ( int  fd,
void *  buf,
size_t  count 
)

POSIX read count bytes from *buf to fileno fd.

  • man page read (2).
Parameters
[in]fdPOSIX fileno.
[in]bufbuffer.
[in]countnumber of bytes to write.
Returns
count on sucess.
-1 on error with errno set.

Definition at line 995 of file posix.c.

Referenced by __wrap_fread(), AP_InertialSensor_PX4::_get_accel_sample(), AP_InertialSensor_PX4::_get_gyro_sample(), PX4::PX4Storage::_mtd_load(), VRBRAIN::VRBRAINStorage::_mtd_load(), PX4::PX4AnalogIn::_timer_tick(), VRBRAIN::VRBRAINAnalogIn::_timer_tick(), HALSITL::SITL_State::_update_gps(), HALSITL::SITL_State::_update_gps_file(), SITL::JSBSim::check_stdout(), dsm_decode(), SITL::JSBSim::expect(), Linux::RCOutput_Bebop::from(), Linux::CAN::getFileDescriptor(), HALSITL::SITL_State::gps_read(), Linux::Storage::init(), loop(), Linux::Memory_table::Memory_table(), Linux::TimerPollable::on_can_read(), Linux::WakeupPollable::on_can_read(), ConsoleDevice::read(), UARTDevice::read(), RC_Channels::read_input(), srxl_decode(), SITL::JSBSim::start_JSBSim(), AP_RPM_PX4_PWM::update(), and AP_RangeFinder_PX4_PWM::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readdir()

dirent_t* readdir ( DIR dirp)

Definition at line 1768 of file posix.c.

Referenced by Linux::I2CDeviceManager::get_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

int remove ( const char *  pathname)

Definition at line 1706 of file posix.c.

Here is the call graph for this function:

◆ rename()

int rename ( const char *  oldpath,
const char *  newpath 
)

POSIX rename a file by name.

  • man page (2).
Parameters
[in]oldpathoriginal name.
[in]newpathnew name.
Returns
0 on success.
-1 on error with errno set.

Definition at line 1648 of file posix.c.

Here is the call graph for this function:

◆ replace_mktime()

static time_t replace_mktime ( const struct tm *  t)
static

Definition at line 2232 of file posix.c.

Referenced by fat_time_to_unix().

Here is the caller graph for this function:

◆ rewind()

void rewind ( FILE *  stream)

POSIX rewind file to the beginning.

  • man page rewind (3).
Parameters
[in]streamPOSIX file stream.
Returns
void.

Definition at line 656 of file posix.c.

Here is the call graph for this function:

◆ rmdir()

int rmdir ( const char *  pathname)

POSIX delete a directory.

  • man page rmdir (2).
Parameters
[in]pathnamedirectory to delete.
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 1671 of file posix.c.

Here is the call graph for this function:

◆ stat()

int stat ( const char *  name,
struct stat *  buf 
)

Display struct stat, from POSIX stat(0 or fstat(), in ASCII. NOT POSIX.

  • POSIX file information functions
    Parameters
    [in]spstruct stat pointer.
    Returns
    void. POSIX stat - get file status of named file.
  • man page (2).
Parameters
[in]namefile name.
[in]bufstruct stat buffer to return results in.
Returns
0 on success.
-1 on error with errno set.

Definition at line 1319 of file posix.c.

Referenced by __attribute__(), __wrap_fclose(), Linux::UARTDriver::_parseDevicePath(), f_getfree(), f_mkfs(), find_volume(), get_stack_top(), PX4::PX4RCOutput::init(), Linux::Util::is_chardev_node(), and is_dir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strerror()

char* strerror ( int  errnum)

◆ sync()

void sync ( void  )

POSIX Sync all pending file changes and metadata on ALL files.

  • man page sync (2).
Returns
void.

Definition at line 1058 of file posix.c.

Here is the call graph for this function:

◆ syncfs()

int syncfs ( int  fd)

POSIX Sync pending file changes and metadata for specified fileno.

  • man page syncfs (2).
Parameters
[in]fdPOSIX fileno to sync.
Returns
0.
-1 on error witrh errno set.

Definition at line 1085 of file posix.c.

Referenced by sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ truncate()

int truncate ( const char *  path,
off_t  length 
)

POSIX truncate named file to length.

  • man page truncate (2).
Parameters
[in]pathfile name to truncate.
[in]lengthlength to truncate to.
Returns
0 on sucess.
-1 n fail.

Definition at line 1131 of file posix.c.

Here is the call graph for this function:

◆ unix_time_to_fat()

void unix_time_to_fat ( time_t  epoch,
uint16_t *  date,
uint16_t *  time 
)

Convert Linux POSIX time_t to FAT32 date and time. NOT POSIX.

  • man page gmtime (3).
    Parameters
    [in]epochunix epoch seconds
    [in]*datefat32 date
    [in]*timefat32 time
    Returns
    void

Definition at line 2307 of file posix.c.

Referenced by utime().

Here is the caller graph for this function:

◆ unlink()

int unlink ( const char *  pathname)

POSIX delete a file.

  • man page unlink (2).
Parameters
[in]pathnamefilename to delete.
Returns
0 on sucess.
-1 on error with errno set.

Definition at line 1693 of file posix.c.

Referenced by HALSITL::SITL_State::_parse_command_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utime()

int utime ( const char *  filename,
const struct utimbuf *  times 
)

Set Modification and Access time of a file.

Parameters
[in]filenamefile name

Definition at line 1382 of file posix.c.

Here is the call graph for this function:

◆ write()

ssize_t write ( int  fd,
const void *  buf,
size_t  count 
)

POSIX Write count bytes from *buf to fileno fd.

  • man page write (2).
Parameters
[in]fdPOSIX fileno.
[in]bufbuffer.
[in]countnumber of bytes to write.
Returns
count on sucess.
-1 on error with errno set.

Definition at line 1169 of file posix.c.

Referenced by HALSITL::SITL_State::_gps_write(), PX4::PX4Storage::_mtd_write(), VRBRAIN::VRBRAINStorage::_mtd_write(), Linux::OpticalFlow_Onboard::_run_optflow(), PX4::PX4Storage::_storage_open(), VRBRAIN::VRBRAINStorage::_storage_open(), Linux::Storage::_timer_tick(), SITL::JSBSim::check_stdout(), SITL::JSBSim::expect(), Linux::RCOutput_Bebop::from(), fwrite(), Linux::CAN::getFileDescriptor(), ToneAlarm_PX4::play_string(), SITL::Vicon::update_vicon_position_estimate(), Linux::Poller::wakeup(), PX4::NSHShellStream::write(), VRBRAIN::NSHShellStream::write(), and ConsoleDevice::write().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ __iob

FILE* __iob[MAX_FILES]

POSIX fileno to POSIX FILE stream table.

  • Note: the index of __iob[] is reffered to "fileno".
  • Reference: libc/avr-libc-1.8.0/libc/stdio.
  • stdin = __iob[0].
  • __iob[1] = stdout.
  • __iob[2] = stderr.

Definition at line 128 of file posix.c.

Referenced by fatfs_to_fileno(), fileno(), fileno_to_stream(), free_file_descriptor(), and new_file_descriptor().

◆ _de

dirent_t _de
static

POSIX opendir.

  • man page readdir(2).
Parameters
[in]dirpDIR * directory handle
Returns
DIR * on sucess.
NULL on error with errno set.

Definition at line 1767 of file posix.c.

Referenced by readdir().

◆ _dp

DIR _dp
static

POSIX opendir.

  • man page opendir (2).
Parameters
[in]pathnamedirectory to delete.
Returns
DIR * on sucess.
NULL on error with errno set.

Definition at line 1748 of file posix.c.

◆ errno

int errno

Note: fdevopen assigns stdin,stdout,stderr.

POSIX errno.

Definition at line 118 of file posix.c.

Referenced by HALSITL::UARTDriver::_check_reconnect(), Linux::VideoIn::_dequeue_frame(), _kill(), VRBRAIN::VRBRAINStorage::_mtd_load(), PX4::PX4Storage::_mtd_load(), Linux::VideoIn::_queue_buffer(), Linux::VideoIn::_set_streaming(), HALSITL::SITL_State::_setup_fdm(), HALSITL::UARTDriver::_tcp_start_client(), HALSITL::UARTDriver::_tcp_start_connection(), Linux::VideoIn::allocate_buffers(), chdir(), chmod(), close(), closedir(), SITL::JSBSim::drain_control_socket(), SITL::Gazebo::drain_sockets(), fatfs_getc(), fatfs_putc(), fatfs_to_fileno(), fgetc(), fileno(), fileno_to_fatfs(), fileno_to_stream(), fputc(), free_file_descriptor(), fsync(), ftell(), ftruncate(), Linux::Util::get_hw_arm32(), getcwd(), Linux::RCInput_UART::init(), Linux::PWM_Sysfs_Base::init(), Linux::Scheduler::init(), Linux::RCInput_115200::init(), is_dir(), lseek(), Linux::Scheduler::microsleep(), mkdir(), mkdir_p(), new_file_descriptor(), Linux::WakeupPollable::on_can_read(), TCPServerDevice::open(), UARTDevice::open(), Linux::I2CBus::open(), Linux::SPIBus::open(), open(), Linux::VideoIn::open_device(), opendir(), perror(), Linux::Poller::poll(), Linux::RCInput_UART::RCInput_UART(), read(), Linux::Util::read_file(), readdir(), remove(), rename(), rmdir(), SITL::JSBSim::send_servos(), UARTDevice::set_blocking(), ConsoleDevice::set_blocking(), AnalogSource_Navio2::set_channel(), Linux::VideoIn::set_crop(), Linux::VideoIn::set_format(), SITL::Gazebo::set_interface_ports(), stat(), syncfs(), Linux::SPIDevice::transfer(), Linux::SPIDevice::transfer_fullduplex(), truncate(), unlink(), Linux::Poller::wakeup(), write(), and Linux::Util::write_file().

◆ sys_errlist

const char* sys_errlist[]

POSIX error messages for each errno value.

  • man page errno (3)

Definition at line 133 of file posix.c.

Referenced by __wrap_strerror_r(), perror(), and strerror().