|
TARFS 0.1.5
Read-only TAR filesystem for ESP32
|
#include "config.h"Go to the source code of this file.
Data Structures | |
| struct | tarhdr_t |
| For TAR files with modified PADDING field (see tarsum.c TARFS Checksum Utility): The type and meaning of the last 8 bytes of the padding field. More... | |
Functions | |
| enum | __attribute__ ((packed)) |
| "TART" == "TAR Type" tarfile entry (header) types, 1-byte wide. | |
| int | tar_strcmp (const char *s1, const char *s1_end, const char *s2) |
| Compare an UTS/CTS to a CTS. | |
| int | tar_strncmp (const char *s1, const char *s2, size_t len) |
| int | tar_strlen (const char *s1, const char *s1_end) |
| Return the length of a TAR string. | |
| char * | tar_strdup1 (const char *s1, const char *s1_end) |
| Duplicate a TAR string as a regular NUL-terminated C string. | |
| uint32_t | tar_octal (const char *p, size_t max_len) |
| bool | tar_badhdr (tarhdr_t const *hdr) |
| Validate a TAR header. | |
| int | tar_getnino (const uint8_t *tar_start, size_t tar_length) |
| Quick run through the tarfile to count number of inodes we have to create Bad blocks are skipped; inodes_count = number_of_links + number_files + number_of_directoris. | |
| bool | tar_rootdir (const uint8_t *tar_start, size_t tar_length, char *base_dir, size_t base_dir_len) |
| Detect the archive root directory. | |
| uint32_t | tar_hdrsum (const tarhdr_t *hdr) |
| bool | tar_baddata (struct tarhdr const *hdr, size_t size) |
| Verify CRC64 checksums stored in a TAR archive, if present. | |
Variables | |
| tart_t | |
| const char | name [100] |
| const char | mode [8] |
| const char | uid [8] |
| const char | gid [8] |
| const char | size [12] |
| const char | mtime [12] |
| char | checksum [8] |
| const tart_t | type |
| const char | link_name [100] |
| const char | magic [6] |
| const char | version [2] |
| const char | user [32] |
| const char | group [32] |
| const char | major [8] |
| const char | minor [8] |
| const char | prefix [155] |
| char | zero |
| const char | pad [11] |
| struct tarhdr __attribute__ | ( | (packed) | ) |
"TART" == "TAR Type" tarfile entry (header) types, 1-byte wide.
The same type is used throughout the filesystem code as the main type for inodes, tar record etc
< file, old format
< file, common format
< hard link
< symbolic link
< directory
< PaxHeader
< character device
< block device
< fifo / named pipe
< contigous file, whatever that means
< PaxGlobalHeader
| bool tar_baddata | ( | struct tarhdr const * | hdr, |
| size_t | size ) |
Verify CRC64 checksums stored in a TAR archive, if present.
Verify CRC64 checksum stored in a TAR archive, if present.
hdr must pass tar_badhdr() check!!
Verify CRC64 checksums stored in a TAR archive, if present.
hdr must pass tar_badhdr() check!!
Definition at line 529 of file tar.c.
References hash64(), and size.
Referenced by inode_populate(), tarf_open(), and tarfs_fsck().
| bool tar_badhdr | ( | tarhdr_t const * | hdr | ) |
Validate a TAR header.
Checks:
| hdr | Pointer to a TAR header. |
Checks:
| hdr | Pointer to a TAR header. |
Definition at line 249 of file tar.c.
References tar_hdrsum(), and tar_octal().
Referenced by inode_populate(), tar_getnino(), tar_rootdir(), and tarfs_fsck().
| int tar_getnino | ( | const uint8_t * | tar_start, |
| size_t | tar_length ) |
Quick run through the tarfile to count number of inodes we have to create Bad blocks are skipped; inodes_count = number_of_links + number_files + number_of_directoris.
Quick run through the tarfile to count number of inodes we have to create.
| tar_start | Address where the TAR archive is mapped. |
| tar_length | Size of the mapped archive. |
Quick run through the tarfile to count number of inodes we have to create Bad blocks are skipped; inodes_count = number_of_links + number_files + number_of_directoris.
Bad blocks are skipped; inodes_count = number_of_links + number_files + number_of_directoris
Definition at line 306 of file tar.c.
References log, size, tar_badhdr(), and tar_octal().
Referenced by inode_mount().
| uint32_t tar_hdrsum | ( | const tarhdr_t * | hdr | ) |
Definition at line 221 of file tar.c.
Referenced by tar_badhdr().
| uint32_t tar_octal | ( | const char * | p, |
| size_t | max_len ) |
Definition at line 193 of file tar.c.
Referenced by inode_getinfo(), inode_mount(), inode_mtime(), inode_populate(), tar_badhdr(), tar_getnino(), tar_rootdir(), and tarfs_fsck().
| bool tar_rootdir | ( | const uint8_t * | tar_start, |
| size_t | tar_length, | ||
| char * | base_dir, | ||
| size_t | out_len ) |
Detect the archive root directory.
The detected directory is used both as the filesystem mount point and as the path prefix to strip from every inode. For example, if the archive contains:
my_archive/ my_archive/file.txt my_archive/dir/test.txt
then the filesystem will expose:
/file.txt /dir/test.txt
Detection relies on the following assumptions:
These assumptions are not verified. It is the caller's responsibility to provide a well-formed TAR archive.
Since the root directory becomes the mount point, it must satisfy the ESP-IDF mount-point limitations (currently no more than 16 characters, excluding the terminating NUL).
The root directory name always fits into tarhdr->name, so it is guaranteed to be NUL-terminated and never uses the TAR 'prefix' field.
| tar_start | Address where the TAR archive is mapped. |
| tar_length | Size of the mapped archive. |
| base_dir | Output buffer receiving the detected root directory. |
| base_dir_len | Output buffer size. Recommended size is 100 bytes |
This function may choose wrong directory name if filesystem is damaged
Definition at line 372 of file tar.c.
References log, size, tar_badhdr(), tar_octal(), tar_strlen(), and tarfs_os_mp_maxlen().
Referenced by tarfs_mount_memory().
| int tar_strcmp | ( | const char * | s1, |
| const char * | s1_end, | ||
| const char * | s2 ) |
Compare an UTS/CTS to a CTS.
TAR string fields are not required to be NUL-terminated. A string ends at the first '\0', '\r' or '
', or at s1_end if no terminator appears before that point.
| s1 | TAR string. |
| s1_end | Pointer to the byte immediately following the last valid character in s1, or NULL if s1 is guaranteed to contain a TAR string terminator. |
| s2 | Regular NUL-terminated C string. |
Definition at line 48 of file tar.c.
Referenced by merge().
| char * tar_strdup1 | ( | const char * | s1, |
| const char * | s1_end ) |
Duplicate a TAR string as a regular NUL-terminated C string.
The returned buffer contains one additional byte after the terminating NUL, allowing a single character (typically '/') to be appended without reallocating. This is used during link resolution.
string\0\0 ^_— Here one could append one character to extend a string by one character
| s1 | TAR string. |
| s1_end | Pointer to the byte immediately following the last valid character in s1, or NULL if s1 contains a TAR string terminator. |
Definition at line 171 of file tar.c.
References tar_strlen(), and tarfs_os_malloc().
Referenced by inode_populate(), tard_fdopendir(), and tarf_open().
| int tar_strlen | ( | const char * | s1, |
| const char * | s1_end ) |
Return the length of a TAR string.
A TAR string ends at the first '\0', '\r' or '
'. If none of these characters is present before s1_end, then s1_end is treated as the end of the string.
| s1 | TAR string. |
| s1_end | Pointer to the byte immediately following the last valid character in s1, or NULL if s1 contains a TAR string terminator. |
Definition at line 131 of file tar.c.
Referenced by inode_populate(), tar_rootdir(), tar_strdup1(), and tard_readdir().
| int tar_strncmp | ( | const char * | s1, |
| const char * | s2, | ||
| size_t | len ) |
Definition at line 90 of file tar.c.
Referenced by is_direct_child().
| const char link_name[100] |
For records type#1 and #2 this field contains a name of the object
Definition at line 9 of file tar.h.
Referenced by inode_resolve().
| const char mode[8] |
| const char mtime[12] |
All times are set at mount time and never change (ROFS)
Definition at line 6 of file tar.h.
Referenced by inode_getinfo(), inode_mount(), tarf_fstat(), and tarf_open().
| const char name[100] |
First (if prefix[0] == 0) or Second part of the entry name
Definition at line 1 of file tar.h.
Referenced by tard_opendir().
| const char prefix[155] |
First (if prefix[0] != 0) part of the entry name. A slash at the end does not exist but is assumed
Definition at line 16 of file tar.h.
Referenced by is_direct_child(), tarfs_os_register_fs(), and tarfs_os_unregister_fs().
| const char size[12] |
Octal, ASCII string, terminated with a space \20, not \0
Definition at line 5 of file tar.h.
Referenced by inode_getinfo(), inode_mount(), inode_mtime(), inode_populate(), path_from_pax_header(), tar_baddata(), tar_getnino(), tar_rootdir(), tarf_open(), tarf_pread(), tarf_read(), tarfs_calloc(), tarfs_fsck(), tarfs_mount(), tarfs_mount_memory(), tarfs_os_malloc(), and tarfs_os_unmap_tarfile().
| tart_t |
Definition at line 46 of file tar.h.
Referenced by inode_getinfo(), inode_rawtype(), inode_resolve(), inode_type(), tarf_fstat(), and tarf_open().
| const tart_t type |
Record type
Definition at line 8 of file tar.h.
Referenced by inode_resolve(), tarf_fstat(), and tarf_open().