forked from CalebQ42/squashfs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
superblock.go
80 lines (65 loc) · 1.6 KB
/
superblock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package squashfs
import "math"
type superblock struct {
Magic uint32
InodeCount uint32
ModTime uint32
BlockSize uint32
FragCount uint32
CompType uint16
BlockLog uint16
Flags uint16
IdCount uint16
VerMaj uint16
VerMin uint16
RootInodeRef uint64
Size uint64
IdTableStart uint64
XattrTableStart uint64
InodeTableStart uint64
DirTableStart uint64
FragTableStart uint64
ExportTableStart uint64
}
func (s superblock) checkMagic() bool {
return s.Magic == 0x73717368
}
func (s superblock) checkBlockLog() bool {
return s.BlockLog == uint16(math.Log2(float64(s.BlockSize)))
}
func (s superblock) checkVersion() bool {
return s.VerMaj == 4 && s.VerMin == 0
}
func (s superblock) uncompressedInodes() bool {
return s.Flags&0x1 == 0x1
}
func (s superblock) uncompressedData() bool {
return s.Flags&0x2 == 0x2
}
func (s superblock) uncompressedFragments() bool {
return s.Flags&0x8 == 0x8
}
func (s superblock) noFragments() bool {
return s.Flags&0x10 == 0x10
}
func (s superblock) alwaysFragment() bool {
return s.Flags&0x20 == 0x20
}
func (s superblock) duplicates() bool {
return s.Flags&0x40 == 0x40
}
func (s superblock) exportable() bool {
return s.Flags&0x80 == 0x80
}
func (s superblock) uncompressedXattrs() bool {
return s.Flags&0x100 == 0x100
}
func (s superblock) noXattrs() bool {
return s.Flags&0x200 == 0x200
}
func (s superblock) compressionOptions() bool {
return s.Flags&0x400 == 0x400
}
func (s superblock) uncompressedIDs() bool {
return s.Flags&0x800 == 0x800
}