TARFS
0.1.5
Read-only TAR filesystem for ESP32
Toggle main menu visibility
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
63
typedef
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
;
72
}
tarfs_inode_t
;
73
74
75
76
struct
tarfs_fs
;
77
78
79
#ifdef __cplusplus
80
extern
"C"
{
81
#endif
96
tart_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
*/
105
tart_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
*/
111
tart_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
*/
118
bool
inode_islink
(
struct
tarfs_inode
const
*ino);
119
120
121
133
int
inode_lookup
(
struct
tarfs_inode
const
*
const
*index,
134
size_t
num_inodes,
135
const
char
*path);
136
137
138
139
140
151
struct
tarfs_inode **
inode_alloc
(
size_t
count);
152
153
165
void
inode_free
(
struct
tarfs_inode **index,
166
size_t
count,
167
uintptr_t tar_start,
168
size_t
tar_length);
169
170
181
void
inode_unmount
(
struct
tarfs_fs
*fs,
182
const
void
*tar_start,
183
size_t
tar_size);
184
185
186
205
int
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
220
void
inode_dumphash_sorted
(
struct
tarfs_inode
const
*
const
*index,
221
size_t
count);
222
230
void
inode_dumppath_sorted
(
struct
tarfs_inode
const
*root);
231
#ifdef __cplusplus
232
};
233
#endif
inode_mount
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
inode_dumphash_sorted
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
inode_islink
bool inode_islink(struct tarfs_inode const *ino)
Definition
inode.c:521
inode_dumppath_sorted
void inode_dumppath_sorted(struct tarfs_inode const *root)
Dump the directory tree sorted by pathname.
Definition
inode.c:1057
inode_free
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
inode_getinfo
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
inode_unmount
void inode_unmount(struct tarfs_fs *fs, const void *tar_start, size_t tar_size)
Unmount a TAR image.
Definition
inode.c:921
inode_rawtype
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
inode_alloc
struct tarfs_inode ** inode_alloc(size_t count)
Allocate an inode index.
Definition
inode.c:303
inode_lookup
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
inode_type
tart_t inode_type(struct tarfs_inode const *ino)
Definition
inode.c:490
tarfs_fs
This descriptor holds all file descriptors opened.
Definition
fs.h:94
tarfs_inode_t
TARFS inode structure, 12..20 bytes per inode; 1000 files require ~16KiB of RAM to store the filesyst...
Definition
inode.h:63
tarfs_inode_t::in_path
uintptr_t in_path
Definition
inode.h:66
tarfs_inode_t::in_next
struct tarfs_inode * in_next
Definition
inode.h:69
tarfs_inode_t::in_hash
uint32_t in_hash
Definition
inode.h:65
tarfs_inode_t::in_dvaddr
uintptr_t in_dvaddr
Definition
inode.h:68
tarfs_inode_t::in_vaddr
uintptr_t in_vaddr
Definition
inode.h:67
tar.h
mtime
const char mtime[12]
Definition
tar.h:6
tart_t
tart_t
Definition
tar.h:46
size
const char size[12]
Definition
tar.h:5
src
inode.h
Generated by
1.17.0