libsquashfs 1.3.0
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
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
77{
78 s->current = s->init;
79 s->entries = 0;
80}
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
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
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
168 sqfs_dir_header_t *hdr);
169
185 sqfs_dir_entry_t **ent);
186
208SQFS_API
210 const sqfs_inode_generic_t *inode);
211
235 sqfs_dir_entry_t **ent,
236 sqfs_u32 *inum, sqfs_u64 *iref);
237
257SQFS_API
259 const sqfs_super_t *super,
260 sqfs_u64 block_start, size_t offset,
262
263#ifdef __cplusplus
264}
265#endif
266
267#endif /* SQFS_META_READER_H */
Includes forward declarations of data structures, macros and integer types.
Encapsultes a compressor with a simple interface to compress or extract chunks of data.
Definition: compressor.h:40
On-disk data structure of a directory entry. Many of these follow a single sqfs_dir_header_t.
Definition: dir.h:74
On-disk data structure of a directory header.
Definition: dir.h:42
Abstracts file I/O to make it easy to embedd SquashFS.
Definition: io.h:94
A generic inode structure that combines all others and provides additional information.
Definition: inode.h:488
Abstracts reading of meta data blocks.
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_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_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_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_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_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_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_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.
Encapsulates state for simple directory reading.
Definition: meta_reader.h:56
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.
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
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition: super.h:47
Contains on-disk data structures, identifiers and functions for the SquashFS super block.