|
TARFS 0.1.5
Read-only TAR filesystem for ESP32
|
Go to the source code of this file.
Data Structures | |
| struct | tarfs_inode_t |
| TARFS inode structure, 12..20 bytes per inode; 1000 files require ~16KiB of RAM to store the filesystem index. More... | |
Functions | |
| tart_t | inode_getinfo (struct tarfs_inode const *const *index, int idx, size_t *size, time_t *mtime) |
| Get information about an inode. | |
| tart_t | inode_type (struct tarfs_inode const *ino) |
| tart_t | inode_rawtype (struct tarfs_inode const *ino) |
| Return raw inode type: TART_HARDLINK, TART_SYMLINK, TART_DIR, TART_FILE or TART_BAD. | |
| bool | inode_islink (struct tarfs_inode const *ino) |
| int | inode_lookup (struct tarfs_inode const *const *index, size_t num_inodes, const char *path) |
| Find an inode by pathname. | |
| struct tarfs_inode ** | inode_alloc (size_t count) |
| Allocate an inode index. | |
| void | inode_free (struct tarfs_inode **index, size_t count, uintptr_t tar_start, size_t tar_length) |
| Destroy an inode index. | |
| void | inode_unmount (struct tarfs_fs *fs, const void *tar_start, size_t tar_size) |
| Unmount a TAR image. | |
| int | inode_mount (struct tarfs_fs *fs, const unsigned char *buf, size_t size, const char *rebase_link, const char *path_rebase) |
| Build an inode index for a TAR image. | |
| void | inode_dumphash_sorted (struct tarfs_inode const *const *index, size_t count) |
| Dump the inode hash table in sorted order. | |
| void | inode_dumppath_sorted (struct tarfs_inode const *root) |
| Dump the directory tree sorted by pathname. | |
| struct tarfs_inode ** inode_alloc | ( | size_t | count | ) |
Allocate an inode index.
Returns an array of pointers to tarfs_inode structures.
Allocates an array of inode pointers capable of holding count entries.
| count | Number of inode pointers to allocate. |
NULL on failure.Allocate an inode index.
Inodes are allocated and initialized to all zeros, array of pointers is allocated in populated with pointers to individual inodes Memory layout, single chunk: 0x3fc00000 .. [[index][inodes]] ..3fcxxxxx ---> memory grows this way
Definition at line 303 of file inode.c.
References log, and tarfs_calloc().
Referenced by inode_mount().
| void inode_dumphash_sorted | ( | struct tarfs_inode const *const * | index, |
| size_t | count ) |
Dump the inode hash table in sorted order.
Displays inodes sorted by hash.
Debug helper used to inspect the inode index.
| index | Inode index. |
| count | Number of entries. |
Dump the inode hash table in sorted order.
Definition at line 1032 of file inode.c.
References inode_getinfo().
| void inode_dumppath_sorted | ( | struct tarfs_inode const * | root | ) |
| void inode_free | ( | struct tarfs_inode ** | index, |
| size_t | count, | ||
| uintptr_t | tar_start, | ||
| size_t | tar_length ) |
Destroy an inode index.
Free inodes.
Frees an inode index previously created by inode_alloc() together with all associated inode objects.
| index | Inode index. |
| count | Number of entries in the index. |
| tar_start | Start address of the mounted TAR image. |
| tar_length | TAR image size in bytes. |
Destroy an inode index.
All memory associated with inodes is freed: inodes and index array. Some inodes may have allocated names. There is no way to distiguish allocated name from a TAR name, except for checking pointer address to NOT BE in the mmaped TAR file
Definition at line 342 of file inode.c.
References tarfs_os_free().
Referenced by inode_unmount().
| tart_t inode_getinfo | ( | struct tarfs_inode const *const * | index, |
| int | idx, | ||
| size_t * | size, | ||
| time_t * | mtime ) |
Get information about an inode.
inode_getinfo() : get inode's Type, Size and Mtime These are not precached and must be calculated every time.
Retrieves metadata for the inode referenced by an inode index entry. Either size or mtime may be NULL if the corresponding value is not required.
| index | Inode index. |
| idx | Inode number within the index. |
| size | Optional output for file size. |
| mtime | Optional output for modification time. |
Get information about an inode.
Having this information in the tarfs_inode will increase the size of inode list dramatically
| fs | a pointer to mounted FS |
| idx | inode of intereset (inode index) |
| size | if not NULL, provides the location to store the entry size |
| mtime | if not NULL, provides the location to store the entry mtime |
Definition at line 466 of file inode.c.
References mtime, tarhdr_t::mtime, size, tarhdr_t::size, tar_octal(), tart_t, and tarhdr_t::type.
Referenced by inode_dumphash_sorted(), inode_resolve(), tarf_fstat(), and tarf_open().
| bool inode_islink | ( | struct tarfs_inode const * | ino | ) |
Definition at line 521 of file inode.c.
References tarhdr_t::type.
| int inode_lookup | ( | struct tarfs_inode const *const * | index, |
| size_t | num_inodes, | ||
| const char * | path ) |
Find an inode by pathname.
Find an inode that corresponds to given path name.
Performs a pathname lookup in the inode index.
| index | Inode index. |
| num_inodes | Number of entries in the index. |
| path | Absolute path to search for. |
Find an inode by pathname.
Performs a binary search in the array of pointers to struct tarfs_inode (index array). The array is sorted by ->in_hash
Inode pointer can be retrieved as node_ptr = index[i] where i is node index as returned by inode_lookup()
Returns inode index (>=0) or -errno
< Init vector for 32bit hash
Definition at line 399 of file inode.c.
References hash32(), HASH32_IV, inode_pathcmp(), and log.
Referenced by inode_resolve(), and tarf_open().
| int inode_mount | ( | struct tarfs_fs * | fs, |
| const unsigned char * | buf, | ||
| size_t | size, | ||
| const char * | rebase_link, | ||
| const char * | path_rebase ) |
Build an inode index for a TAR image.
Scans the TAR archive, creates the inode index and initializes the filesystem state.
| fs | Filesystem instance. |
| buf | Start address of the TAR image. |
| size | TAR image size in bytes. |
| rebase_link | Optional path prefix substracted from symbolic links. |
| path_rebase | Optional path prefix substracted from every TAR entry. Normally this one is autodetected (the very first directory in the archive becomes the 'path_rebase' parameter) and then substracted from every path in the archive, so archive gets "/" entry |
| 0 | Success. |
| -1 | Mount failed. |
< Hash32 value of a single-character C-string "/". NOTE: must be recomputed if hash32 algo is changed!
Definition at line 932 of file inode.c.
References tarfs_fs::fs_dsize, tarfs_fs::fs_ino, tarfs_fs::fs_mtime, tarfs_fs::fs_nino, tarfs_fs::fs_root, tarfs_fs::fs_size, tarfs_fs::fs_stats, tarfs_fs::fs_vaddr, HASH32_SLASH, inode_alloc(), inode_alphasort(), inode_populate(), inode_resolve(), inode_sort(), log, mtime, tarhdr_t::mtime, size, tar_getnino(), and tar_octal().
Referenced by tarfs_mount_memory().
| tart_t inode_rawtype | ( | struct tarfs_inode const * | ino | ) |
Return raw inode type: TART_HARDLINK, TART_SYMLINK, TART_DIR, TART_FILE or TART_BAD.
Definition at line 506 of file inode.c.
References tart_t, and tarhdr_t::type.
| tart_t inode_type | ( | struct tarfs_inode const * | ino | ) |
Definition at line 490 of file inode.c.
References tart_t, and tarhdr_t::type.
Referenced by tard_readdir().
| void inode_unmount | ( | struct tarfs_fs * | fs, |
| const void * | tar_start, | ||
| size_t | tar_size ) |
Unmount a TAR image.
Releases all in-memory data structures associated with a mounted TARFS instance.
| fs | Filesystem instance. |
| tar_start | Start address of the mounted TAR image. |
| tar_size | TAR image size in bytes. |
Definition at line 921 of file inode.c.
References tarfs_fs::fs_ino, tarfs_fs::fs_nino, inode_free(), and log.
Referenced by commit_unmount().