Minor tweaks

This commit is contained in:
Caleb Gardner
2025-06-06 14:27:35 -05:00
parent 0905141013
commit b2c8084f41
6 changed files with 33 additions and 21 deletions
+12 -12
View File
@@ -20,10 +20,10 @@ func ReadFile(r io.Reader, blockSize uint32) (f File, err error) {
if err != nil {
return
}
f.BlockStart = binary.LittleEndian.Uint32(dat)
f.FragInd = binary.LittleEndian.Uint32(dat[4:])
f.FragOffset = binary.LittleEndian.Uint32(dat[8:])
f.Size = binary.LittleEndian.Uint32(dat[12:])
f.BlockStart = binary.LittleEndian.Uint32(dat[0:4])
f.FragInd = binary.LittleEndian.Uint32(dat[4:8])
f.FragOffset = binary.LittleEndian.Uint32(dat[8:12])
f.Size = binary.LittleEndian.Uint32(dat[12:16])
toRead := int(math.Floor(float64(f.Size) / float64(blockSize)))
if f.FragInd == 0xFFFFFFFF && f.Size%blockSize > 0 {
toRead++
@@ -57,14 +57,14 @@ func ReadEFile(r io.Reader, blockSize uint32) (f EFile, err error) {
if err != nil {
return
}
f.BlockStart = binary.LittleEndian.Uint64(dat)
f.Size = binary.LittleEndian.Uint64(dat[8:])
f.Sparse = binary.LittleEndian.Uint64(dat[16:])
f.LinkCount = binary.LittleEndian.Uint32(dat[24:])
f.FragInd = binary.LittleEndian.Uint32(dat[28:])
f.FragOffset = binary.LittleEndian.Uint32(dat[32:])
f.XattrInd = binary.LittleEndian.Uint32(dat[36:])
toRead := int(math.Floor(float64(f.Size) / float64(blockSize)))
f.BlockStart = binary.LittleEndian.Uint64(dat[0:8])
f.Size = binary.LittleEndian.Uint64(dat[8:16])
f.Sparse = binary.LittleEndian.Uint64(dat[16:24])
f.LinkCount = binary.LittleEndian.Uint32(dat[24:28])
f.FragInd = binary.LittleEndian.Uint32(dat[28:32])
f.FragOffset = binary.LittleEndian.Uint32(dat[32:36])
f.XattrInd = binary.LittleEndian.Uint32(dat[36:40])
toRead := f.Size / uint64(blockSize)
if f.FragInd == 0xFFFFFFFF && f.Size%uint64(blockSize) > 0 {
toRead++
}
+8 -1
View File
@@ -40,10 +40,17 @@ type Inode struct {
}
func Read(r io.Reader, blockSize uint32) (i Inode, err error) {
err = binary.Read(r, binary.LittleEndian, &i.Header)
dat := make([]byte, 16)
_, err = r.Read(dat)
if err != nil {
return
}
i.Type = binary.LittleEndian.Uint16(dat[0:2])
i.Perm = binary.LittleEndian.Uint16(dat[2:4])
i.UidInd = binary.LittleEndian.Uint16(dat[4:6])
i.GidInd = binary.LittleEndian.Uint16(dat[6:8])
i.ModTime = binary.LittleEndian.Uint32(dat[8:12])
i.Num = binary.LittleEndian.Uint32(dat[12:16])
switch i.Type {
case Dir:
i.Data, err = ReadDir(r)