Files
squashfs/superblock.go
T
Caleb Gardner 7a2f9a87ba Re-wrote a bunch to try to figure out why things weren't working.
Turned out I was reading if a block was compressed exactly opposite.
Started to work more on looking up dirs.
2020-11-16 14:56:19 -06:00

65 lines
1.6 KiB
Go

package squashfs
const (
gzipCompression = 1 + iota
lzmaCompression
lzoCompression
xzCompression
lz4Compression
zstdCompression
)
type Superblock struct {
Magic uint32
InodeCount uint32
CreationTime uint32
BlockSize uint32
FragCount uint32
CompressionType uint16
BlockLog uint16
Flags uint16
IDCount uint16
MajorVersion uint16
MinorVersion uint16
RootInodeRef uint64
BytesUsed uint64
IDTableStart uint64
XattrTableStart uint64
InodeTableStart uint64
DirTableStart uint64
FragTableStart uint64
ExportTableStart uint64
}
type SuperblockFlags struct {
UncompressedInodes bool
UncompressedData bool
Check bool
UncompressedFragments bool
NoFragments bool
AlwaysFragments bool
Duplicates bool
Exportable bool
UncompressedXattr bool
NoXattr bool
CompressorOptions bool
UncompressedIDs bool
}
func (s *Superblock) GetFlags() SuperblockFlags {
return SuperblockFlags{
UncompressedInodes: s.Flags&0x1 == 0x1,
UncompressedData: s.Flags&0x2 == 0x2,
Check: s.Flags&0x4 == 0x4,
UncompressedFragments: s.Flags&0x8 == 0x8,
NoFragments: s.Flags&0x10 == 0x10,
AlwaysFragments: s.Flags&0x20 == 0x20,
Duplicates: s.Flags&0x40 == 0x40,
Exportable: s.Flags&0x80 == 0x80,
UncompressedXattr: s.Flags&0x100 == 0x100,
NoXattr: s.Flags&0x200 == 0x200,
CompressorOptions: s.Flags&0x400 == 0x400,
UncompressedIDs: s.Flags&0x800 == 0x800,
}
}