Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9fdd89c67 | |||
| c80d150fdc | |||
| 03266d0560 |
+3
-3
@@ -88,7 +88,7 @@ func (r *Reader) Id(i uint16) (uint32, error) {
|
||||
// Populate the id table as needed
|
||||
var blockNum uint32
|
||||
if i != 0 { // If i == 0, we go negatives causing issues with uint32s
|
||||
blockNum = uint32(math.Ceil(float64(i)/2048)) - 1
|
||||
blockNum = uint32(math.Ceil(float64(i+1)/2048)) - 1
|
||||
} else {
|
||||
blockNum = 0
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (r *Reader) fragEntry(i uint32) (fragEntry, error) {
|
||||
// Populate the fragment table as needed
|
||||
var blockNum uint32
|
||||
if i != 0 { // If i == 0, we go negatives causing issues with uint32s
|
||||
blockNum = uint32(math.Ceil(float64(i)/512)) - 1
|
||||
blockNum = uint32(math.Ceil(float64(i+1)/512)) - 1
|
||||
} else {
|
||||
blockNum = 0
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (r *Reader) inodeRef(i uint32) (uint64, error) {
|
||||
// Populate the export table as needed
|
||||
var blockNum uint32
|
||||
if i != 0 { // If i == 0, we go negatives causing issues with uint32s
|
||||
blockNum = uint32(math.Ceil(float64(i)/1024)) - 1
|
||||
blockNum = uint32(math.Ceil(float64(i+1)/1024)) - 1
|
||||
} else {
|
||||
blockNum = 0
|
||||
}
|
||||
|
||||
+21
-8
@@ -1,4 +1,4 @@
|
||||
package squashfslow_test
|
||||
package squashfslow
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -8,13 +8,11 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
squashfslow "github.com/CalebQ42/squashfs/low"
|
||||
)
|
||||
|
||||
const (
|
||||
squashfsURL = "https://darkstorm.tech/files/LinuxPATest.sfs"
|
||||
squashfsName = "LinuxPATest.sfs"
|
||||
squashfsName = "airootfs.sfs"
|
||||
)
|
||||
|
||||
func preTest(dir string) (fil *os.File, err error) {
|
||||
@@ -50,6 +48,21 @@ func preTest(dir string) (fil *os.File, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func TestMisc(t *testing.T) {
|
||||
tmpDir := "../testing"
|
||||
fil, err := preTest(tmpDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer fil.Close()
|
||||
rdr, err := NewReader(fil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(rdr.Superblock.FragCount)
|
||||
t.Fatal(rdr.fragEntry(1233))
|
||||
}
|
||||
|
||||
func TestReader(t *testing.T) {
|
||||
tmpDir := "../testing"
|
||||
fil, err := preTest(tmpDir)
|
||||
@@ -57,7 +70,7 @@ func TestReader(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer fil.Close()
|
||||
rdr, err := squashfslow.NewReader(fil)
|
||||
rdr, err := NewReader(fil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -77,7 +90,7 @@ func TestSingleFile(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer fil.Close()
|
||||
rdr, err := squashfslow.NewReader(fil)
|
||||
rdr, err := NewReader(fil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -92,7 +105,7 @@ func TestSingleFile(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
func extractToDir(rdr *squashfslow.Reader, b *squashfslow.FileBase, folder string) error {
|
||||
func extractToDir(rdr *Reader, b *FileBase, folder string) error {
|
||||
path := filepath.Join(folder, b.Name)
|
||||
if b.IsDir() {
|
||||
d, err := b.ToDir(rdr)
|
||||
@@ -103,7 +116,7 @@ func extractToDir(rdr *squashfslow.Reader, b *squashfslow.FileBase, folder strin
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var nestBast squashfslow.FileBase
|
||||
var nestBast FileBase
|
||||
for _, e := range d.Entries {
|
||||
nestBast, err = rdr.BaseFromEntry(e)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user