Skip to content

Commit

Permalink
Merge branch 'diskfs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbojangles3 authored Sep 19, 2024
2 parents 22b6e86 + 1c5247c commit 170c3e5
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: ^1.21
go-version-file: 'go.mod'
- run: go build
env:
GOOS: ${{ matrix.target.os }}
Expand Down
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ linters-settings:
nolintlint:
require-explanation: true
require-specific: true
gosec:
excludes:
- G115

linters:
disable-all: true
Expand All @@ -24,7 +27,7 @@ linters:
- dogsled
- dupl
- errcheck
- exportloopref
- copyloopvar
- exhaustive
- gocritic
- gofmt
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GOENV ?= GO111MODULE=on CGO_ENABLED=0
GO_FILES ?= $(shell $(GOENV) go list ./...)
GOBIN ?= $(shell go env GOPATH)/bin
LINTER ?= $(GOBIN)/golangci-lint
LINTER_VERSION ?= v1.59.0
LINTER_VERSION ?= v1.61.0

# BUILDARCH is the host architecture
# ARCH is the target architecture
Expand Down
12 changes: 6 additions & 6 deletions disk/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ func TestWritePartitionContents(t *testing.T) {
{"no table, write to partition -1", nil, -1, fmt.Errorf("cannot write contents of a partition on a disk without a partition table")},
{"good table, write to partition 1", table, 1, nil},
}
for _, tt := range tests {
for _, t2 := range tests {
// so that closures do not cause an issue
tt := tt
tt := t2
t.Run(tt.name, func(t *testing.T) {
f, err := tmpDisk("")
if err != nil {
Expand Down Expand Up @@ -292,9 +292,9 @@ func TestReadPartitionContents(t *testing.T) {
{"good table, partition greater than max", table, 5, fmt.Errorf("cannot read contents of partition %d which is greater than max partition %d", 5, 1)},
{"good table, good partition 1", table, 1, nil},
}
for _, tt := range tests {
for _, t2 := range tests {
// so that closure does not cause issues
tt := tt
tt := t2
t.Run(tt.name, func(t *testing.T) {
f, err := tmpDisk("../partition/gpt/testdata/gpt.img")
if err != nil {
Expand Down Expand Up @@ -366,8 +366,8 @@ func TestReadPartitionContents(t *testing.T) {
{"valid table partition 5", table, 5, fmt.Errorf("cannot read contents of partition %d which is greater than max partition %d", 5, 1)},
{"valid table partition 1", table, 1, nil},
}
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(tt.name, func(t *testing.T) {
f, err := tmpDisk("../partition/mbr/testdata/mbr.img")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions diskfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func TestCreate(t *testing.T) {
{"10MB with 2048 sector size", "disk", 10 * oneMB, diskfs.Raw, diskfs.SectorSize4k, &disk.Disk{LogicalBlocksize: 4096, PhysicalBlocksize: 4096, Size: 10 * oneMB, Type: disk.File}, nil},
}

for i, tt := range tests {
tt := tt
for i, t2 := range tests {
tt := t2
t.Run(tt.name, func(t *testing.T) {
var filename string
if tt.path != "" {
Expand Down
12 changes: 6 additions & 6 deletions filesystem/fat32/fat32_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func TestFat32Create(t *testing.T) {
}
//nolint:thelper // this is not a helper function
runTest := func(t *testing.T, pre, post int64) {
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d", tt.blocksize, tt.filesize), func(t *testing.T) {
// get a temporary working file
f, err := tmpFat32(false, pre, post)
Expand Down Expand Up @@ -245,8 +245,8 @@ func TestFat32Read(t *testing.T) {
}
//nolint:thelper // this is not a helper function
runTest := func(t *testing.T, pre, post int64) {
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d bytechange %d", tt.filesize, tt.blocksize, tt.bytechange), func(t *testing.T) {
// get a temporary working file
f, err := tmpFat32(true, pre, post)
Expand Down Expand Up @@ -455,8 +455,8 @@ func TestFat32OpenFile(t *testing.T) {
{"/CORTO1.TXT", os.O_APPEND, true, "More", "", fmt.Errorf("cannot write to file opened read-only")},
{"/CORTO1.TXT", os.O_APPEND | os.O_RDWR, true, "More", "Moremos un archivo corto\n", nil},
}
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("path %s mode %v beginning %v", tt.path, tt.mode, tt.beginning), func(t *testing.T) {
header := fmt.Sprintf("OpenFile(%s, %s, %t)", tt.path, getOpenMode(tt.mode), tt.beginning)
// get a temporary working file
Expand Down
10 changes: 5 additions & 5 deletions filesystem/iso9660/iso9660_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"testing"

"github.com/diskfs/go-diskfs"
diskfs "github.com/diskfs/go-diskfs"
"github.com/diskfs/go-diskfs/disk"
"github.com/diskfs/go-diskfs/filesystem"
"github.com/diskfs/go-diskfs/filesystem/iso9660"
Expand Down Expand Up @@ -174,8 +174,8 @@ func TestIso9660Create(t *testing.T) {
{2048, 10000000, &iso9660.FileSystem{}, nil, testDir},
{2048, 10000000, &iso9660.FileSystem{}, nil, ""},
}
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d", tt.blocksize, tt.filesize), func(t *testing.T) {
// create the filesystem
f, err := tmpIso9660File()
Expand Down Expand Up @@ -214,8 +214,8 @@ func TestISO9660Read(t *testing.T) {
{512, iso9660.MaxBlocks*2048 + 10000, -1, nil, fmt.Errorf("blocksize for ISO9660 must be")},
{2048, 10000000, -1, &iso9660.FileSystem{}, nil},
}
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d", tt.blocksize, tt.filesize), func(t *testing.T) {
// get a temporary working file
f, err := os.Open(iso9660.ISO9660File)
Expand Down
2 changes: 1 addition & 1 deletion filesystem/squashfs/compressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"

"github.com/klauspost/compress/zstd"
"github.com/pierrec/lz4/v4"
lz4 "github.com/pierrec/lz4/v4"
"github.com/ulikunitz/xz"
"github.com/ulikunitz/xz/lzma"
)
Expand Down
8 changes: 4 additions & 4 deletions filesystem/squashfs/squashfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ func TestSquashfsRead(t *testing.T) {
{4097, squashfs.GB * squashfs.GB, -1, nil, fmt.Errorf("blocksize %d is not a power of 2", 4097)},
{4096, 10000000, -1, &squashfs.FileSystem{}, nil},
}
for i, tt := range tests {
tt := tt
for i, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d bytechange %d", tt.blocksize, tt.filesize, tt.bytechange), func(t *testing.T) {
// get a temporary working file
f, err := os.Open(squashfs.Squashfsfile)
Expand Down Expand Up @@ -641,8 +641,8 @@ func TestSquashfsCreate(t *testing.T) {
{4097, squashfs.GB * squashfs.GB, nil, fmt.Errorf("blocksize %d is not a power of 2", 4097)},
{4096, 10000000, &squashfs.FileSystem{}, nil},
}
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d", tt.blocksize, tt.filesize), func(t *testing.T) {
// create the filesystem
f, err := tmpSquashfsFile()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/diskfs/go-diskfs

go 1.21
go 1.23

require (
github.com/djherbis/times v1.6.0
Expand Down
2 changes: 1 addition & 1 deletion partition/mbr/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func partitionFromBytes(b []byte, logicalSectorSize, physicalSectorSize int) (*P
EndSector: b[6],
EndCylinder: b[7],
Start: binary.LittleEndian.Uint32(b[8:12]),
Size: binary.LittleEndian.Uint32(b[12:16]),
Size: binary.LittleEndian.Uint32(b[12:16]), //nolint:gosec // we already checked the length above
logicalSectorSize: logicalSectorSize,
physicalSectorSize: physicalSectorSize,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions partition/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestRead(t *testing.T) {
{"./gpt/testdata/gpt.img", "gpt", nil},
{"", "", fmt.Errorf("unknown disk partition type")},
}
for _, tt := range tests {
tt := tt
for _, t2 := range tests {
tt := t2
t.Run(tt.tableType, func(t *testing.T) {
// create a blank file if we did not provide a path to a test file
var f *os.File
Expand Down

0 comments on commit 170c3e5

Please sign in to comment.