blob: 14fccda07c8c675c303abec47e9089d615a1ca32 [file] [log] [blame]
Tim Windelschmidt6d33a432025-02-04 14:34:25 +01001// Copyright The Monogon Project Authors.
Lorenz Brun378a4452021-01-26 13:47:41 +01002// SPDX-License-Identifier: Apache-2.0
Lorenz Brun378a4452021-01-26 13:47:41 +01003
4package erofs
5
Serge Bazanski216fe7b2021-05-21 18:36:16 +02006// This file contains definitions coming from the in-Kernel implementation of
7// the EROFS filesystem. All definitions come from @linux//fs/erofs:erofs_fs.h
8// unless stated otherwise.
Lorenz Brun378a4452021-01-26 13:47:41 +01009
Serge Bazanski216fe7b2021-05-21 18:36:16 +020010// Magic contains the 4 magic bytes starting at position 1024 identifying an
11// EROFS filesystem. Defined in @linux//include/uapi/linux/magic.h
12// EROFS_SUPER_MAGIC_V1
Lorenz Brun378a4452021-01-26 13:47:41 +010013var Magic = [4]byte{0xe2, 0xe1, 0xf5, 0xe0}
14
15const blockSizeBits = 12
16const BlockSize = 1 << blockSizeBits
17
18// Defined in @linux//include/linux:fs_types.h starting at FT_UNKNOWN
19const (
20 fileTypeUnknown = iota
21 fileTypeRegularFile
22 fileTypeDirectory
23 fileTypeCharacterDevice
24 fileTypeBlockDevice
25 fileTypeFIFO
26 fileTypeSocket
27 fileTypeSymbolicLink
28)
29
30// Anonymous enum starting at EROFS_INODE_FLAT_PLAIN
31const (
32 inodeFlatPlain = 0
33 inodeFlatCompressionLegacy = 1
34 inodeFlatInline = 2
35 inodeFlatCompression = 3
36)
37
38// struct erofs_dirent
39type directoryEntryRaw struct {
40 NodeNumber uint64
41 NameStartOffset uint16
42 FileType uint8
43 Reserved uint8
44}
45
46// struct erofs_super_block
47type superblock struct {
48 Magic [4]byte
49 Checksum uint32
50 FeatureCompat uint32
51 BlockSizeBits uint8
52 Reserved0 uint8
53 RootNodeNumber uint16
54 TotalInodes uint64
55 BuildTimeSeconds uint64
56 BuildTimeNanoseconds uint32
57 Blocks uint32
58 MetaStartAddr uint32
59 SharedXattrStartAddr uint32
60 UUID [16]byte
61 VolumeName [16]byte
62 FeaturesIncompatible uint32
63 Reserved1 [44]byte
64}
65
66// struct erofs_inode_compact
67type inodeCompact struct {
68 Format uint16
69 XattrCount uint16
70 Mode uint16
71 HardlinkCount uint16
72 Size uint32
73 Reserved0 uint32
74 Union uint32
75 InodeNumCompat uint32
76 UID uint16
77 GID uint16
78 Reserved1 uint32
79}
80
81// Anonymous enum starting at Z_EROFS_VLE_CLUSTER_TYPE_PLAIN
82const (
83 vleClusterTypePlain = iota << 12
84 vleClusterTypeHead
85 vleClusterTypeNonhead
86)