35#include <sys/socket.h>
49#if CONFIG_TARFS_HAVE_MMAP
54void *
mmap(
void *addr,
size_t length,
int prot,
int flags,
int fd, off_t offset) {
60 return tarf_mmap((
void *)(uintptr_t)io.
fs_idx, addr, length, prot, flags, io.
fd, offset);
72int munmap(
void *addr,
size_t length) {
75 uintptr_t vaddr = (uintptr_t )addr;
77 if (addr != NULL && length > 0) {
87 return tarf_munmap((
void *)(uintptr_t )i, addr, length);
91 log(
"address %p does not belong to mmap()\r\n", addr);
99#if CONFIG_TARFS_HAVE_DUPFD
114 int fd_offset =
fd - io.
fd;
124#if CONFIG_TARFS_HAVE_FDOPENDIR
150#if CONFIG_TARFS_HAVE_STATVFS
176#if CONFIG_TARFS_HAVE_SENDFILE
196ssize_t
sendfile(
int out_fd,
int in_fd, off_t *offset,
size_t count) {
203 if (ioctl(in_fd,
FIOGETFD, &io) >= 0)
DIR * tard_fdopendir(void *ctx, int fd)
Associate an open directory file descriptor with a directory stream.
ssize_t tarf_sendfile(void *ctx, int sock, int fd, off_t *offset, size_t count)
Copy data from a TARFS file descriptor to a socket.
void * tarf_mmap(void *ctx, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
Mimics POSIX mmap().
int tarf_dupfd(void *ctx, int fd)
Create an independent duplicate of a file descriptor.
int tarf_munmap(void *ctx, void *addr, size_t length)
munmap().
int tarfs_statvfs(void *ctx, struct statvfs *st)
Obtain filesystem statistics.
int tarfs_fsindex(const char *path)
Find the filesystem responsible for a given path.
struct tarfs_fs * tarfs_getfs(int i)
Lockless, not thread safe, does not increase refcounters.
static void tarfs_unlock()
static void tarfs_lock()
Platform abstraction helpers.
int munmap(void *addr, size_t length)
POSIX munmap().
int statvfs(const char *path, struct statvfs *st)
Obtain filesystem statistics.
void * mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
Subset of POSIX functions.
DIR * fdopendir(int fd)
Associate an open directory file descriptor with a directory stream.
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
Zero-overhead, no-buffer file-to-socket tranfer.
int dupfd(int fd)
Create an independent duplicate of a file descriptor.
Return/Request argument for FIOGETFD ioctl.
The statvfs structure for systems without it (e.g.
This descriptor holds all file descriptors opened.