ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
posix.h File Reference

POSIX wrapper for FatFS. More...

Go to the source code of this file.

Data Structures

struct  stat
 POSIX stat structure. More...
 
struct  utimbuf
 POSIX utimbuf structure. More...
 
struct  dirent
 
struct  __file
 FILE type structure. More...
 

Macros

#define POSIX
 
#define MAX_NAME_LEN   13
 
#define lstat   stat
 POSIX lstat() More...
 
#define __SRD   0x0001 /* OK to read */
 
#define __SWR   0x0002 /* OK to write */
 
#define __SSTR   0x0004 /* this is an sprintf/snprintf string */
 
#define __SPGM   0x0008 /* fmt string is in progmem */
 
#define __SERR   0x0010 /* found error */
 
#define __SEOF   0x0020 /* found EOF */
 
#define __SUNGET   0x040 /* ungetc() happened */
 
#define __SMALLOC   0x80 /* handle is malloc()ed */
 
#define O_ACCMODE   00000003 /*< read, write, read-write modes */
 POSIX open modes - no other combination are allowed. More...
 
#define O_RDONLY   00000000 /*< Read only */
 
#define O_WRONLY   00000001 /*< Write only */
 
#define O_RDWR   00000002 /*< Read/Write */
 
#define O_CREAT   00000100 /*< Create file only if it does not exist */
 
#define O_EXCL
 
#define O_NOCTTY   00000400 /*< @todo */
 
#define O_TRUNC   00001000 /*< Truncate if exists */
 
#define O_APPEND   00002000 /*< All writes are to EOF */
 
#define O_NONBLOCK   00004000 /*< @todo */
 
#define O_BINARY   00000004 /*< Binary */
 
#define O_TEXT   00000004 /*< Text End Of Line translation */
 
#define S_IFMT   0170000 /*< These bits determine file type. */
 POSIX File types, see fstat and stat. More...
 
#define S_IFDIR   0040000 /*< Directory. */
 
#define S_IFCHR   0020000 /*< Character device. */
 
#define S_IFBLK   0060000 /*< Block device. */
 
#define S_IFREG   0100000 /*< Regular file. */
 
#define S_IFIFO   0010000 /*< FIFO. */
 
#define S_IFLNK   0120000 /*< Symbolic link. */
 
#define S_IFSOCK   0140000 /*< Socket. */
 
#define S_IREAD   0400 /*< Read by owner. */
 
#define S_IWRITE   0200 /*< Write by owner. */
 
#define S_IEXEC   0100 /*< Execute by owner. */
 
#define S_ISTYPE(mode, mask)   (((mode) & S_IFMT) == (mask))
 POSIX File type test macros. More...
 
#define S_ISDIR(mode)   S_ISTYPE((mode), S_IFDIR)
 
#define S_ISCHR(mode)   S_ISTYPE((mode), S_IFCHR)
 
#define S_ISBLK(mode)   S_ISTYPE((mode), S_IFBLK)
 
#define S_ISREG(mode)   S_ISTYPE((mode), S_IFREG)
 
#define S_IRUSR   S_IREAD /*< Read by owner. */
 
#define S_IWUSR   S_IWRITE /*< Write by owner. */
 
#define S_IXUSR   S_IEXEC /*< Execute by owner. */
 
#define S_IRWXU   (S_IREAD|S_IWRITE|S_IEXEC) /*< Read,Write,Execute by owner */
 
#define S_IRGRP   (S_IRUSR >> 3) /*< Read by group. */
 
#define S_IWGRP   (S_IWUSR >> 3) /*< Write by group. */
 
#define S_IXGRP   (S_IXUSR >> 3) /*< Execute by group. */
 
#define S_IRWXG   (S_IRWXU >> 3) /*< Read,Write,Execute by user */
 
#define S_IROTH   (S_IRGRP >> 3) /*< Read by others. */
 
#define S_IWOTH   (S_IWGRP >> 3) /*< Write by others. */
 
#define S_IXOTH   (S_IXGRP >> 3) /*< Execute by others. */
 
#define S_IRWXO   (S_IRWXG >> 3) /*< Read,Write,Execute by other */
 
#define modecmp(str, pat)   (strcmp(str, pat) == 0 ? 1: 0)
 used in posix.c to compare to ascii file modes More...
 
#define FATFS_R   (S_IRUSR | S_IRGRP | S_IROTH) /*< FatFs Read perms */
 FATFS open modes. More...
 
#define FATFS_W   (S_IWUSR | S_IWGRP | S_IWOTH) /*< FatFs Write perms */
 
#define FATFS_X   (S_IXUSR | S_IXGRP | S_IXOTH) /*< FatFs Execute perms */
 
#define EOF   (-1)
 End of file or device read. More...
 
#define SEEK_SET   0
 Seek offset macros. More...
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 
#define MAX_FILES   16
 Maximum number of POSIX file handles. More...
 
#define stdin   (__iob[0])
 define stdin, stdout and stderr More...
 
#define stdout   (__iob[1])
 
#define stderr   (__iob[2])
 
#define fdev_set_udata(stream, u)   do { (stream)->udata = u; } while(0)
 device IO udata More...
 
#define fdev_get_udata(stream)   ((stream)->udata)
 
#define _FDEV_EOF   (-1)
 device status flags More...
 
#define _FDEV_ERR   (-2)
 
#define _FDEV_SETUP_READ   __SRD
 
#define _FDEV_SETUP_WRITE   __SWR
 
#define _FDEV_SETUP_RW   (__SRD|__SWR)
 

Typedefs

typedef uint32_t dev_t
 make sure we use our EDOM and ERANGE values More...
 
typedef uint32_t ino_t
 
typedef uint32_t mode_t
 
typedef uint32_t nlink_t
 
typedef uint16_t uid_t
 
typedef uint16_t gid_t
 
typedef uint32_t off_t
 
typedef uint32_t blkcnt_t
 
typedef uint32_t blksize_t
 
typedef uint32_t time_t
 
typedef int32_t ssize_t
 
typedef struct utimbuf utime_t
 POSIX utimbuf structure. More...
 
typedef struct dirent dirent_t
 
typedef struct __file FILE
 define FILE type More...
 

Enumerations

enum  POSIX_errno {
  EOK, EPERM, ENOENT, ESRCH,
  EINTR, EIO, ENXIO, E2BIG,
  ENOEXEC, EBADF, ECHILD, EAGAIN,
  ENOMEM, EACCES, EFAULT, ENOTBLK,
  EBUSY, EEXIST, EXDEV, ENODEV,
  ENOTDIR, EISDIR, EINVAL, ENFILE,
  EMFILE, ENOTTY, ETXTBSY, EFBIG,
  ENOSPC, ESPIPE, EROFS, EMLINK,
  EPIPE, EDOM, ERANGE, EBADMSG
}
 

Functions

MEMSPACE int isatty (int fileno)
 Test POSIX fileno if it is a Serial Console/TTY. More...
 
MEMSPACE 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...
 
MEMSPACE 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...
 
MEMSPACE int getchar (void)
 functions normally defined as macros More...
 
MEMSPACE int putchar (int c)
 put a character to stdout See fdevopen() sets stream->put get for TTY devices More...
 
MEMSPACE int ungetc (int c, FILE *stream)
 Un-Get byte from a TTY device or FatFs file stream. More...
 
MEMSPACE int putc (int c, FILE *stream)
 Put a character to a stream See fdevopen() sets stream->put get for TTY devices. More...
 
MEMSPACE char * fgets (char *str, int size, FILE *stream)
 get a string from stdin See fdevopen() sets stream->put get for TTY devices More...
 
MEMSPACE int fputs (const char *str, FILE *stream)
 put a string to stdout See fdevopen() sets stream->put get for TTY devices More...
 
MEMSPACE int puts (const char *str)
 put a string to stdout See fdevopen() sets stream->put get for TTY devices More...
 
MEMSPACE int feof (FILE *stream)
 feof reports if the stream is at EOF More...
 
MEMSPACE int fgetpos (FILE *stream, size_t *pos)
 POSIX get position of file stream. More...
 
MEMSPACE int fseek (FILE *stream, long offset, int whence)
 POSIX seek to file possition. More...
 
MEMSPACE int fsetpos (FILE *stream, size_t *pos)
 POSIX set position of file stream. More...
 
MEMSPACE long ftell (FILE *stream)
 POSIX file position of open stream. More...
 
MEMSPACE off_t lseek (int fileno, off_t position, int whence)
 POSIX seek to file position. More...
 
MEMSPACE void rewind (FILE *stream)
 POSIX rewind file to the beginning. More...
 
MEMSPACE int close (int fileno)
 POSIX Close a file with fileno handel. More...
 
MEMSPACE int fileno (FILE *stream)
 Convert POSIX stream pointer to POSIX fileno (index of __iob[]) More...
 
MEMSPACE FILEfileno_to_stream (int fileno)
 Convert POSIX fileno to POSIX FILE stream pointer. NOT POSIX. More...
 
MEMSPACE FILEfopen (const char *path, const char *mode)
 POSIX Open a file with path name and ascii file mode string. More...
 
MEMSPACE size_t 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...
 
MEMSPACE int ftruncate (int fd, off_t length)
 POSIX truncate open file to length. More...
 
MEMSPACE 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...
 
MEMSPACE int open (const char *pathname, int flags)
 POSIX Open a file with integer mode flags. More...
 
MEMSPACE ssize_t read (int fd, const void *buf, size_t count)
 POSIX read count bytes from *buf to fileno fd. More...
 
MEMSPACE void sync (void)
 POSIX Sync all pending file changes and metadata on ALL files. More...
 
MEMSPACE int syncfs (int fd)
 POSIX Sync pending file changes and metadata for specified fileno. More...
 
MEMSPACE int truncate (const char *path, off_t length)
 POSIX truncate named file to length. More...
 
MEMSPACE ssize_t write (int fd, const void *buf, size_t count)
 POSIX Write count bytes from *buf to fileno fd. More...
 
MEMSPACE int fclose (FILE *stream)
 POSIX close a file stream. More...
 
MEMSPACE void dump_stat (struct stat *sp)
 Display struct stat, from POSIX stat(0 or fstat(), in ASCII. NOT POSIX. More...
 
MEMSPACE char * mctime (time_t timev)
 Display Ascii formatted time from timev seconds NOT POSIX. More...
 
MEMSPACE int stat (char *name, struct stat *buf)
 POSIX stat - get file status of named file. More...
 
MEMSPACE char * basename (char *str)
 POSIX Basename of filename. More...
 
MEMSPACE char * baseext (char *str)
 File extention of a file name. NOT POSIX. More...
 
MEMSPACE int chdir (const char *pathname)
 POSIX change directory. More...
 
MEMSPACE 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...
 
MEMSPACE int dirname (char *str)
 POSIX directory name of a filename. Return the index of the last '/' character. More...
 
MEMSPACE int utime (const char *filename, const struct utimbuf *times)
 Set Modification and Access time of a file. More...
 
MEMSPACE char * getcwd (char *pathname, int len)
 POSIX get current working directory. More...
 
MEMSPACE int mkdir (const char *pathname, mode_t mode)
 POSIX make a directory. More...
 
MEMSPACE int rename (const char *oldpath, const char *newpath)
 POSIX rename a file by name. More...
 
MEMSPACE int rmdir (const char *pathname)
 POSIX delete a directory. More...
 
MEMSPACE int unlink (const char *pathname)
 POSIX delete a file. More...
 
int closedir (DIR *dirp)
 POSIX closedir. More...
 
DIRopendir (const char *pathdir)
 
struct direntreaddir (DIR *dirp)
 
MEMSPACE void clrerror (FILE *stream)
 clrerror resets stream EOF and error flags More...
 
MEMSPACE int ferror (FILE *stream)
 ferror reports if the stream has an error flag set More...
 
MEMSPACE void perror (const char *s)
 POSIX perror() - convert POSIX errno to text with user message. More...
 
MEMSPACE char WEAK_ATRstrerror (int errnum)
 POSIX strerror() - convert POSIX errno to text with user message. More...
 
MEMSPACE char * strerror_r (int errnum, char *buf, size_t buflen)
 POSIX strerror_r() - convert POSIX errno to text with user message. More...
 
MEMSPACE FILEfdevopen (int(*put)(char, FILE *), int(*get)(FILE *))
 Device open functions. More...
 
MEMSPACE int mkfs (char *name)
 Formt SD card. More...
 
MEMSPACE int fatfs_getc (FILE *stream)
 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() More...
 
MEMSPACE 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...
 
MEMSPACE int fatfs_to_errno (FRESULT Result)
 Convert FafFs error result to POSIX errno. NOT POSIX. More...
 
MEMSPACE int fatfs_to_fileno (FIL *fh)
 Convert FatFS file handle to POSIX fileno. NOT POSIX. More...
 
MEMSPACE 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...
 
MEMSPACE 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...
 
MEMSPACE FILfileno_to_fatfs (int fileno)
 Convert POSIX fileno to FatFS handle NOT POSIX. More...
 
MEMSPACE int free_file_descriptor (int fileno)
 Free POSIX fileno FILE descriptor. NOT POSIX. More...
 
MEMSPACE int new_file_descriptor (void)
 Allocate a POSIX FILE descriptor. NOT POSIX. More...
 
MEMSPACE int posix_fopen_modes_to_open (const char *mode)
 Convert POSIX fopen mode to POSIX open mode flags. NOT POSIX. More...
 
MEMSPACE int fprintf (FILE *fp, const char *format,...)
 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 More...
 

Variables

FILE__iob [MAX_FILES]
 POSIX fileno to POSIX FILE stream table. More...
 

Detailed Description

POSIX wrapper for FatFS.

Copyright © 2014-2017 Mike Gore, All rights reserved. GPL License
See also
http://github.com/magore/hp85disk
http://github.com/magore/hp85disk/COPYRIGHT.md for specific Copyright details
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.h.

Macro Definition Documentation

#define __SEOF   0x0020 /* found EOF */

Definition at line 165 of file posix.h.

Referenced by clrerror(), fatfs_getc(), fatfs_putc(), feof(), fgetc(), and ungetc().

#define __SERR   0x0010 /* found error */

Definition at line 164 of file posix.h.

Referenced by clrerror(), ferror(), and fgetc().

#define __SMALLOC   0x80 /* handle is malloc()ed */

Definition at line 167 of file posix.h.

Referenced by fdevopen(), and free_file_descriptor().

#define __SPGM   0x0008 /* fmt string is in progmem */

Definition at line 163 of file posix.h.

#define __SRD   0x0001 /* OK to read */

Definition at line 160 of file posix.h.

Referenced by fdevopen(), fgetc(), and ungetc().

#define __SSTR   0x0004 /* this is an sprintf/snprintf string */

Definition at line 162 of file posix.h.

Referenced by fgetc(), and fputc().

#define __SUNGET   0x040 /* ungetc() happened */

Definition at line 166 of file posix.h.

Referenced by fgetc(), lseek(), read(), syncfs(), and ungetc().

#define __SWR   0x0002 /* OK to write */

Definition at line 161 of file posix.h.

Referenced by fdevopen(), and fputc().

#define _FDEV_EOF   (-1)

device status flags

Definition at line 295 of file posix.h.

#define _FDEV_ERR   (-2)

Definition at line 296 of file posix.h.

Referenced by fgetc().

#define _FDEV_SETUP_READ   __SRD

fdev_setup_stream() with read intent

Definition at line 298 of file posix.h.

Referenced by open().

#define _FDEV_SETUP_RW   (__SRD|__SWR)

fdev_setup_stream() with read/write intent

Definition at line 300 of file posix.h.

Referenced by open().

#define _FDEV_SETUP_WRITE   __SWR

fdev_setup_stream() with write intent

Definition at line 299 of file posix.h.

Referenced by open().

#define EOF   (-1)

End of file or device read.

Definition at line 248 of file posix.h.

Referenced by buffer_getc(), buffer_gets(), fatfs_getc(), fatfs_putc(), fclose(), fgetc(), fgets(), fputc(), fputs(), putc_flush(), puts(), and ungetc().

#define FATFS_R   (S_IRUSR | S_IRGRP | S_IROTH) /*< FatFs Read perms */

FATFS open modes.

Definition at line 242 of file posix.h.

Referenced by stat().

#define FATFS_W   (S_IWUSR | S_IWGRP | S_IWOTH) /*< FatFs Write perms */

Definition at line 243 of file posix.h.

Referenced by stat().

#define FATFS_X   (S_IXUSR | S_IXGRP | S_IXOTH) /*< FatFs Execute perms */

Definition at line 244 of file posix.h.

Referenced by stat().

#define fdev_get_udata (   stream)    ((stream)->udata)
#define fdev_set_udata (   stream,
 
)    do { (stream)->udata = u; } while(0)

device IO udata

Definition at line 291 of file posix.h.

Referenced by new_file_descriptor().

#define lstat   stat

POSIX lstat()

See also
stat()

Definition at line 153 of file posix.h.

#define MAX_FILES   16

Maximum number of POSIX file handles.

Definition at line 260 of file posix.h.

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

#define MAX_NAME_LEN   13

Definition at line 133 of file posix.h.

Referenced by ls().

#define modecmp (   str,
  pat 
)    (strcmp(str, pat) == 0 ? 1: 0)

used in posix.c to compare to ascii file modes

Definition at line 238 of file posix.h.

Referenced by posix_fopen_modes_to_open().

#define O_ACCMODE   00000003 /*< read, write, read-write modes */

POSIX open modes - no other combination are allowed.

  • man page open(2)
  • Note: The POSIX correct test of O_RDONLY is: (mode & O_ACCMODE) == O_RDONLY.

Definition at line 186 of file posix.h.

Referenced by open().

#define O_APPEND   00002000 /*< All writes are to EOF */

Definition at line 195 of file posix.h.

Referenced by open(), and posix_fopen_modes_to_open().

#define O_BINARY   00000004 /*< Binary */

Definition at line 197 of file posix.h.

#define O_CREAT   00000100 /*< Create file only if it does not exist */

Definition at line 190 of file posix.h.

Referenced by open(), and posix_fopen_modes_to_open().

#define O_EXCL
Value:
00000200 /*< O_CREAT option, Create fails if file exists
*/

Definition at line 191 of file posix.h.

#define O_NOCTTY   00000400 /*< @todo */

Definition at line 193 of file posix.h.

#define O_NONBLOCK   00004000 /*< @todo */

Definition at line 196 of file posix.h.

#define O_RDONLY   00000000 /*< Read only */

Definition at line 187 of file posix.h.

Referenced by open(), and posix_fopen_modes_to_open().

#define O_RDWR   00000002 /*< Read/Write */

Definition at line 189 of file posix.h.

Referenced by open(), and posix_fopen_modes_to_open().

#define O_TEXT   00000004 /*< Text End Of Line translation */

Definition at line 198 of file posix.h.

#define O_TRUNC   00001000 /*< Truncate if exists */

Definition at line 194 of file posix.h.

Referenced by open(), and posix_fopen_modes_to_open().

#define O_WRONLY   00000001 /*< Write only */

Definition at line 188 of file posix.h.

Referenced by posix_fopen_modes_to_open().

#define POSIX

Definition at line 30 of file posix.h.

#define S_IEXEC   0100 /*< Execute by owner. */

Definition at line 211 of file posix.h.

#define S_IFBLK   0060000 /*< Block device. */

Definition at line 204 of file posix.h.

#define S_IFCHR   0020000 /*< Character device. */

Definition at line 203 of file posix.h.

#define S_IFDIR   0040000 /*< Directory. */

Definition at line 202 of file posix.h.

Referenced by ls(), and stat().

#define S_IFIFO   0010000 /*< FIFO. */

Definition at line 206 of file posix.h.

#define S_IFLNK   0120000 /*< Symbolic link. */

Definition at line 207 of file posix.h.

#define S_IFMT   0170000 /*< These bits determine file type. */

POSIX File types, see fstat and stat.

Definition at line 201 of file posix.h.

Referenced by ls().

#define S_IFREG   0100000 /*< Regular file. */

Definition at line 205 of file posix.h.

Referenced by ls(), and stat().

#define S_IFSOCK   0140000 /*< Socket. */

Definition at line 208 of file posix.h.

#define S_IREAD   0400 /*< Read by owner. */

Definition at line 209 of file posix.h.

#define S_IRGRP   (S_IRUSR >> 3) /*< Read by group. */

Definition at line 226 of file posix.h.

#define S_IROTH   (S_IRGRP >> 3) /*< Read by others. */

Definition at line 231 of file posix.h.

#define S_IRUSR   S_IREAD /*< Read by owner. */

Definition at line 221 of file posix.h.

#define S_IRWXG   (S_IRWXU >> 3) /*< Read,Write,Execute by user */

Definition at line 229 of file posix.h.

#define S_IRWXO   (S_IRWXG >> 3) /*< Read,Write,Execute by other */

Definition at line 234 of file posix.h.

#define S_IRWXU   (S_IREAD|S_IWRITE|S_IEXEC) /*< Read,Write,Execute by owner */

Definition at line 224 of file posix.h.

#define S_ISBLK (   mode)    S_ISTYPE((mode), S_IFBLK)

Definition at line 217 of file posix.h.

#define S_ISCHR (   mode)    S_ISTYPE((mode), S_IFCHR)

Definition at line 216 of file posix.h.

#define S_ISDIR (   mode)    S_ISTYPE((mode), S_IFDIR)

Definition at line 215 of file posix.h.

Referenced by dump_stat(), and ls_info().

#define S_ISREG (   mode)    S_ISTYPE((mode), S_IFREG)

Definition at line 218 of file posix.h.

Referenced by dump_stat().

#define S_ISTYPE (   mode,
  mask 
)    (((mode) & S_IFMT) == (mask))

POSIX File type test macros.

Definition at line 214 of file posix.h.

#define S_IWGRP   (S_IWUSR >> 3) /*< Write by group. */

Definition at line 227 of file posix.h.

Referenced by chmod().

#define S_IWOTH   (S_IWGRP >> 3) /*< Write by others. */

Definition at line 232 of file posix.h.

Referenced by chmod().

#define S_IWRITE   0200 /*< Write by owner. */

Definition at line 210 of file posix.h.

#define S_IWUSR   S_IWRITE /*< Write by owner. */

Definition at line 222 of file posix.h.

Referenced by chmod().

#define S_IXGRP   (S_IXUSR >> 3) /*< Execute by group. */

Definition at line 228 of file posix.h.

#define S_IXOTH   (S_IXGRP >> 3) /*< Execute by others. */

Definition at line 233 of file posix.h.

#define S_IXUSR   S_IEXEC /*< Execute by owner. */

Definition at line 223 of file posix.h.

#define SEEK_CUR   1

Definition at line 252 of file posix.h.

Referenced by lseek().

#define SEEK_END   2

Definition at line 253 of file posix.h.

Referenced by lseek().

#define SEEK_SET   0

Seek offset macros.

Definition at line 251 of file posix.h.

Referenced by fsetpos(), and rewind().

#define stderr   (__iob[2])

Definition at line 271 of file posix.h.

Referenced by db_calloc(), escape(), fdevopen(), fputc(), main(), read(), ReadBdf(), send_message(), and write().

#define stdin   (__iob[0])

define stdin, stdout and stderr

Definition at line 269 of file posix.h.

Referenced by fdevopen(), getchar(), read(), setdate(), upload(), user_tasks(), and write().

#define stdout   (__iob[1])

Definition at line 270 of file posix.h.

Referenced by fatfs_ls(), fdevopen(), fputc(), main(), putchar(), puts(), read(), timetests(), and write().

Typedef Documentation

typedef uint32_t blkcnt_t

Definition at line 52 of file posix.h.

Definition at line 53 of file posix.h.

typedef uint32_t dev_t

make sure we use our EDOM and ERANGE values

Standard POSIX typedefs.

  • Using these makes code portable accross many acrchitectures

Definition at line 45 of file posix.h.

typedef struct dirent dirent_t

Definition at line 147 of file posix.h.

typedef struct __file FILE

define FILE type

Definition at line 257 of file posix.h.

typedef uint16_t gid_t

Definition at line 50 of file posix.h.

typedef uint32_t ino_t

Definition at line 46 of file posix.h.

typedef uint32_t mode_t

Definition at line 47 of file posix.h.

typedef uint32_t nlink_t

Definition at line 48 of file posix.h.

typedef uint32_t off_t

Definition at line 51 of file posix.h.

typedef int32_t ssize_t

Definition at line 55 of file posix.h.

typedef uint32_t time_t

Definition at line 54 of file posix.h.

typedef uint16_t uid_t

Definition at line 49 of file posix.h.

typedef struct utimbuf utime_t

POSIX utimbuf structure.

See also
utime()

Enumeration Type Documentation

Enumerator
EOK 
EPERM 
ENOENT 
ESRCH 
EINTR 
EIO 
ENXIO 
E2BIG 
ENOEXEC 
EBADF 
ECHILD 
EAGAIN 
ENOMEM 
EACCES 
EFAULT 
ENOTBLK 
EBUSY 
EEXIST 
EXDEV 
ENODEV 
ENOTDIR 
EISDIR 
EINVAL 
ENFILE 
EMFILE 
ENOTTY 
ETXTBSY 
EFBIG 
ENOSPC 
ESPIPE 
EROFS 
EMLINK 
EPIPE 
EDOM 
ERANGE 
EBADMSG 

Definition at line 61 of file posix.h.

Function Documentation

MEMSPACE 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 1466 of file posix.c.

MEMSPACE char* basename ( 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.

Referenced by FontHeaderInfo(), ls_info(), and main().

MEMSPACE 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 1488 of file posix.c.

Referenced by posix_tests().

MEMSPACE 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 1513 of file posix.c.

Referenced by mkdir(), and posix_tests().

MEMSPACE 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 685 of file posix.c.

Referenced by fclose(), and send_message().

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 1717 of file posix.c.

Referenced by ls().

MEMSPACE 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 1786 of file posix.c.

MEMSPACE int dirname ( char *  str)

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

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

Definition at line 1551 of file posix.c.

MEMSPACE void dump_stat ( struct stat sp)

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

  • POSIX file information functions
    Parameters
    [in]spstruct stat pointer.
    Returns
    void.

Definition at line 1260 of file posix.c.

Referenced by posix_tests().

MEMSPACE 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 2227 of file posix.c.

Referenced by stat().

MEMSPACE int fatfs_getc ( FILE stream)

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 1984 of file posix.c.

Referenced by open().

MEMSPACE 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 2074 of file posix.c.

Referenced by fputc(), and open().

MEMSPACE 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 2114 of file posix.c.

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

MEMSPACE 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 2190 of file posix.c.

MEMSPACE int 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 1239 of file posix.c.

Referenced by buffer_read_close(), cat(), copy(), hexdump(), logfile(), main(), MatRead(), MatWrite(), ReadBdf(), sum(), timetests(), and upload().

MEMSPACE 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]*putputc function pointer
[in]*getgutc function pointer

Definition at line 1876 of file posix.c.

MEMSPACE 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 505 of file posix.c.

MEMSPACE 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 1798 of file posix.c.

MEMSPACE 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 216 of file posix.c.

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

MEMSPACE 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 522 of file posix.c.

MEMSPACE 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 420 of file posix.c.

Referenced by cat(), main(), MatRead(), ReadBdf(), setdate(), upload(), and user_tasks().

MEMSPACE 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 724 of file posix.c.

Referenced by fclose(), fileno(), fileno_to_stream(), fopen(), fread(), free_file_descriptor(), fseek(), ftell(), fwrite(), open(), and ungetc().

MEMSPACE 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 2276 of file posix.c.

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

MEMSPACE 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 754 of file posix.c.

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

MEMSPACE 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 782 of file posix.c.

Referenced by buffer_read_open(), cat(), copy(), hexdump(), logfile(), main(), MatRead(), MatWrite(), ReadBdf(), sum(), timetests(), and upload().

MEMSPACE int fprintf ( FILE fp,
const char *  format,
  ... 
)

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

Parameters
[in]*fpFILE stream pointer
[in]fmtprintf forat string
[in]...vararg list or arguments
Returns
size of printed result

Definition at line 2484 of file posix.c.

Referenced by Convert_Font2c(), db_calloc(), emit_data(), emit_number(), emit_str(), escape(), FontHeaderInfo(), FontPreview(), FontPreviewFull(), FontPreviewProportional(), get_date(), main(), MatWrite(), ReadBdf(), send_message(), timetests(), WriteCharacterBits(), WriteFontBits(), WriteFontBitsPreview(), WriteFontInfo(), and WriteFontTable().

MEMSPACE 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 278 of file posix.c.

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

MEMSPACE 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 457 of file posix.c.

MEMSPACE size_t 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 803 of file posix.c.

Referenced by buffer_getc(), copy(), hexdump(), main(), and sum().

MEMSPACE 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 2311 of file posix.c.

Referenced by close(), and open().

MEMSPACE 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 545 of file posix.c.

Referenced by fsetpos(), and rewind().

MEMSPACE 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 571 of file posix.c.

MEMSPACE 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 585 of file posix.c.

Referenced by fgetpos().

MEMSPACE 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 827 of file posix.c.

MEMSPACE 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 868 of file posix.c.

Referenced by copy(), logfile(), main(), and upload().

MEMSPACE int getchar ( void  )

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 336 of file posix.c.

Referenced by testpage().

MEMSPACE 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 1596 of file posix.c.

Referenced by ls(), main(), and posix_tests().

MEMSPACE 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 196 of file posix.c.

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

MEMSPACE 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 617 of file posix.c.

Referenced by fseek().

MEMSPACE char* mctime ( time_t  timev)

Display Ascii formatted time from timev seconds NOT POSIX.

  • Assumes no timezone offset.
  • man page ctime (3).
Parameters
[in]timevepoch time in seconds
Returns
ascii string pointer of POSIX ctime()
See also
ctime()

Definition at line 1323 of file posix.c.

Referenced by dump_stat(), and ls_info().

MEMSPACE 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 1619 of file posix.c.

Referenced by posix_tests().

MEMSPACE int mkfs ( char *  name)

Formt SD card.

  • FatFS to POSIX bridge functions
    Parameters
    [in]*namedevice name void

Definition at line 1922 of file posix.c.

Referenced by posix_tests().

MEMSPACE 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 2355 of file posix.c.

Referenced by open().

MEMSPACE 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 895 of file posix.c.

Referenced by fopen().

DIR* opendir ( const char *  pathdir)

Definition at line 1736 of file posix.c.

Referenced by ls().

MEMSPACE 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 1814 of file posix.c.

Referenced by escape(), send_message(), and timetests().

MEMSPACE 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 2418 of file posix.c.

Referenced by fopen().

MEMSPACE int putc ( int  c,
FILE stream 
)

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 401 of file posix.c.

MEMSPACE 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 351 of file posix.c.

MEMSPACE 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 480 of file posix.c.

Referenced by cat().

MEMSPACE ssize_t read ( int  fd,
const 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 1006 of file posix.c.

Referenced by fread(), rx_fifo_read(), and send_message().

struct dirent* readdir ( DIR dirp)

Definition at line 1755 of file posix.c.

Referenced by ls().

MEMSPACE 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.

Referenced by posix_tests().

MEMSPACE void rewind ( FILE stream)

POSIX rewind file to the beginning.

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

Definition at line 666 of file posix.c.

MEMSPACE 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.

Referenced by posix_tests().

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

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 1344 of file posix.c.

Referenced by f_getfree(), f_mkfs(), find_volume(), ls(), ls_info(), main(), and posix_tests().

MEMSPACE char WEAK_ATR* strerror ( int  errnum)

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

  • man page strerror (3).
Parameters
[in]errnumindex for sys_errlist[]
See also
sys_errlist[].
Returns
char *

Definition at line 1840 of file posix.c.

MEMSPACE char* 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 1857 of file posix.c.

MEMSPACE void sync ( void  )

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

  • man page sync (2).
Returns
void.

Definition at line 1069 of file posix.c.

Referenced by upload().

MEMSPACE 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 1096 of file posix.c.

Referenced by sync().

MEMSPACE 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 1142 of file posix.c.

MEMSPACE int ungetc ( 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.

Definition at line 368 of file posix.c.

MEMSPACE 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 2252 of file posix.c.

Referenced by utime().

MEMSPACE 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 posix_tests().

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

Set Modification and Access time of a file.

Parameters
[in]filenamefile name

Definition at line 1407 of file posix.c.

MEMSPACE 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 1180 of file posix.c.

Referenced by fwrite(), and send_message().

Variable Documentation

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 139 of file posix.c.