libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
Loading...
Searching...
No Matches
inode.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/*
3 * inode.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_INODE_H
21#define SQFS_INODE_H
22
23#include "sqfs/predef.h"
24
36typedef enum {
37 SQFS_INODE_DIR = 1,
38 SQFS_INODE_FILE = 2,
39 SQFS_INODE_SLINK = 3,
40 SQFS_INODE_BDEV = 4,
41 SQFS_INODE_CDEV = 5,
42 SQFS_INODE_FIFO = 6,
43 SQFS_INODE_SOCKET = 7,
44 SQFS_INODE_EXT_DIR = 8,
45 SQFS_INODE_EXT_FILE = 9,
46 SQFS_INODE_EXT_SLINK = 10,
47 SQFS_INODE_EXT_BDEV = 11,
48 SQFS_INODE_EXT_CDEV = 12,
49 SQFS_INODE_EXT_FIFO = 13,
50 SQFS_INODE_EXT_SOCKET = 14,
52
95typedef enum {
96 SQFS_INODE_OTHERS_X = 00001,
97 SQFS_INODE_OTHERS_W = 00002,
98 SQFS_INODE_OTHERS_R = 00004,
99 SQFS_INODE_OTHERS_MASK = 00007,
100
101 SQFS_INODE_GROUP_X = 00010,
102 SQFS_INODE_GROUP_W = 00020,
103 SQFS_INODE_GROUP_R = 00040,
104 SQFS_INODE_GROUP_MASK = 00070,
105
106 SQFS_INODE_OWNER_X = 00100,
107 SQFS_INODE_OWNER_W = 00200,
108 SQFS_INODE_OWNER_R = 00400,
109 SQFS_INODE_OWNER_MASK = 00700,
110
111 SQFS_INODE_STICKY = 01000,
112 SQFS_INODE_SET_GID = 02000,
113 SQFS_INODE_SET_UID = 04000,
114
115 SQFS_INODE_MODE_FIFO = 0010000,
116 SQFS_INODE_MODE_CHR = 0020000,
117 SQFS_INODE_MODE_DIR = 0040000,
118 SQFS_INODE_MODE_BLK = 0060000,
119 SQFS_INODE_MODE_REG = 0100000,
120 SQFS_INODE_MODE_LNK = 0120000,
121 SQFS_INODE_MODE_SOCK = 0140000,
122 SQFS_INODE_MODE_MASK = 0170000,
124
137 sqfs_u16 type;
138
145 sqfs_u16 mode;
146
150 sqfs_u16 uid_idx;
151
155 sqfs_u16 gid_idx;
156
164 sqfs_u32 mod_time;
165
169 sqfs_u32 inode_number;
170};
171
182 sqfs_u32 nlink;
183
187 sqfs_u32 devno;
188};
189
200 sqfs_u32 nlink;
201
205 sqfs_u32 devno;
206
210 sqfs_u32 xattr_idx;
211};
212
223 sqfs_u32 nlink;
224};
225
236 sqfs_u32 nlink;
237
241 sqfs_u32 xattr_idx;
242};
243
257 sqfs_u32 nlink;
258
262 sqfs_u32 target_size;
263
264 /*sqfs_u8 target[];*/
265};
266
280 sqfs_u32 nlink;
281
285 sqfs_u32 target_size;
286
287 /*sqfs_u8 target[];*/
288
292 sqfs_u32 xattr_idx;
293};
294
315 sqfs_u32 blocks_start;
316
321
327
331 sqfs_u32 file_size;
332
333 /*sqfs_u32 block_sizes[];*/
334};
335
347 sqfs_u64 blocks_start;
348
352 sqfs_u64 file_size;
353
358 sqfs_u64 sparse;
359
363 sqfs_u32 nlink;
364
368 sqfs_u32 fragment_idx;
369
375
379 sqfs_u32 xattr_idx;
380
381 /*sqfs_u32 block_sizes[];*/
382};
383
394 sqfs_u32 start_block;
395
399 sqfs_u32 nlink;
400
413 sqfs_u16 size;
414
419 sqfs_u16 offset;
420
425 sqfs_u32 parent_inode;
426};
427
437 sqfs_u32 nlink;
438
442 sqfs_u32 size;
443
448 sqfs_u32 start_block;
449
454 sqfs_u32 parent_inode;
455
462 sqfs_u16 inodex_count;
463
468 sqfs_u16 offset;
469
473 sqfs_u32 xattr_idx;
474};
475
493
501
510
514 union {
516 sqfs_inode_dev_ext_t dev_ext;
518 sqfs_inode_ipc_ext_t ipc_ext;
519 sqfs_inode_slink_t slink;
520 sqfs_inode_slink_ext_t slink_ext;
522 sqfs_inode_file_ext_t file_ext;
524 sqfs_inode_dir_ext_t dir_ext;
526
535 sqfs_u32 extra[];
536};
537
538#ifdef __cplusplus
539extern "C" {
540#endif
541
551static SQFS_INLINE
553{
554 return inode->payload_bytes_used / sizeof(sqfs_u32);
555}
556
572 sqfs_u32 *out);
573
591 sqfs_u32 index);
592
606
623
641 sqfs_u64 size);
642
660 sqfs_u64 location);
661
675 sqfs_u32 index, sqfs_u32 offset);
676
689 sqfs_u64 *size);
690
704 sqfs_u32 *index, sqfs_u32 *offset);
705
718 sqfs_u64 *location);
719
739SQFS_API
741 sqfs_dir_index_t **out,
742 size_t index);
743
744#ifdef __cplusplus
745}
746#endif
747
748#endif /* SQFS_INODE_H */
SQFS_INODE_TYPE
Used by sqfs_inode_t to identify the inode type.
Definition: inode.h:36
SQFS_INODE_MODE
Mode bits for the sqfs_inode_t mode field.
Definition: inode.h:95
Includes forward declarations of data structures, macros and integer types.
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_EXT_BDEV or SQFS_INODE_EXT_CDEV.
Definition: inode.h:196
sqfs_u32 xattr_idx
Extended attribute index.
Definition: inode.h:210
sqfs_u32 devno
Device number.
Definition: inode.h:205
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:200
Follows a sqfs_inode_t if type is SQFS_INODE_BDEV or SQFS_INODE_CDEV.
Definition: inode.h:178
sqfs_u32 devno
Device number.
Definition: inode.h:187
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:182
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_DIR.
Definition: inode.h:433
sqfs_u32 size
Size of all directory entries and headers in bytes plus 3.
Definition: inode.h:442
sqfs_u16 offset
Offset into the uncompressed start block where the header can be found.
Definition: inode.h:468
sqfs_u32 xattr_idx
Extended attribute index.
Definition: inode.h:473
sqfs_u16 inodex_count
Number of directory index entries following the inode.
Definition: inode.h:462
sqfs_u32 start_block
Offset from the directory table start to the location of the meta data block containing the first dir...
Definition: inode.h:448
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:437
sqfs_u32 parent_inode
Inode number of the parent directory containing this directory inode.
Definition: inode.h:454
Follows a sqfs_inode_t if type is SQFS_INODE_DIR.
Definition: inode.h:389
sqfs_u16 offset
Offset into the uncompressed start block where the header can be found.
Definition: inode.h:419
sqfs_u16 size
Combined size of all directory entries and headers in bytes.
Definition: inode.h:413
sqfs_u32 start_block
Offset from the directory table start to the location of the meta data block containing the first dir...
Definition: inode.h:394
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:399
sqfs_u32 parent_inode
Inode number of the parent directory containing this directory inode.
Definition: inode.h:425
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FILE.
Definition: inode.h:343
sqfs_u64 sparse
If the file is sparse, holds the number of bytes not written to disk because of the omitted sparse bl...
Definition: inode.h:358
sqfs_u64 blocks_start
Absolute position of the first data block.
Definition: inode.h:347
sqfs_u32 xattr_idx
Extended attribute index.
Definition: inode.h:379
sqfs_u32 fragment_idx
Index into the fragment table or 0xFFFFFFFF if unused.
Definition: inode.h:368
sqfs_u64 file_size
Total, uncompressed size of the file in bytes.
Definition: inode.h:352
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:363
sqfs_u32 fragment_offset
Offset into the uncompressed fragment block or 0xFFFFFFFF if unused.
Definition: inode.h:374
Follows a sqfs_inode_t if type is SQFS_INODE_FILE.
Definition: inode.h:311
sqfs_u32 fragment_index
Index into the fragment table or 0xFFFFFFFF if unused.
Definition: inode.h:320
sqfs_u32 blocks_start
Absolute position of the first data block.
Definition: inode.h:315
sqfs_u32 file_size
Total, uncompressed size of the file in bytes.
Definition: inode.h:331
sqfs_u32 fragment_offset
Offset into the uncompressed fragment block or 0xFFFFFFFF if unused.
Definition: inode.h:326
A generic inode structure that combines all others and provides additional information.
Definition: inode.h:488
union sqfs_inode_generic_t::@4 data
Type specific inode data.
sqfs_inode_t base
The common fields for all inodes.
Definition: inode.h:492
SQFS_API int sqfs_inode_set_frag_location(sqfs_inode_generic_t *inode, sqfs_u32 index, sqfs_u32 offset)
Update the file fragment location of a regular file inode.
static SQFS_INLINE size_t sqfs_inode_get_file_block_count(const sqfs_inode_generic_t *inode)
Get the number of file blocks in a regular file inode.
Definition: inode.h:552
SQFS_API int sqfs_inode_get_frag_location(const sqfs_inode_generic_t *inode, sqfs_u32 *index, sqfs_u32 *offset)
Get the file fragment location of a regular file inode.
SQFS_API int sqfs_inode_set_file_size(sqfs_inode_generic_t *inode, sqfs_u64 size)
Update the file size of a regular file inode.
sqfs_u32 payload_bytes_available
Maximum number of available data bytes in the payload.
Definition: inode.h:500
SQFS_API int sqfs_inode_make_basic(sqfs_inode_generic_t *inode)
Convert an extended inode to a basic inode if possible.
SQFS_API int sqfs_inode_get_file_size(const sqfs_inode_generic_t *inode, sqfs_u64 *size)
Get the file size of a regular file inode.
sqfs_u32 extra[]
Holds type specific extra data, such as symlink target.
Definition: inode.h:535
SQFS_API int sqfs_inode_get_file_block_start(const sqfs_inode_generic_t *inode, sqfs_u64 *location)
Get the location of the first data block of a regular file inode.
SQFS_API int sqfs_inode_set_xattr_index(sqfs_inode_generic_t *inode, sqfs_u32 index)
Set the extended attribute index of an inode.
sqfs_u32 payload_bytes_used
Number of used data bytes in the payload.
Definition: inode.h:509
SQFS_API int sqfs_inode_unpack_dir_index_entry(const sqfs_inode_generic_t *inode, sqfs_dir_index_t **out, size_t index)
Unpack the a directory index structure from an inode.
SQFS_API int sqfs_inode_get_xattr_index(const sqfs_inode_generic_t *inode, sqfs_u32 *out)
Get the extended attribute index of an inode.
SQFS_API int sqfs_inode_make_extended(sqfs_inode_generic_t *inode)
Convert a basic inode to an extended inode.
SQFS_API int sqfs_inode_set_file_block_start(sqfs_inode_generic_t *inode, sqfs_u64 location)
Update the location of the first data block of a regular file inode.
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FIFO or SQFS_INODE_EXT_SOCKET.
Definition: inode.h:232
sqfs_u32 xattr_idx
Extended attribute index.
Definition: inode.h:241
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:236
Follows a sqfs_inode_t if type is SQFS_INODE_FIFO or SQFS_INODE_SOCKET.
Definition: inode.h:219
sqfs_u32 nlink
Number of hard links to this node.
Definition: inode.h:223
Common inode structure.
Definition: inode.h:133
sqfs_u32 inode_number
Unique inode number.
Definition: inode.h:169
sqfs_u32 mod_time
Last modifcation time.
Definition: inode.h:164
sqfs_u16 mode
Mode filed holding permission bits only. The type is derived from the type field.
Definition: inode.h:145
sqfs_u16 uid_idx
An index into the ID table where the owner UID is located.
Definition: inode.h:150
sqfs_u16 type
An SQFS_INODE_TYPE value.
Definition: inode.h:137
sqfs_u16 gid_idx
An index into the ID table where the owner GID is located.
Definition: inode.h:155