libsquashfs 1.3.0
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
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
51 sqfs_u32 magic;
52
56 sqfs_u32 inode_count;
57
66
72 sqfs_u32 block_size;
73
78
85
91 sqfs_u16 block_log;
92
98 sqfs_u16 flags;
99
103 sqfs_u16 id_count;
104
109
114
123
127 sqfs_u64 bytes_used;
128
137
148
156
165
174
184};
185
194typedef 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,
205
211typedef enum {
217
222
228
233
239
244
249
255
261
267
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 */
Includes forward declarations of data structures, macros and integer types.
Abstracts file I/O to make it easy to embedd SquashFS.
Definition: io.h:94
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition: super.h:47
sqfs_u32 inode_count
Total number of inodes.
Definition: super.h:56
sqfs_u16 id_count
The total number of unique user or group IDs.
Definition: super.h:103
sqfs_u16 version_major
Must be SQFS_VERSION_MAJOR.
Definition: super.h:108
sqfs_u64 id_table_start
On-disk location of the ID table.
Definition: super.h:136
sqfs_u32 magic
Magic number. Must be set to SQFS_MAGIC.
Definition: super.h:51
sqfs_u16 block_log
The log2 of the block_size field for sanity checking.
Definition: super.h:91
sqfs_u64 directory_table_start
On-disk location of the first meta data block containing the directory entries.
Definition: super.h:164
sqfs_u32 fragment_entry_count
The number of fragment blocks in the data area.
Definition: super.h:77
sqfs_u64 bytes_used
Total size of the file system in bytes, not counting padding.
Definition: super.h:127
sqfs_u16 version_minor
Must be SQFS_VERSION_MINOR.
Definition: super.h:113
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_u32 modification_time
Last time the filesystem was modified.
Definition: super.h:65
sqfs_u16 flags
A combination of SQFS_SUPER_FLAGS flags.
Definition: super.h:98
sqfs_u64 xattr_id_table_start
On-disk location of the extended attribute table (if present)
Definition: super.h:147
sqfs_u64 export_table_start
On-disk location of the export table (if present)
Definition: super.h:183
sqfs_u64 fragment_table_start
On-disk location of the fragment table (if present)
Definition: super.h:173
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_u64 inode_table_start
On-disk location of the first meta data block containing the inodes.
Definition: super.h:155
sqfs_u16 compression_id
Identifies the compressor that has been used.
Definition: super.h:84
sqfs_u32 block_size
The data block size in bytes.
Definition: super.h:72
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_u64 root_inode_ref
A reference to the root inode.
Definition: super.h:122
SQFS_SUPER_FLAGS
Flags that can be set in sqfs_super flags field.
Definition: super.h:211
@ 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
Set to indicate that all data blocks are stored uncompressed.
Definition: super.h:221
@ SQFS_FLAG_NO_FRAGMENTS
Set to indicate that there are no fragment blocks.
Definition: super.h:232
@ 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
Set to indicate that a single, uncompressed meta data block with compressor options follows the super...
Definition: super.h:266
@ SQFS_FLAG_EXPORTABLE
Set to indicate that an NFS export table is present.
Definition: super.h:248
@ SQFS_FLAG_UNCOMPRESSED_FRAGMENTS
Set to indicate that all fragment blocks are stored uncompressed.
Definition: super.h:227
@ SQFS_FLAG_NO_XATTRS
Set to indicate that the filesystem does not contain extended attributes.
Definition: super.h:260
@ 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
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
Set to indicate that data blocks have not been deduplicated.
Definition: super.h:243
SQFS_COMPRESSOR
Set in sqfs_super_t to identify the compresser used by the filesystem.
Definition: super.h:194