libsquashfs  1.3.2
A new set of tools and libraries for working with SquashFS images
predef.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-3.0-or-later */
2 /*
3  * predef.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_PREDEF_H
21 #define SQFS_PREDEF_H
22 
30 #include <stdbool.h>
31 #include <stddef.h>
32 #include <stdint.h>
33 
34 #if defined(_WIN32) || defined(__CYGWIN__)
35  #if defined(SQFS_STATIC)
36  #define SQFS_API
37  #elif defined(SQFS_BUILDING_DLL)
38  #if defined(__GNUC__) || defined(__clang__)
39  #define SQFS_API __attribute__ ((dllexport))
40  #else
41  #define SQFS_API __declspec(dllexport)
42  #endif
43  #else
44  #if defined(__GNUC__) || defined(__clang__)
45  #define SQFS_API __attribute__ ((dllimport))
46  #else
47  #define SQFS_API __declspec(dllimport)
48  #endif
49  #endif
50 
51  #define SQFS_INTERNAL
52 #else
53  #if defined(__GNUC__) || defined(__clang__)
54  #define SQFS_API __attribute__ ((visibility ("default")))
55  #define SQFS_INTERNAL __attribute__ ((visibility ("hidden")))
56  #else
57  #define SQFS_API
58  #define SQFS_INTERNAL
59  #endif
60 #endif
61 
62 #ifdef _MSC_VER
63  #define SQFS_INLINE __forceinline
64 #else
65  #define SQFS_INLINE __inline__ __attribute__((always_inline))
66 #endif
67 
68 typedef uint8_t sqfs_u8;
69 typedef uint16_t sqfs_u16;
70 typedef uint32_t sqfs_u32;
71 typedef uint64_t sqfs_u64;
72 
73 typedef int8_t sqfs_s8;
74 typedef int16_t sqfs_s16;
75 typedef int32_t sqfs_s32;
76 typedef int64_t sqfs_s64;
77 
83 typedef struct sqfs_id_table_t sqfs_id_table_t;
87 typedef struct sqfs_file_t sqfs_file_t;
88 typedef struct sqfs_tree_node_t sqfs_tree_node_t;
90 typedef struct sqfs_block_hooks_t sqfs_block_hooks_t;
94 typedef struct sqfs_block_writer_stats_t sqfs_block_writer_stats_t;
98 
99 typedef struct sqfs_fragment_t sqfs_fragment_t;
100 typedef struct sqfs_dir_header_t sqfs_dir_header_t;
101 typedef struct sqfs_dir_entry_t sqfs_dir_entry_t;
102 typedef struct sqfs_dir_index_t sqfs_dir_index_t;
103 typedef struct sqfs_inode_t sqfs_inode_t;
104 typedef struct sqfs_inode_dev_t sqfs_inode_dev_t;
106 typedef struct sqfs_inode_ipc_t sqfs_inode_ipc_t;
110 typedef struct sqfs_inode_file_t sqfs_inode_file_t;
112 typedef struct sqfs_inode_dir_t sqfs_inode_dir_t;
115 typedef struct sqfs_super_t sqfs_super_t;
118 typedef struct sqfs_xattr_id_t sqfs_xattr_id_t;
120 
126 typedef struct sqfs_object_t {
127  void (*destroy)(struct sqfs_object_t *instance);
128 
129  struct sqfs_object_t *(*copy)(const struct sqfs_object_t *orig);
130 } sqfs_object_t;
131 
139 static SQFS_INLINE void sqfs_destroy(void *obj)
140 {
141  if (obj)
142  ((sqfs_object_t *)obj)->destroy((sqfs_object_t *)obj);
143 }
144 
155 static SQFS_INLINE void *sqfs_copy(const void *obj)
156 {
157  if (((const sqfs_object_t *)obj)->copy != NULL) {
158  return ((const sqfs_object_t *)obj)->
159  copy((const sqfs_object_t *)obj);
160  }
161 
162  return NULL;
163 }
164 
165 #ifdef __cplusplus
166 extern "C" {
167 #endif
168 
202 SQFS_API void sqfs_free(void *ptr);
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif /* SQFS_PREDEF_H */
Common inode structure.
Definition: inode.h:133
Configuration parameters for instantiating a compressor backend.
Definition: compressor.h:106
On-disk data structure that holds a single xattr value.
Definition: xattr.h:78
static SQFS_INLINE void * sqfs_copy(const void *obj)
Create a deep copy of an object if possible.
Definition: predef.h:155
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_BDEV or SQFS_INODE_EXT_CDEV.
Definition: inode.h:196
Abstracts reading, writing and management of the fragment table.
Encapsultes a compressor with a simple interface to compress or extract chunks of data...
Definition: compressor.h:40
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_DIR.
Definition: inode.h:433
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition: super.h:47
Abstracts writing of extended attributes to a SquashFS filesystem.
Encapsulates state for simple directory reading.
Definition: meta_reader.h:56
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
On-disk data structure that holds a single xattr key.
Definition: xattr.h:53
On-disk data structure that the super block points to.
Definition: xattr.h:127
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FILE.
Definition: inode.h:343
On-disk data structure that describes a set of key-value pairs.
Definition: xattr.h:94
Abstracts generating of meta data blocks, either in memory or directly on disk.
Follows a sqfs_inode_t if type is SQFS_INODE_DIR.
Definition: inode.h:389
SQFS_API void sqfs_free(void *ptr)
Free a block of memory created by the squashfs library.
Used to store runtime statistics about the sqfs_block_processor_t.
Encapsulates a description for an sqfs_block_processor_t.
Abstracts access to data blocks stored in a SquashFS image.
Follows a sqfs_inode_t if type is SQFS_INODE_BDEV or SQFS_INODE_CDEV.
Definition: inode.h:178
Data structure that makes up the fragment table entries.
Definition: block.h:42
Base interface for all libsquashfs in-memory data structures.
Definition: predef.h:126
Abstracts generating of file data and fragment blocks.
On-disk data structure of a directory header.
Definition: dir.h:42
Abstracts reading of directory entries.
Follows a sqfs_inode_t if type is SQFS_INODE_FIFO or SQFS_INODE_SOCKET.
Definition: inode.h:219
Abstracts writing and deduplicating of data and fragment blocks.
Definition: block_writer.h:42
A simple data structure that encapsulates ID to index mapping for user and group IDs.
Abstracts read access to extended attributes in a SquashFS filesystem.
On-disk data structure of a directory index. A series of those can follow an sqfs_inode_dir_ext_t.
Definition: dir.h:115
Follows a sqfs_inode_t if type is SQFS_INODE_FILE.
Definition: inode.h:311
On-disk data structure of a directory entry. Many of these follow a single sqfs_dir_header_t.
Definition: dir.h:74
Abstracts generating of directory entries.
Abstracts reading of meta data blocks.
static SQFS_INLINE void sqfs_destroy(void *obj)
Destroy an object and free all its memory.
Definition: predef.h:139
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FIFO or SQFS_INODE_EXT_SOCKET.
Definition: inode.h:232
A generic inode structure that combines all others and provides additional information.
Definition: inode.h:488