TARFS 0.1.5
Read-only TAR filesystem for ESP32
Loading...
Searching...
No Matches
inode.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 inode.h
14 * @brief Public inode API
15 *
16 */
17
18
19#pragma once
20
21#include <stdint.h>
22#include <time.h>
23#include "tar.h"
62
63typedef struct tarfs_inode {
64
65 uint32_t in_hash;
66 uintptr_t in_path;
67 uintptr_t in_vaddr;
68 uintptr_t in_dvaddr;
69 struct tarfs_inode *in_next;
73
74
75
76struct tarfs_fs;
77
78
79#ifdef __cplusplus
80extern "C" {
81#endif
96tart_t inode_getinfo(struct tarfs_inode const * const *index,
97 int idx,
98 size_t *size,
99 time_t *mtime);
100
101/*
102 * variant of inode_getinfo() which works with raw pointers to inodes
103 * Not MT-Safe. Must be called under addref protocol only
104 */
105tart_t inode_type(struct tarfs_inode const *ino);
106
107/*
108 * variant of inode_type() which returns raw type (i.e. it can be TART_SYMLINK and TART_HARDLINK)
109 * Not MT-Safe. Must be called under addref protocol only
110 */
111tart_t inode_rawtype(struct tarfs_inode const *ino);
112
113
114/* Check if inode (raw inode pointer) is one of two link-type inodes
115 * Not MT-Safe. Must be called under addref protocol only
116 *
117 */
118bool inode_islink(struct tarfs_inode const *ino);
119
120
121
133int inode_lookup(struct tarfs_inode const * const *index,
134 size_t num_inodes,
135 const char *path);
136
137
138
139
140
151struct tarfs_inode **inode_alloc(size_t count);
152
153
165void inode_free(struct tarfs_inode **index,
166 size_t count,
167 uintptr_t tar_start,
168 size_t tar_length);
169
170
181void inode_unmount(struct tarfs_fs *fs,
182 const void *tar_start,
183 size_t tar_size);
184
185
186
205int inode_mount(struct tarfs_fs *fs,
206 const unsigned char *buf,
207 size_t size,
208 const char *rebase_link,
209 const char *path_rebase);
210
211
220void inode_dumphash_sorted(struct tarfs_inode const * const *index,
221 size_t count);
222
230void inode_dumppath_sorted(struct tarfs_inode const *root);
231#ifdef __cplusplus
232};
233#endif
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.
Definition inode.c:932
void inode_dumphash_sorted(struct tarfs_inode const *const *index, size_t count)
Dump the inode hash table in sorted order.
Definition inode.c:1032
bool inode_islink(struct tarfs_inode const *ino)
Definition inode.c:521
void inode_dumppath_sorted(struct tarfs_inode const *root)
Dump the directory tree sorted by pathname.
Definition inode.c:1057
void inode_free(struct tarfs_inode **index, size_t count, uintptr_t tar_start, size_t tar_length)
Destroy an inode index.
Definition inode.c:342
tart_t inode_getinfo(struct tarfs_inode const *const *index, int idx, size_t *size, time_t *mtime)
Get information about an inode.
Definition inode.c:466
void inode_unmount(struct tarfs_fs *fs, const void *tar_start, size_t tar_size)
Unmount a TAR image.
Definition inode.c:921
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 inode.c:506
struct tarfs_inode ** inode_alloc(size_t count)
Allocate an inode index.
Definition inode.c:303
int inode_lookup(struct tarfs_inode const *const *index, size_t num_inodes, const char *path)
Find an inode by pathname.
Definition inode.c:399
tart_t inode_type(struct tarfs_inode const *ino)
Definition inode.c:490
This descriptor holds all file descriptors opened.
Definition fs.h:94
TARFS inode structure, 12..20 bytes per inode; 1000 files require ~16KiB of RAM to store the filesyst...
Definition inode.h:63
uintptr_t in_path
Definition inode.h:66
struct tarfs_inode * in_next
Definition inode.h:69
uint32_t in_hash
Definition inode.h:65
uintptr_t in_dvaddr
Definition inode.h:68
uintptr_t in_vaddr
Definition inode.h:67
const char mtime[12]
Definition tar.h:6
tart_t
Definition tar.h:46
const char size[12]
Definition tar.h:5