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.
This commit is contained in:
+34
-30
@@ -1,48 +1,52 @@
|
||||
package squashfs
|
||||
|
||||
const squashfsMagic = 0x73717368
|
||||
const (
|
||||
gzipCompression = 1 + iota
|
||||
lzmaCompression
|
||||
lzoCompression
|
||||
xzCompression
|
||||
lz4Compression
|
||||
zstdCompression
|
||||
)
|
||||
|
||||
//Superblock is a raw representation of a squashfs
|
||||
//Descriptions provided by https://dr-emann.github.io/squashfs/
|
||||
type Superblock struct {
|
||||
Magic uint32 //Magic will be 0x73717368 if it's a legit Squashfs filesystem
|
||||
Inodes uint32 //Inodes is the number of inodes in the inodes table
|
||||
MkfsTime uint32 //MkfsTime is when archive was created
|
||||
BlockSize uint32 //BlockSize is the size of data blocks in bytes
|
||||
Fragments uint32 //Fragments is the number of entries in fragment table
|
||||
Compression uint16 //Compression is what type of compression is used
|
||||
BlockLog uint16 //BlockLog should be log base 2 of BlockSize. If not then the squash might be corrupt
|
||||
Flags uint16 //Flags are the superblock's flags
|
||||
IDCount uint16 //IDCount is the number of IDs in the id lookup table
|
||||
Major uint16 //Major version of squashfs format
|
||||
Minor uint16 //Minor version of squashfs format
|
||||
RootInode uint64 //RootInode is a reference to the root of the squashfs
|
||||
BytesUsed uint64 //BytesUsed is how many bytes the archive is. squashfs archives are often padded to 4KB.
|
||||
IDTableOffset uint64 //IDTableOff is the byte offset of the IDTable
|
||||
XattrIDTableOffset uint64 //XattrIDTableOffset is the byte offset of the xattr id table
|
||||
InodeTableOffset uint64 //InodeTableOffset is the byte offset of the inode table
|
||||
DirectoryTableOffset uint64 //DirectoryTableOffset is the byte offset of the directory table
|
||||
FragmentTableOffset uint64 //FragmentTableOffset is the byte offset of the fragment table
|
||||
ExportTableOffset uint64 //ExportTableOffset is the byte offset of the export table
|
||||
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
|
||||
}
|
||||
|
||||
//SuperblockFlags is a parsed list of options set in Superblock.Flags
|
||||
type SuperblockFlags struct {
|
||||
UncompressedInodes bool
|
||||
UncompressedData bool
|
||||
Check bool //Check is unused in current versions of squashfs
|
||||
Check bool
|
||||
UncompressedFragments bool
|
||||
NoFragments bool
|
||||
AlwaysFragments bool
|
||||
Duplicates bool //Identical files are stored only once
|
||||
Duplicates bool
|
||||
Exportable bool
|
||||
UncompressedXattrs bool
|
||||
NoXattrs bool
|
||||
UncompressedXattr bool
|
||||
NoXattr bool
|
||||
CompressorOptions bool
|
||||
UncompressedIDs bool
|
||||
}
|
||||
|
||||
func (s *Superblock) getFlags() SuperblockFlags {
|
||||
func (s *Superblock) GetFlags() SuperblockFlags {
|
||||
return SuperblockFlags{
|
||||
UncompressedInodes: s.Flags&0x1 == 0x1,
|
||||
UncompressedData: s.Flags&0x2 == 0x2,
|
||||
@@ -52,8 +56,8 @@ func (s *Superblock) getFlags() SuperblockFlags {
|
||||
AlwaysFragments: s.Flags&0x20 == 0x20,
|
||||
Duplicates: s.Flags&0x40 == 0x40,
|
||||
Exportable: s.Flags&0x80 == 0x80,
|
||||
UncompressedXattrs: s.Flags&0x100 == 0x100,
|
||||
NoXattrs: s.Flags&0x200 == 0x200,
|
||||
UncompressedXattr: s.Flags&0x100 == 0x100,
|
||||
NoXattr: s.Flags&0x200 == 0x200,
|
||||
CompressorOptions: s.Flags&0x400 == 0x400,
|
||||
UncompressedIDs: s.Flags&0x800 == 0x800,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user