libsquashfs: include/sqfs/dir_reader.h Source File

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

Loading...
Searching...
No Matches
dir_reader.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/*
3 * dir_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_DIR_READER_H
21#define SQFS_DIR_READER_H
22
23#include "sqfs/predef.h"
24
30
54
60 typedef enum {
64 SQFS_TREE_NO_DEVICES = 0x01,
65
69 SQFS_TREE_NO_SOCKETS = 0x02,
70
74 SQFS_TREE_NO_FIFO = 0x04,
75
79 SQFS_TREE_NO_SLINKS = 0x08,
80
87 SQFS_TREE_NO_EMPTY = 0x10,
88
95 SQFS_TREE_NO_RECURSE = 0x20,
96
103 SQFS_TREE_STORE_PARENTS = 0x40,
104
105 SQFS_TREE_ALL_FLAGS = 0x7F,
106} SQFS_TREE_FILTER_FLAGS;
107
114 struct sqfs_tree_node_t {
118 sqfs_tree_node_t *parent;
119
123 sqfs_tree_node_t *children;
124
128 sqfs_tree_node_t *next;
129
133 sqfs_inode_generic_t *inode;
134
138 sqfs_u32 uid;
139
143 sqfs_u32 gid;
144
148 sqfs_u8 name[];
149};
150
156 typedef enum {
171 SQFS_DIR_READER_DOT_ENTRIES = 0x00000001,
172
173 SQFS_DIR_READER_ALL_FLAGS = 0x00000001,
174} SQFS_DIR_READER_FLAGS;
175
181 typedef enum {
191 SQFS_DIR_OPEN_NO_DOT_ENTRIES = 0x00000001,
192
193 SQFS_DIR_OPEN_ALL_FLAGS = 0x00000001,
194} SQFS_DIR_OPEN_FLAGS;
195
196#ifdef __cplusplus
197extern "C" {
198#endif
199
217SQFS_API sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
218 sqfs_compressor_t *cmp,
219 sqfs_file_t *file,
220 sqfs_u32 flags);
221
250SQFS_API int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd,
251 const sqfs_inode_generic_t *inode,
252 sqfs_u32 flags);
253
263SQFS_API int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd);
264
276SQFS_API int sqfs_dir_reader_find(sqfs_dir_reader_t *rd, const char *name);
277
299SQFS_API int sqfs_dir_reader_read(sqfs_dir_reader_t *rd,
300 sqfs_dir_entry_t **out);
301
313SQFS_API int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd,
314 sqfs_inode_generic_t **inode);
315
327SQFS_API int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd,
328 sqfs_inode_generic_t **inode);
329
347SQFS_API int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd,
348 const sqfs_inode_generic_t *start,
349 const char *path,
350 sqfs_inode_generic_t **out);
351
371SQFS_API int sqfs_dir_reader_get_full_hierarchy(sqfs_dir_reader_t *rd,
372 const sqfs_id_table_t *idtbl,
373 const char *path,
374 sqfs_u32 flags,
375 sqfs_tree_node_t **out);
376
385SQFS_API void sqfs_dir_tree_destroy(sqfs_tree_node_t *root);
386
415SQFS_API int sqfs_tree_node_get_path(const sqfs_tree_node_t *node,
416 char **out);
417
418#ifdef __cplusplus
419}
420#endif
421
422#endif /* SQFS_DIR_READER_H */
SQFS_DIR_READER_FLAGS
SQFS_DIR_READER_FLAGS
Flags for sqfs_dir_reader_create.
Definition dir_reader.h:156
SQFS_DIR_READER_DOT_ENTRIES
@ SQFS_DIR_READER_DOT_ENTRIES
Support "." and ".." directory and path entries.
Definition dir_reader.h:171
SQFS_TREE_FILTER_FLAGS
SQFS_TREE_FILTER_FLAGS
Filter flags for sqfs_dir_reader_get_full_hierarchy.
Definition dir_reader.h:60
SQFS_TREE_STORE_PARENTS
@ SQFS_TREE_STORE_PARENTS
Store the list of parent nodes all the way to the target node.
Definition dir_reader.h:103
SQFS_TREE_NO_SLINKS
@ SQFS_TREE_NO_SLINKS
Omit symbolic links from the final tree.
Definition dir_reader.h:79
SQFS_TREE_NO_EMPTY
@ SQFS_TREE_NO_EMPTY
Omit empty directories from the final tree.
Definition dir_reader.h:87
SQFS_TREE_NO_FIFO
@ SQFS_TREE_NO_FIFO
Omit named pipes from the final tree.
Definition dir_reader.h:74
SQFS_TREE_NO_SOCKETS
@ SQFS_TREE_NO_SOCKETS
Omit socket files from the final tree.
Definition dir_reader.h:69
SQFS_TREE_NO_DEVICES
@ SQFS_TREE_NO_DEVICES
Omit device special files from the final tree.
Definition dir_reader.h:64
SQFS_TREE_NO_RECURSE
@ SQFS_TREE_NO_RECURSE
Do not recurse into sub directories.
Definition dir_reader.h:95
sqfs_dir_tree_destroy
SQFS_API void sqfs_dir_tree_destroy(sqfs_tree_node_t *root)
Recursively destroy a tree of sqfs_tree_node_t nodes.
SQFS_DIR_OPEN_FLAGS
SQFS_DIR_OPEN_FLAGS
Flags for sqfs_dir_reader_open_dir.
Definition dir_reader.h:181
SQFS_DIR_OPEN_NO_DOT_ENTRIES
@ SQFS_DIR_OPEN_NO_DOT_ENTRIES
Do not generate "." and ".." entries.
Definition dir_reader.h:191
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_reader_t
Abstracts reading of directory entries.
sqfs_dir_reader_t::sqfs_dir_reader_open_dir
SQFS_API int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd, const sqfs_inode_generic_t *inode, sqfs_u32 flags)
Navigate a directory reader to the location of a directory represented by an inode.
sqfs_dir_reader_t::sqfs_dir_reader_find_by_path
SQFS_API int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, const sqfs_inode_generic_t *start, const char *path, sqfs_inode_generic_t **out)
Find an inode through path traversal starting from the root or a given node downwards.
sqfs_dir_reader_t::sqfs_dir_reader_get_full_hierarchy
SQFS_API int sqfs_dir_reader_get_full_hierarchy(sqfs_dir_reader_t *rd, const sqfs_id_table_t *idtbl, const char *path, sqfs_u32 flags, sqfs_tree_node_t **out)
High level helper function for deserializing the entire file system hierarchy into an in-memory tree ...
sqfs_dir_reader_t::sqfs_dir_reader_rewind
SQFS_API int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd)
Reset a directory reader back to the beginning of the listing.
sqfs_dir_reader_t::sqfs_dir_reader_find
SQFS_API int sqfs_dir_reader_find(sqfs_dir_reader_t *rd, const char *name)
Seek through the current directory listing to locate an entry by name.
sqfs_dir_reader_t::sqfs_dir_reader_read
SQFS_API int sqfs_dir_reader_read(sqfs_dir_reader_t *rd, sqfs_dir_entry_t **out)
Read a directory entry and advance the internal position indicator to the next one.
sqfs_dir_reader_t::sqfs_dir_reader_get_root_inode
SQFS_API int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, sqfs_inode_generic_t **inode)
Read the root inode using the location given by the super block.
sqfs_dir_reader_t::sqfs_dir_reader_get_inode
SQFS_API int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd, sqfs_inode_generic_t **inode)
Read the inode that the current directory entry points to.
sqfs_dir_reader_t::sqfs_dir_reader_create
SQFS_API sqfs_dir_reader_t * sqfs_dir_reader_create(const sqfs_super_t *super, sqfs_compressor_t *cmp, sqfs_file_t *file, sqfs_u32 flags)
Create a directory reader.
sqfs_file_t
Abstracts file I/O to make it easy to embedd SquashFS.
Definition io.h:94
sqfs_id_table_t
A simple data structure that encapsulates ID to index mapping for user and group IDs.
sqfs_inode_generic_t
A generic inode structure that combines all others and provides additional information.
Definition inode.h:488
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
sqfs_tree_node_t
Encapsulates a node in the filesystem tree read by sqfs_dir_reader_get_full_hierarchy.
Definition dir_reader.h:114
sqfs_tree_node_t::parent
sqfs_tree_node_t * parent
Pointer to parent, NULL for the root node.
Definition dir_reader.h:118
sqfs_tree_node_t::children
sqfs_tree_node_t * children
For directories, a linked list of children.
Definition dir_reader.h:123
sqfs_tree_node_t::inode
sqfs_inode_generic_t * inode
Inode representing this element in the tree.
Definition dir_reader.h:133
sqfs_tree_node_t::name
sqfs_u8 name[]
null-terminated entry name.
Definition dir_reader.h:148
sqfs_tree_node_t::uid
sqfs_u32 uid
Resolved 32 bit user ID from the inode.
Definition dir_reader.h:138
sqfs_tree_node_t::sqfs_tree_node_get_path
SQFS_API int sqfs_tree_node_get_path(const sqfs_tree_node_t *node, char **out)
Recursively destroy a tree of sqfs_tree_node_t nodes.
sqfs_tree_node_t::next
sqfs_tree_node_t * next
Linked list next pointer for children list.
Definition dir_reader.h:128
sqfs_tree_node_t::gid
sqfs_u32 gid
Resolved 32 bit group ID from the inode.
Definition dir_reader.h:143