Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion filesystem/iso9660/finalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@

// test creating an iso with el torito boot
func TestFinalizeElTorito(t *testing.T) {
finalizeElTorito(t, "")
dir, err := os.MkdirTemp("", "workspace")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
finalizeElTorito(t, dir)
}
func TestFinalizeElToritoWithInaccurateTmpDir(t *testing.T) {
finalizeElTorito(t, "")
dir, err := os.MkdirTemp("/tmp//", "workspace")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
finalizeElTorito(t, dir)
}

func finalizeElTorito(t *testing.T, workspace string) {

Check failure on line 42 in filesystem/iso9660/finalize_test.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

test helper function should start from t.Helper() (thelper)

Check failure on line 42 in filesystem/iso9660/finalize_test.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

test helper function should start from t.Helper() (thelper)
blocksize := int64(2048)
f, err := os.CreateTemp("", "iso_finalize_test")
defer os.Remove(f.Name())
Expand All @@ -31,7 +48,7 @@
}

b := file.New(f, false)
fs, err := iso9660.Create(b, 0, 0, blocksize, "")
fs, err := iso9660.Create(b, 0, 0, blocksize, workspace)
if err != nil {
t.Fatalf("Failed to iso9660.Create: %v", err)
}
Expand Down
4 changes: 4 additions & 0 deletions filesystem/iso9660/iso9660.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/diskfs/go-diskfs/backend"
"github.com/diskfs/go-diskfs/filesystem"
Expand Down Expand Up @@ -97,6 +98,9 @@ func Create(b backend.Storage, size, start, blocksize int64, workspace string) (
}
}

// sometimes, at least on macos, extra separators in path can cause panic
workdir = filepath.Clean(workdir)

// create root directory
// there is nothing in there
return &FileSystem{
Expand Down
Loading