131 #define MAX_NAME_LEN _MAX_LFN 133 #define MAX_NAME_LEN 13 140 unsigned short d_reclen;
141 unsigned char d_type;
162 #define __SSTR 0x0004 163 #define __SPGM 0x0008 164 #define __SERR 0x0010 165 #define __SEOF 0x0020 166 #define __SUNGET 0x040 167 #define __SMALLOC 0x80 171 #define __SLBF 0x0200 172 #define __SNBF 0x0400 173 #define __SMBF 0x0800 186 #define O_ACCMODE 00000003 187 #define O_RDONLY 00000000 188 #define O_WRONLY 00000001 189 #define O_RDWR 00000002 190 #define O_CREAT 00000100 191 #define O_EXCL 00000200 193 #define O_NOCTTY 00000400 194 #define O_TRUNC 00001000 195 #define O_APPEND 00002000 196 #define O_NONBLOCK 00004000 197 #define O_BINARY 00000004 198 #define O_TEXT 00000004 201 #define S_IFMT 0170000 202 #define S_IFDIR 0040000 203 #define S_IFCHR 0020000 204 #define S_IFBLK 0060000 205 #define S_IFREG 0100000 206 #define S_IFIFO 0010000 207 #define S_IFLNK 0120000 208 #define S_IFSOCK 0140000 210 #define S_IWRITE 0200 214 #define S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask)) 215 #define S_ISDIR(mode) S_ISTYPE((mode), S_IFDIR) 216 #define S_ISCHR(mode) S_ISTYPE((mode), S_IFCHR) 217 #define S_ISBLK(mode) S_ISTYPE((mode), S_IFBLK) 218 #define S_ISREG(mode) S_ISTYPE((mode), S_IFREG) 221 #define S_IRUSR S_IREAD 222 #define S_IWUSR S_IWRITE 223 #define S_IXUSR S_IEXEC 224 #define S_IRWXU (S_IREAD|S_IWRITE|S_IEXEC) 226 #define S_IRGRP (S_IRUSR >> 3) 227 #define S_IWGRP (S_IWUSR >> 3) 228 #define S_IXGRP (S_IXUSR >> 3) 229 #define S_IRWXG (S_IRWXU >> 3) 231 #define S_IROTH (S_IRGRP >> 3) 232 #define S_IWOTH (S_IWGRP >> 3) 233 #define S_IXOTH (S_IXGRP >> 3) 234 #define S_IRWXO (S_IRWXG >> 3) 238 #define modecmp(str, pat) (strcmp(str, pat) == 0 ? 1: 0) 242 #define FATFS_R (S_IRUSR | S_IRGRP | S_IROTH) 243 #define FATFS_W (S_IWUSR | S_IWGRP | S_IWOTH) 244 #define FATFS_X (S_IXUSR | S_IXGRP | S_IXOTH) 269 #define stdin (__iob[0]) 270 #define stdout (__iob[1]) 271 #define stderr (__iob[2]) 276 #define putc(__c, __stream) fputc(__c, __stream) 280 #define getc(__stream) fgetc(__stream) 284 #define putchar(__c) fputc(__c,stdout) 286 #define puts(__str) fputs(__str,stdout) 291 #define fdev_set_udata(stream, u) do { (stream)->udata = u; } while(0) 292 #define fdev_get_udata(stream) ((stream)->udata) 295 #define _FDEV_EOF (-1) 296 #define _FDEV_ERR (-2) 298 #define _FDEV_SETUP_READ __SRD 299 #define _FDEV_SETUP_WRITE __SWR 300 #define _FDEV_SETUP_RW (__SRD|__SWR) 302 // ============================================= 364 MEMSPACE int rename (
const char *oldpath ,
const char *newpath );
struct dirent * readdir(DIR *dirp)
MEMSPACE int fatfs_to_fileno(FIL *fh)
Convert FatFS file handle to POSIX fileno. NOT POSIX.
MEMSPACE int dirname(char *str)
POSIX directory name of a filename. Return the index of the last '/' character.
MEMSPACE int fsetpos(FILE *stream, size_t *pos)
POSIX set position of file stream.
MEMSPACE FILE * fdevopen(int(*put)(char, FILE *), int(*get)(FILE *))
Device open functions.
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 F...
MEMSPACE int fileno(FILE *stream)
Convert POSIX stream pointer to POSIX fileno (index of __iob[])
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.
FILE * __iob[MAX_FILES]
POSIX fileno to POSIX FILE stream table.
MEMSPACE void rewind(FILE *stream)
POSIX rewind file to the beginning.
DIR * opendir(const char *pathdir)
MEMSPACE int mkfs(char *name)
Formt SD card.
MEMSPACE int feof(FILE *stream)
feof reports if the stream is at EOF
MEMSPACE char * strerror_r(int errnum, char *buf, size_t buflen)
POSIX strerror_r() - convert POSIX errno to text with user message.
MEMSPACE int chmod(const char *pathname, mode_t mode)
POSIX chmod function - change file access permission Unfortunately file f_open modes and f_chmod mode...
uint32_t dev_t
make sure we use our EDOM and ERANGE values
MEMSPACE int fclose(FILE *stream)
POSIX close a file stream.
MEMSPACE int rename(const char *oldpath, const char *newpath)
POSIX rename a file by name.
MEMSPACE char * getcwd(char *pathname, int len)
POSIX get current working directory.
struct utimbuf utime_t
POSIX utimbuf structure.
MEMSPACE int new_file_descriptor(void)
Allocate a POSIX FILE descriptor. NOT POSIX.
MEMSPACE char * mctime(time_t timev)
Display Ascii formatted time from timev seconds NOT POSIX.
MEMSPACE int fputs(const char *str, FILE *stream)
put a string to stdout See fdevopen() sets stream->put get for TTY devices
MEMSPACE int putc(int c, FILE *stream)
Put a character to a stream See fdevopen() sets stream->put get for TTY devices.
MEMSPACE int syncfs(int fd)
POSIX Sync pending file changes and metadata for specified fileno.
MEMSPACE int puts(const char *str)
put a string to stdout See fdevopen() sets stream->put get for TTY devices
#define MAX_FILES
Maximum number of POSIX file handles.
MEMSPACE FIL * fileno_to_fatfs(int fileno)
Convert POSIX fileno to FatFS handle NOT POSIX.
MEMSPACE off_t lseek(int fileno, off_t position, int whence)
POSIX seek to file position.
MEMSPACE int fatfs_getc(FILE *stream)
Private FatFs function called by fgetc() to get a byte from file stream FIXME buffer this function ca...
MEMSPACE int ftruncate(int fd, off_t length)
POSIX truncate open file to length.
MEMSPACE int ungetc(int c, FILE *stream)
Un-Get byte from a TTY device or FatFs file stream.
MEMSPACE void dump_stat(struct stat *sp)
Display struct stat, from POSIX stat(0 or fstat(), in ASCII. NOT POSIX.
MEMSPACE void clrerror(FILE *stream)
clrerror resets stream EOF and error flags
MEMSPACE void sync(void)
POSIX Sync all pending file changes and metadata on ALL files.
MEMSPACE time_t time(time_t *t)
Return second from epoch - POSIX function.
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 stre...
MEMSPACE FILE * fileno_to_stream(int fileno)
Convert POSIX fileno to POSIX FILE stream pointer. NOT POSIX.
MEMSPACE int chdir(const char *pathname)
POSIX change directory.
MEMSPACE char * basename(char *str)
POSIX Basename of filename.
MEMSPACE int putchar(int c)
put a character to stdout See fdevopen() sets stream->put get for TTY devices
uint32_t time_t
type of EPOCH result.
MEMSPACE int fgetc(FILE *stream)
Get byte from a TTY device or FatFs file stream open() or fopen() sets stream->get = fatfs_getc() for...
MEMSPACE int fatfs_to_errno(FRESULT Result)
Convert FafFs error result to POSIX errno. NOT POSIX.
MEMSPACE int mkdir(const char *pathname, mode_t mode)
POSIX make a directory.
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.
MEMSPACE char WEAK_ATR * strerror(int errnum)
POSIX strerror() - convert POSIX errno to text with user message.
MEMSPACE int stat(char *name, struct stat *buf)
POSIX stat - get file status of named file.
MEMSPACE FILE * fopen(const char *path, const char *mode)
POSIX Open a file with path name and ascii file mode string.
MEMSPACE int isatty(int fileno)
Test POSIX fileno if it is a Serial Console/TTY.
MEMSPACE int fgetpos(FILE *stream, size_t *pos)
POSIX get position of file stream.
MEMSPACE int ferror(FILE *stream)
ferror reports if the stream has an error flag set
MEMSPACE char * baseext(char *str)
File extention of a file name. NOT POSIX.
MEMSPACE int open(const char *pathname, int flags)
POSIX Open a file with integer mode flags.
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 d...
MEMSPACE ssize_t read(int fd, const void *buf, size_t count)
POSIX read count bytes from *buf to fileno fd.
MEMSPACE int close(int fileno)
POSIX Close a file with fileno handel.
MEMSPACE int unlink(const char *pathname)
POSIX delete a file.
MEMSPACE int posix_fopen_modes_to_open(const char *mode)
Convert POSIX fopen mode to POSIX open mode flags. NOT POSIX.
MEMSPACE void perror(const char *s)
POSIX perror() - convert POSIX errno to text with user message.
MEMSPACE ssize_t write(int fd, const void *buf, size_t count)
POSIX Write count bytes from *buf to fileno fd.
MEMSPACE int utime(const char *filename, const struct utimbuf *times)
Set Modification and Access time of a file.
MEMSPACE int free_file_descriptor(int fileno)
Free POSIX fileno FILE descriptor. NOT POSIX.
MEMSPACE int truncate(const char *path, off_t length)
POSIX truncate named file to length.
MEMSPACE int getchar(void)
functions normally defined as macros
MEMSPACE int fseek(FILE *stream, long offset, int whence)
POSIX seek to file possition.
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.
int closedir(DIR *dirp)
POSIX closedir.
MEMSPACE char * fgets(char *str, int size, FILE *stream)
get a string from stdin See fdevopen() sets stream->put get for TTY devices
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.
MEMSPACE long ftell(FILE *stream)
POSIX file position of open stream.
MEMSPACE int rmdir(const char *pathname)
POSIX delete a directory.