|
TARFS 0.1.5
Read-only TAR filesystem for ESP32
|
TARFS File API: tarf_open(), tarf_close(), tarf_read(), tarf_pread(), tarf_lseek(), tarf_mmap(), tarf_munmap(), tarf_dupfd(), tarf_stat(), tarf_fstat(), tarf_fcntl(), tarf_ioctl(). More...
#include <file.h>
Data Fields | |
| uintptr_t | fp_vaddr |
| uint32_t | fp_pos |
| size_t | fp_size |
| int | fp_idx |
TARFS File API: tarf_open(), tarf_close(), tarf_read(), tarf_pread(), tarf_lseek(), tarf_mmap(), tarf_munmap(), tarf_dupfd(), tarf_stat(), tarf_fstat(), tarf_fcntl(), tarf_ioctl().
tarf_dupfd() is similar to POSIX dup(), except that the duplicated file descriptor does not share its file position with the original. Instead, a completely independent copy of the file descriptor is created.
How it works: open() uses inode_lookup() to find the requested inode, allocates a file descriptor structure, initializes it from the inode, and increments the filesystem reference count.
close() decrements the filesystem reference count.
read() and pread() are implemented as simple memcpy() operations.
Functions that operate on a file descriptor rely on the open()/close() reference-counting protocol. The filesystem reference is acquired by open() and released by close(), guaranteeing that the filesystem remains valid for the lifetime of every open file descriptor. This internal file descriptor maps to a local fd number as descriptor_ptr = s_tarfs[slot]->fs_fds[local_fd];
TARFS file descriptor, 16 bytes
| int tarfs_fp::fp_idx |
associated inode index
Definition at line 68 of file file.h.
Referenced by tard_fdopendir(), tarf_fstat(), and tarf_open().
| uint32_t tarfs_fp::fp_pos |
current file pointer position. can be set 1 byte past the file end, i.e. fp_pos = fp_size
Definition at line 66 of file file.h.
Referenced by tarf_ioctl(), tarf_lseek(), tarf_open(), tarf_read(), and tarf_sendfile().
| size_t tarfs_fp::fp_size |
file size in bytes. NOTE: If fp_size is 0, then fp_vaddr could be invalid and must not be read
Definition at line 67 of file file.h.
Referenced by tarf_fstat(), tarf_ioctl(), tarf_lseek(), tarf_mmap(), tarf_open(), tarf_pread(), and tarf_sendfile().
| uintptr_t tarfs_fp::fp_vaddr |
file virtual address, absolute. zero indicates unused fd.
Definition at line 65 of file file.h.
Referenced by tarf_mmap(), tarf_open(), tarf_pread(), and tarf_sendfile().