TARFS
0.1.5
Read-only TAR filesystem for ESP32
Toggle main menu visibility
Loading...
Searching...
No Matches
posix.h
Go to the documentation of this file.
1
/*
2
* TARFS - Immutable (read-only) filesystem for embedded systems.
3
*
4
* Copyright (c) 2026 Viacheslav Logunov
5
* SPDX-License-Identifier: MMIT
6
*
7
* Author:
8
* Viacheslav Logunov <vvb333007@gmail.com>
9
*
10
* Project:
11
* https://github.com/vvb333007/tarfs
12
*
13
* @file posix.h
14
* @brief POSIX extensions API for TARFS (mmap(), sendfile() etc)
15
*/
16
17
#pragma once
18
19
#include <stdint.h>
20
#include <stdlib.h>
21
#include <stddef.h>
22
#include <stdio.h>
23
#include <sys/types.h>
24
28
#define PROT_READ 1
29
#define PROT_WRITE 2
30
#define PROT_EXEC 4
31
32
#define MAP_FILE 0
33
#define MAP_SHARED 1
34
#define MAP_PRIVATE 2
35
36
#define MAP_FIXED 4
37
#define MAP_ANONYMOUS 8
38
#define MAP_ANON 8
39
40
41
#define MAP_FAILED ((void *)(-1))
42
43
44
45
46
#ifdef __cplusplus
47
extern
"C"
{
48
#endif
83
void
*
mmap
(
void
*addr,
size_t
length,
int
prot,
int
flags,
int
fd, off_t offset);
84
85
99
int
munmap
(
void
*addr,
size_t
length);
100
101
#if CONFIG_TARFS_HAVE_FDOPENDIR
117
DIR *
fdopendir
(
int
fd);
118
#endif
/* CONFIG_TARFS_HAVE_FDOPENDIR */
119
120
#if CONFIG_TARFS_HAVE_DUPFD
141
int
dupfd
(
int
fd);
142
#endif
/* CONFIG_TARFS_HAVE_DUPFD */
143
144
145
#if CONFIG_TARFS_HAVE_STATVFS
157
int
statvfs
(
const
char
*path,
struct
statvfs
*st);
158
#endif
/* CONFIG_TARFS_HAVE_STATVFS */
159
160
#if CONFIG_TARFS_HAVE_SENDFILE
179
ssize_t
sendfile
(
int
out_fd,
int
in_fd, off_t *offset,
size_t
count);
180
#endif
/* #if CONFIG_TARFS_HAVE_SENDFILE */
181
182
#ifdef __cplusplus
183
};
184
#endif
statvfs
int statvfs(const char *path, struct statvfs *st)
Obtain filesystem statistics.
Definition
posix.c:163
fdopendir
DIR * fdopendir(int fd)
Associate an open directory file descriptor with a directory stream.
Definition
posix.c:133
sendfile
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
Zero-overhead, no-buffer file-to-socket tranfer.
Definition
posix.c:196
dupfd
int dupfd(int fd)
Create an independent duplicate of a file descriptor.
Definition
posix.c:107
munmap
int munmap(void *addr, size_t length)
Remove a previously created memory mapping.
Definition
posix.c:72
mmap
void * mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
Map a file into the process address space.
Definition
posix.c:54
statvfs
The statvfs structure for systems without it (e.g.
Definition
fs.h:142
src
posix.h
Generated by
1.17.0