libsquashfs: include/sqfs/meta_reader.h Source File

libsquashfs 1.3.2 A new set of tools and libraries for working with SquashFS images

Loading...
Searching...
No Matches
meta_reader.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/*
3 * meta_reader.h - This file is part of libsquashfs
4 *
5 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef SQFS_META_READER_H
21#define SQFS_META_READER_H
22
23#include "sqfs/predef.h"
24#include "sqfs/super.h"
25
31
50
56 struct sqfs_readdir_state_t {
57 struct {
58 sqfs_u64 block;
59 size_t offset;
60 size_t size;
61 } init, current;
62
63 size_t entries;
64
65 sqfs_u32 inum_base;
66 sqfs_u64 inode_block;
67};
68
76 static SQFS_INLINE void sqfs_readdir_state_reset(sqfs_readdir_state_t *s)
77{
78 s->current = s->init;
79 s->entries = 0;
80}
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
101SQFS_API sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
102 sqfs_compressor_t *cmp,
103 sqfs_u64 start,
104 sqfs_u64 limit);
105
120SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, sqfs_u64 block_start,
121 size_t offset);
122
132SQFS_API void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m,
133 sqfs_u64 *block_start,
134 size_t *offset);
135
151SQFS_API int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data,
152 size_t size);
153
167SQFS_API int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m,
168 sqfs_dir_header_t *hdr);
169
184SQFS_API int sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m,
185 sqfs_dir_entry_t **ent);
186
208SQFS_API
209 int sqfs_readdir_state_init(sqfs_readdir_state_t *s, const sqfs_super_t *super,
210 const sqfs_inode_generic_t *inode);
211
233SQFS_API int sqfs_meta_reader_readdir(sqfs_meta_reader_t *m,
234 sqfs_readdir_state_t *s,
235 sqfs_dir_entry_t **ent,
236 sqfs_u32 *inum, sqfs_u64 *iref);
237
257SQFS_API
258 int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
259 const sqfs_super_t *super,
260 sqfs_u64 block_start, size_t offset,
261 sqfs_inode_generic_t **out);
262
263#ifdef __cplusplus
264}
265#endif
266
267#endif /* SQFS_META_READER_H */
predef.h
Includes forward declarations of data structures, macros and integer types.
sqfs_compressor_t
Encapsultes a compressor with a simple interface to compress or extract chunks of data.
Definition compressor.h:40
sqfs_dir_entry_t
On-disk data structure of a directory entry. Many of these follow a single sqfs_dir_header_t.
Definition dir.h:74
sqfs_dir_header_t
On-disk data structure of a directory header.
Definition dir.h:42
sqfs_file_t
Abstracts file I/O to make it easy to embedd SquashFS.
Definition io.h:94
sqfs_inode_generic_t
A generic inode structure that combines all others and provides additional information.
Definition inode.h:488
sqfs_meta_reader_t
Abstracts reading of meta data blocks.
sqfs_meta_reader_t::sqfs_meta_reader_create
SQFS_API sqfs_meta_reader_t * sqfs_meta_reader_create(sqfs_file_t *file, sqfs_compressor_t *cmp, sqfs_u64 start, sqfs_u64 limit)
Create a meta data reader.
sqfs_meta_reader_t::sqfs_meta_reader_read_dir_header
SQFS_API int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m, sqfs_dir_header_t *hdr)
Read and decode a directory header from a meta data reader.
sqfs_meta_reader_t::sqfs_meta_reader_get_position
SQFS_API void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m, sqfs_u64 *block_start, size_t *offset)
Get the current position that the next read will read from.
sqfs_meta_reader_t::sqfs_meta_reader_read
SQFS_API int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size)
Read a chunk of data from a meta data reader.
sqfs_meta_reader_t::sqfs_meta_reader_seek
SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, sqfs_u64 block_start, size_t offset)
Seek to a specific meta data block and offset.
sqfs_meta_reader_t::sqfs_meta_reader_read_inode
SQFS_API int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir, const sqfs_super_t *super, sqfs_u64 block_start, size_t offset, sqfs_inode_generic_t **out)
Read and decode an inode from a meta data reader.
sqfs_meta_reader_t::sqfs_meta_reader_readdir
SQFS_API int sqfs_meta_reader_readdir(sqfs_meta_reader_t *m, sqfs_readdir_state_t *s, sqfs_dir_entry_t **ent, sqfs_u32 *inum, sqfs_u64 *iref)
Simple directory reading interface.
sqfs_meta_reader_t::sqfs_meta_reader_read_dir_ent
SQFS_API int sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m, sqfs_dir_entry_t **ent)
Read and decode a directory header from a meta data reader.
sqfs_readdir_state_t
Encapsulates state for simple directory reading.
Definition meta_reader.h:56
sqfs_readdir_state_t::sqfs_readdir_state_init
SQFS_API int sqfs_readdir_state_init(sqfs_readdir_state_t *s, const sqfs_super_t *super, const sqfs_inode_generic_t *inode)
Initialize a state object for reading a directory.
sqfs_readdir_state_t::sqfs_readdir_state_reset
static SQFS_INLINE void sqfs_readdir_state_reset(sqfs_readdir_state_t *s)
Rewind a directory state object back to its starting location.
Definition meta_reader.h:76
sqfs_super_t
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition super.h:47
super.h
Contains on-disk data structures, identifiers and functions for the SquashFS super block.