|
HP85 GPIB Disk Emulator
1.0
HP85GPIBDiskEmulator
|
POSIX wrapper for FatFS. More...
Go to the source code of this file.
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 () |
| 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 FILE * | fileno_to_stream (int fileno) |
| Convert POSIX fileno to POSIX FILE stream pointer. NOT POSIX. More... | |
| MEMSPACE FILE * | fopen (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 int | utime (const char *filename, const struct utimbuf *times) |
| Set Modification and Access time of a 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 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... | |
| DIR * | opendir (const char *pathdir) |
| dirent_t * | readdir (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_ATR * | strerror (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 FILE * | fdevopen (int(*put)(char, FILE *), int(*get)(FILE *)) |
| Device open functions. More... | |
| 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 FIL * | fileno_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... | |
| static MEMSPACE void | _fprintf_putc (struct _printf_t *p, char ch) |
| fprintf character write function 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 | |
| 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... | |
POSIX wrapper for FatFS.
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.
| MEMSPACE char* baseext | ( | char * | str | ) |
| MEMSPACE char* basename | ( | char * | str | ) |
POSIX Basename of filename.
| [in] | str | string to find basename in. |
Definition at line 1469 of file posix.c.
Referenced by lif_fixname(), and ls_info().
| MEMSPACE int chdir | ( | const char * | pathname | ) |
POSIX change directory.
| [in] | pathname | directory to change to |
Definition at line 1512 of file posix.c.
Referenced by posix_tests().
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.
man page chmod (2).
| [in] | pathname | filename string. |
| [in] | mode | POSIX chmod modes. |
Definition at line 1538 of file posix.c.
Referenced by mkdir(), and posix_tests().
| MEMSPACE int close | ( | int | fileno | ) |
| int closedir | ( | DIR * | dirp | ) |
| MEMSPACE int dirname | ( | char * | str | ) |
POSIX directory name of a filename. Return the index of the last '/' character.
| [in] | str | string to examine. |
Definition at line 1577 of file posix.c.
Referenced by hpdir_find_drive().
Display struct stat, from POSIX stat(0 or fstat(), in ASCII. NOT POSIX.
| [in] | sp | struct stat pointer. |
Definition at line 1283 of file posix.c.
Referenced by posix_tests().
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()
| [in] | stream | POSIX stream pointer. |
Definition at line 2031 of file posix.c.
Referenced by open().
Private FatFs function called by fputc() to put a byte from file stream NOT POSIX open() assigns stream->put = fatfs_putc()
| [in] | c | character. |
| [in] | stream | POSIX stream pointer. |
Convert FafFs error result to POSIX errno. NOT POSIX.
| [in] | Result | FatFs Result code. |
Definition at line 2163 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().
POSIX close a file stream.
| [in] | stream | POSIX stream pointer. |
Definition at line 1261 of file posix.c.
Referenced by buffer_read_close(), cat(), copy(), gpib_trace_task(), hpdir_find_drive(), lif_add_ascii_file_as_e010_wrapper(), lif_close_volume(), lif_extract_e010_as_ascii(), MatRead(), MatWrite(), printer_close(), Read_Config(), td02lif(), and timetests().
Device open functions.
Assign stdin,stdout,stderr or any use defined I/O NOT POSIX
| [in] | *put | putc function pointer |
| [in] | *get | gutc function pointer |
Definition at line 1912 of file posix.c.
Referenced by uart_init().
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.
| [in] | stream | POSIX stream pointer. |
get a string from stdin See fdevopen() sets stream->put get for TTY devices
POSIX string I/O
| [in] | stream | POSIX stream pointer. |
Definition at line 432 of file posix.c.
Referenced by cat(), hpdir_find_drive(), lif_add_ascii_file_as_e010_wrapper(), MatRead(), Read_Config(), setdate(), and user_task().
Convert POSIX stream pointer to POSIX fileno (index of __iob[])
| [in] | stream | stream pointer |
Definition at line 741 of file posix.c.
Referenced by close(), fclose(), fileno(), fileno_to_fatfs(), fileno_to_stream(), fopen(), fread(), free_file_descriptor(), fseek(), ftell(), fwrite(), isatty(), lseek(), open(), receive_plot_flush(), and ungetc().
Convert POSIX fileno to FatFS handle NOT POSIX.
| [in] | fileno | fileno of file |
Definition at line 2327 of file posix.c.
Referenced by close(), ftell(), ftruncate(), lseek(), open(), read(), sync(), syncfs(), and write().
Convert POSIX fileno to POSIX FILE stream pointer. NOT POSIX.
| [in] | fileno | POSIX fileno is the index of __iob[]. |
Definition at line 772 of file posix.c.
Referenced by close(), fileno_to_fatfs(), fopen(), free_file_descriptor(), lseek(), open(), read(), syncfs(), and write().
POSIX Open a file with path name and ascii file mode string.
| [in] | path | filename string. |
| [in] | mode | POSIX open mode strings. |
Definition at line 801 of file posix.c.
Referenced by buffer_read_open(), cat(), copy(), gpib_trace_task(), hpdir_find_drive(), lif_open(), MatRead(), MatWrite(), printer_open(), Read_Config(), td02lif(), td0_open(), and timetests().
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] | *fp | FILE stream pointer |
| [in] | fmt | printf forat string |
| [in] | ... | vararg list or arguments |
Definition at line 2533 of file posix.c.
Referenced by gpib_decode_header(), gpib_log(), gpib_trace_display(), MatWrite(), and timetests().
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.
| [in] | stream | POSIX stream pointer. |
Definition at line 287 of file posix.c.
Referenced by _fprintf_putc(), fputs(), putc(), putchar(), puts(), and write().
put a string to stdout See fdevopen() sets stream->put get for TTY devices
| [in] | stream | POSIX stream pointer. |
POSIX read nmemb elements from buf, size bytes each, to the stream fd.
| [in] | ptr | buffer. |
| [in] | nmemb | number of items to read. |
| [in] | size | size of each item in bytes. |
| [in] | stream | POSIX file stream. |
Definition at line 823 of file posix.c.
Referenced by buffer_getc(), copy(), lif_read(), td0_open(), and td0_read().
| MEMSPACE int free_file_descriptor | ( | int | fileno | ) |
POSIX seek to file possition.
| [in] | stream | POSIX file stream. |
| [in] | offset | offset to seek to. |
| [in] | whence |
|
Definition at line 558 of file posix.c.
Referenced by fsetpos(), lif_close_volume(), lif_seek_msg(), and rewind().
POSIX file position of open stream.
| [in] | stream | POSIX file stream. |
Definition at line 600 of file posix.c.
Referenced by fgetpos(), and lif_seek_msg().
POSIX write nmemb elements from buf, size bytes each, to the stream fd.
| [in] | ptr | buffer. |
| [in] | nmemb | number of items to write. |
| [in] | size | size of each item in bytes. |
| [in] | stream | POSIX file stream. |
Definition at line 890 of file posix.c.
Referenced by copy(), lif_extract_e010_as_ascii(), lif_write(), receive_plot_flush(), and td0_save_lif_sector().
| MEMSPACE int getchar | ( | ) |
functions normally defined as macros
get a character from stdin See fdevopen() sets stream->get for TTY devices
| [in] | stream | POSIX stream pointer. |
Definition at line 347 of file posix.c.
Referenced by testpage().
| MEMSPACE char* getcwd | ( | char * | pathname, |
| int | len | ||
| ) |
POSIX get current working directory.
| [in] | pathname | directory to change to |
Definition at line 1623 of file posix.c.
Referenced by ls(), and posix_tests().
| MEMSPACE int isatty | ( | int | fileno | ) |
Test POSIX fileno if it is a Serial Console/TTY.
| [in] | fileno | POSIX fileno of open file. |
Definition at line 195 of file posix.c.
Referenced by fileno_to_fatfs(), free_file_descriptor(), ftell(), ftruncate(), lseek(), new_file_descriptor(), sync(), syncfs(), and ungetc().
POSIX seek to file position.
| [in] | fileno | POSIX fileno of open file. |
| [in] | position | offset to seek to. |
| [in] | whence |
|
Definition at line 633 of file posix.c.
Referenced by fseek().
POSIX make a directory.
| [in] | pathname | directory to create |
Definition at line 1647 of file posix.c.
Referenced by posix_tests().
| int mkfs | ( | char * | name | ) |
Formt SD card.
| [in] | *name | device name @retrun void |
Definition at line 1960 of file posix.c.
Referenced by posix_tests().
| MEMSPACE int new_file_descriptor | ( | void | ) |
| MEMSPACE int open | ( | const char * | pathname, |
| int | flags | ||
| ) |
| MEMSPACE void perror | ( | const char * | s | ) |
POSIX perror() - convert POSIX errno to text with user message.
| [in] | s | User message displayed before the error message |
Definition at line 1850 of file posix.c.
Referenced by gpib_trace_task(), printer_open(), Read_Config(), receive_plot_flush(), and timetests().
| MEMSPACE int posix_fopen_modes_to_open | ( | const char * | mode | ) |
Convert POSIX fopen mode to POSIX open mode flags. NOT POSIX.
| [in] | mode | POSIX file mode string. |
Definition at line 2468 of file posix.c.
Referenced by fopen().
Put a character to a stream See fdevopen() sets stream->put get for TTY devices.
| [in] | stream | POSIX stream pointer. |
| MEMSPACE int putchar | ( | int | c | ) |
put a character to stdout See fdevopen() sets stream->put get for TTY devices
| [in] | stream | POSIX stream pointer. |
Definition at line 363 of file posix.c.
Referenced by print_tok(), print_tok_str(), print_tok_val(), and td0_hexdump().
| MEMSPACE int puts | ( | const char * | str | ) |
put a string to stdout See fdevopen() sets stream->put get for TTY devices
| [in] | stream | POSIX stream pointer. |
Definition at line 493 of file posix.c.
Referenced by cat(), and gpib_trace_display().
| MEMSPACE int rename | ( | const char * | oldpath, |
| const char * | newpath | ||
| ) |
POSIX rename a file by name.
| [in] | oldpath | original name. |
| [in] | newpath | new name. |
Definition at line 1677 of file posix.c.
Referenced by posix_tests().
| MEMSPACE int rmdir | ( | const char * | pathname | ) |
POSIX delete a directory.
| [in] | pathname | directory to delete. |
Definition at line 1701 of file posix.c.
Referenced by posix_tests().
POSIX stat - get file status of named file.
| [in] | name | file name. |
| [in] | buf | struct stat buffer to return results in. |
Definition at line 1368 of file posix.c.
Referenced by f_getfree(), format_drives(), lif_stat(), ls(), ls_info(), mount_volume(), and posix_tests().
POSIX strerror() - convert POSIX errno to text with user message.
| [in] | errnum | index for sys_errlist[] |
POSIX strerror_r() - convert POSIX errno to text with user message.
| [in] | errnum | index for sys_errlist[] |
| [in] | buf | user buffer for error message |
| [in] | buflen | length of user buffer for error message |
| MEMSPACE void sync | ( | void | ) |
POSIX Sync all pending file changes and metadata on ALL files.
Definition at line 1091 of file posix.c.
Referenced by lif_close_volume(), and lif_extract_e010_as_ascii().
| MEMSPACE int syncfs | ( | int | fd | ) |
POSIX Sync pending file changes and metadata for specified fileno.
| [in] | fd | POSIX fileno to sync. |
Definition at line 1119 of file posix.c.
Referenced by receive_plot_flush(), and sync().
| MEMSPACE int unlink | ( | const char * | pathname | ) |
POSIX delete a file.
| [in] | pathname | filename to delete. |
Definition at line 1723 of file posix.c.
Referenced by posix_tests().
Set Modification and Access time of a file.
| [in] | filename | file name |
| [in | *times: access and modication utimbuf structure, if NULL use current time |
Definition at line 1432 of file posix.c.
Referenced by lif_extract_e010_as_ascii().
POSIX fileno to POSIX FILE stream table.
Definition at line 138 of file posix.c.
Referenced by fatfs_to_fileno(), fileno(), fileno_to_stream(), free_file_descriptor(), and new_file_descriptor().
|
static |
|
static |
| int errno |
Note: fdevopen assigns stdin,stdout,stderr.
POSIX errno.
Definition at line 129 of file posix.c.
Referenced by chdir(), chmod(), close(), closedir(), fatfs_getc(), fatfs_putc(), fatfs_to_fileno(), fgetc(), fileno(), fileno_to_fatfs(), fileno_to_stream(), fputc(), free_file_descriptor(), ftell(), ftruncate(), getcwd(), lseek(), mctime(), mkdir(), new_file_descriptor(), open(), opendir(), perror(), read(), readdir(), rename(), rmdir(), stat(), syncfs(), truncate(), unlink(), and write().
| const char* sys_errlist[] |
POSIX error messages for each errno value.
Definition at line 143 of file posix.c.
Referenced by perror(), strerror(), and strerror_r().
1.8.17