libsquashfs: include/sqfs/super.h Source File

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

Loading...
Searching...
No Matches
super.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/*
3 * super.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_SUPER_H
21#define SQFS_SUPER_H
22
23#include "sqfs/predef.h"
24
31
32#define SQFS_MAGIC 0x73717368
33#define SQFS_VERSION_MAJOR 4
34#define SQFS_VERSION_MINOR 0
35#define SQFS_DEVBLK_SIZE 4096
36
37#define SQFS_MIN_BLOCK_SIZE (4 * 1024)
38#define SQFS_MAX_BLOCK_SIZE (1024 * 1024)
39#define SQFS_DEFAULT_BLOCK_SIZE (128 * 1024)
40
47 struct sqfs_super_t {
51 sqfs_u32 magic;
52
56 sqfs_u32 inode_count;
57
65 sqfs_u32 modification_time;
66
72 sqfs_u32 block_size;
73
77 sqfs_u32 fragment_entry_count;
78
84 sqfs_u16 compression_id;
85
91 sqfs_u16 block_log;
92
98 sqfs_u16 flags;
99
103 sqfs_u16 id_count;
104
108 sqfs_u16 version_major;
109
113 sqfs_u16 version_minor;
114
122 sqfs_u64 root_inode_ref;
123
127 sqfs_u64 bytes_used;
128
136 sqfs_u64 id_table_start;
137
147 sqfs_u64 xattr_id_table_start;
148
155 sqfs_u64 inode_table_start;
156
164 sqfs_u64 directory_table_start;
165
173 sqfs_u64 fragment_table_start;
174
183 sqfs_u64 export_table_start;
184};
185
194 typedef enum {
195 SQFS_COMP_GZIP = 1,
196 SQFS_COMP_LZMA = 2,
197 SQFS_COMP_LZO = 3,
198 SQFS_COMP_XZ = 4,
199 SQFS_COMP_LZ4 = 5,
200 SQFS_COMP_ZSTD = 6,
201
202 SQFS_COMP_MIN = 1,
203 SQFS_COMP_MAX = 6,
204} SQFS_COMPRESSOR;
205
211 typedef enum {
216 SQFS_FLAG_UNCOMPRESSED_INODES = 0x0001,
217
221 SQFS_FLAG_UNCOMPRESSED_DATA = 0x0002,
222
227 SQFS_FLAG_UNCOMPRESSED_FRAGMENTS = 0x0008,
228
232 SQFS_FLAG_NO_FRAGMENTS = 0x0010,
233
238 SQFS_FLAG_ALWAYS_FRAGMENTS = 0x0020,
239
243 SQFS_FLAG_NO_DUPLICATES = 0x0040,
244
248 SQFS_FLAG_EXPORTABLE = 0x0080,
249
254 SQFS_FLAG_UNCOMPRESSED_XATTRS = 0x0100,
255
260 SQFS_FLAG_NO_XATTRS = 0x0200,
261
266 SQFS_FLAG_COMPRESSOR_OPTIONS = 0x0400,
267
272 SQFS_FLAG_UNCOMPRESSED_IDS = 0x0800,
273} SQFS_SUPER_FLAGS;
274
275#ifdef __cplusplus
276extern "C" {
277#endif
278
292SQFS_API int sqfs_super_init(sqfs_super_t *super, size_t block_size,
293 sqfs_u32 mtime,
294 SQFS_COMPRESSOR compressor);
295
307SQFS_API int sqfs_super_write(const sqfs_super_t *super, sqfs_file_t *file);
308
320SQFS_API int sqfs_super_read(sqfs_super_t *super, sqfs_file_t *file);
321
322#ifdef __cplusplus
323}
324#endif
325
326#endif /* SQFS_SUPER_H */
predef.h
Includes forward declarations of data structures, macros and integer types.
sqfs_file_t
Abstracts file I/O to make it easy to embedd SquashFS.
Definition io.h:94
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_super_t::inode_count
sqfs_u32 inode_count
Total number of inodes.
Definition super.h:56
sqfs_super_t::id_count
sqfs_u16 id_count
The total number of unique user or group IDs.
Definition super.h:103
sqfs_super_t::version_major
sqfs_u16 version_major
Must be SQFS_VERSION_MAJOR.
Definition super.h:108
sqfs_super_t::id_table_start
sqfs_u64 id_table_start
On-disk location of the ID table.
Definition super.h:136
sqfs_super_t::magic
sqfs_u32 magic
Magic number. Must be set to SQFS_MAGIC.
Definition super.h:51
sqfs_super_t::block_log
sqfs_u16 block_log
The log2 of the block_size field for sanity checking.
Definition super.h:91
sqfs_super_t::directory_table_start
sqfs_u64 directory_table_start
On-disk location of the first meta data block containing the directory entries.
Definition super.h:164
sqfs_super_t::fragment_entry_count
sqfs_u32 fragment_entry_count
The number of fragment blocks in the data area.
Definition super.h:77
sqfs_super_t::bytes_used
sqfs_u64 bytes_used
Total size of the file system in bytes, not counting padding.
Definition super.h:127
sqfs_super_t::version_minor
sqfs_u16 version_minor
Must be SQFS_VERSION_MINOR.
Definition super.h:113
sqfs_super_t::sqfs_super_write
SQFS_API int sqfs_super_write(const sqfs_super_t *super, sqfs_file_t *file)
Encode and write a SquashFS super block to disk.
sqfs_super_t::modification_time
sqfs_u32 modification_time
Last time the filesystem was modified.
Definition super.h:65
sqfs_super_t::flags
sqfs_u16 flags
A combination of SQFS_SUPER_FLAGS flags.
Definition super.h:98
sqfs_super_t::xattr_id_table_start
sqfs_u64 xattr_id_table_start
On-disk location of the extended attribute table (if present).
Definition super.h:147
sqfs_super_t::export_table_start
sqfs_u64 export_table_start
On-disk location of the export table (if present).
Definition super.h:183
sqfs_super_t::fragment_table_start
sqfs_u64 fragment_table_start
On-disk location of the fragment table (if present).
Definition super.h:173
sqfs_super_t::sqfs_super_read
SQFS_API int sqfs_super_read(sqfs_super_t *super, sqfs_file_t *file)
Read a SquashFS super block from disk, decode it and check the fields.
sqfs_super_t::inode_table_start
sqfs_u64 inode_table_start
On-disk location of the first meta data block containing the inodes.
Definition super.h:155
sqfs_super_t::compression_id
sqfs_u16 compression_id
Identifies the compressor that has been used.
Definition super.h:84
sqfs_super_t::block_size
sqfs_u32 block_size
The data block size in bytes.
Definition super.h:72
sqfs_super_t::sqfs_super_init
SQFS_API int sqfs_super_init(sqfs_super_t *super, size_t block_size, sqfs_u32 mtime, SQFS_COMPRESSOR compressor)
Initialize the SquashFS super block.
sqfs_super_t::root_inode_ref
sqfs_u64 root_inode_ref
A reference to the root inode.
Definition super.h:122
SQFS_SUPER_FLAGS
SQFS_SUPER_FLAGS
Flags that can be set in sqfs_super flags field.
Definition super.h:211
SQFS_FLAG_UNCOMPRESSED_IDS
@ SQFS_FLAG_UNCOMPRESSED_IDS
Set to indicate that meta data blocks holding the IDs are stored uncompressed.
Definition super.h:272
SQFS_FLAG_UNCOMPRESSED_DATA
@ SQFS_FLAG_UNCOMPRESSED_DATA
Set to indicate that all data blocks are stored uncompressed.
Definition super.h:221
SQFS_FLAG_NO_FRAGMENTS
@ SQFS_FLAG_NO_FRAGMENTS
Set to indicate that there are no fragment blocks.
Definition super.h:232
SQFS_FLAG_UNCOMPRESSED_XATTRS
@ SQFS_FLAG_UNCOMPRESSED_XATTRS
Set to indicate that meta data blocks holding extended attributes are stored uncompressed.
Definition super.h:254
SQFS_FLAG_COMPRESSOR_OPTIONS
@ SQFS_FLAG_COMPRESSOR_OPTIONS
Set to indicate that a single, uncompressed meta data block with compressor options follows the super...
Definition super.h:266
SQFS_FLAG_EXPORTABLE
@ SQFS_FLAG_EXPORTABLE
Set to indicate that an NFS export table is present.
Definition super.h:248
SQFS_FLAG_UNCOMPRESSED_FRAGMENTS
@ SQFS_FLAG_UNCOMPRESSED_FRAGMENTS
Set to indicate that all fragment blocks are stored uncompressed.
Definition super.h:227
SQFS_FLAG_NO_XATTRS
@ SQFS_FLAG_NO_XATTRS
Set to indicate that the filesystem does not contain extended attributes.
Definition super.h:260
SQFS_FLAG_UNCOMPRESSED_INODES
@ SQFS_FLAG_UNCOMPRESSED_INODES
Set to indicate that meta data blocks holding the inodes are stored uncompressed.
Definition super.h:216
SQFS_FLAG_ALWAYS_FRAGMENTS
@ SQFS_FLAG_ALWAYS_FRAGMENTS
Set to indicate that fragments have been generated for all files that are not a multiple of the block...
Definition super.h:238
SQFS_FLAG_NO_DUPLICATES
@ SQFS_FLAG_NO_DUPLICATES
Set to indicate that data blocks have not been deduplicated.
Definition super.h:243
SQFS_COMPRESSOR
SQFS_COMPRESSOR
Set in sqfs_super_t to identify the compresser used by the filesystem.
Definition super.h:194