libsquashfs  1.3.2
A new set of tools and libraries for working with SquashFS images
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 
60 typedef enum {
65 
70 
75 
80 
88 
96 
104 
105  SQFS_TREE_ALL_FLAGS = 0x7F,
107 
119 
124 
129 
134 
138  sqfs_u32 uid;
139 
143  sqfs_u32 gid;
144 
148  sqfs_u8 name[];
149 };
150 
156 typedef enum {
172 
173  SQFS_DIR_READER_ALL_FLAGS = 0x00000001,
175 
181 typedef enum {
192 
193  SQFS_DIR_OPEN_ALL_FLAGS = 0x00000001,
195 
196 #ifdef __cplusplus
197 extern "C" {
198 #endif
199 
218  sqfs_compressor_t *cmp,
219  sqfs_file_t *file,
220  sqfs_u32 flags);
221 
251  const sqfs_inode_generic_t *inode,
252  sqfs_u32 flags);
253 
263 SQFS_API int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd);
264 
276 SQFS_API int sqfs_dir_reader_find(sqfs_dir_reader_t *rd, const char *name);
277 
299 SQFS_API int sqfs_dir_reader_read(sqfs_dir_reader_t *rd,
300  sqfs_dir_entry_t **out);
301 
314  sqfs_inode_generic_t **inode);
315 
328  sqfs_inode_generic_t **inode);
329 
348  const sqfs_inode_generic_t *start,
349  const char *path,
350  sqfs_inode_generic_t **out);
351 
372  const sqfs_id_table_t *idtbl,
373  const char *path,
374  sqfs_u32 flags,
375  sqfs_tree_node_t **out);
376 
385 SQFS_API void sqfs_dir_tree_destroy(sqfs_tree_node_t *root);
386 
415 SQFS_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_tree_node_t * children
For directories, a linked list of children.
Definition: dir_reader.h:123
SQFS_API void sqfs_dir_tree_destroy(sqfs_tree_node_t *root)
Recursively destroy a tree of sqfs_tree_node_t nodes.
Omit empty directories from the final tree.
Definition: dir_reader.h:87
Omit socket files from the final tree.
Definition: dir_reader.h:69
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_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 ...
Encapsultes a compressor with a simple interface to compress or extract chunks of data...
Definition: compressor.h:40
Store the list of parent nodes all the way to the target node.
Definition: dir_reader.h:103
Omit symbolic links from the final tree.
Definition: dir_reader.h:79
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition: super.h:47
Encapsulates a node in the filesystem tree read by sqfs_dir_reader_get_full_hierarchy.
Definition: dir_reader.h:114
Abstracts file I/O to make it easy to embedd SquashFS.
Definition: io.h:94
sqfs_inode_generic_t * inode
Inode representing this element in the tree.
Definition: dir_reader.h:133
sqfs_tree_node_t * next
Linked list next pointer for children list.
Definition: dir_reader.h:128
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_tree_node_t * parent
Pointer to parent, NULL for the root node.
Definition: dir_reader.h:118
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.
Omit named pipes from the final tree.
Definition: dir_reader.h:74
SQFS_API int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd)
Reset a directory reader back to the beginning of the listing.
Do not recurse into sub directories.
Definition: dir_reader.h:95
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_DIR_READER_FLAGS
Flags for sqfs_dir_reader_create.
Definition: dir_reader.h:156
SQFS_DIR_OPEN_FLAGS
Flags for sqfs_dir_reader_open_dir.
Definition: dir_reader.h:181
Abstracts reading of directory entries.
sqfs_u32 uid
Resolved 32 bit user ID from the inode.
Definition: dir_reader.h:138
A simple data structure that encapsulates ID to index mapping for user and group IDs.
Do not generate "." and ".." entries.
Definition: dir_reader.h:191
Support "." and ".." directory and path entries.
Definition: dir_reader.h:171
SQFS_TREE_FILTER_FLAGS
Filter flags for sqfs_dir_reader_get_full_hierarchy.
Definition: dir_reader.h:60
On-disk data structure of a directory entry. Many of these follow a single sqfs_dir_header_t.
Definition: dir.h:74
sqfs_u32 gid
Resolved 32 bit group ID from the inode.
Definition: dir_reader.h:143
Includes forward declarations of data structures, macros and integer types.
Omit device special files from the final tree.
Definition: dir_reader.h:64
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_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_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.
A generic inode structure that combines all others and provides additional information.
Definition: inode.h:488
sqfs_u8 name[]
null-terminated entry name.
Definition: dir_reader.h:148
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.