Skip to content

Commit 442e0ad

Browse files
authored
Merge pull request #1575 from shirou/feat/fix_disk_unix_uint64cast
[linux][disk]: fix Rdev cast
2 parents 8aa43a2 + 13218ce commit 442e0ad

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ build_test: ## test only buildable
2020
GOOS=linux GOARCH=loong64 go test ./... | $(BUILD_FAIL_PATTERN)
2121
GOOS=linux GOARCH=riscv64 go test ./... | $(BUILD_FAIL_PATTERN)
2222
GOOS=linux GOARCH=s390x go test ./... | $(BUILD_FAIL_PATTERN)
23+
GOOS=linux GOARCH=mips go test ./... | $(BUILD_FAIL_PATTERN)
2324
GOOS=freebsd GOARCH=amd64 go test ./... | $(BUILD_FAIL_PATTERN)
2425
GOOS=freebsd GOARCH=386 go test ./... | $(BUILD_FAIL_PATTERN)
2526
GOOS=freebsd GOARCH=arm go test ./... | $(BUILD_FAIL_PATTERN)

disk/disk_linux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
507507
if err := unix.Stat(name, &stat); err != nil {
508508
return "", err
509509
}
510-
major := unix.Major(stat.Rdev)
511-
minor := unix.Minor(stat.Rdev)
510+
major := unix.Major(uint64(stat.Rdev))
511+
minor := unix.Minor(uint64(stat.Rdev))
512512

513513
sserial, _ := udevData(ctx, major, minor, "E:ID_SERIAL")
514514
if sserial != "" {
@@ -541,8 +541,8 @@ func LabelWithContext(ctx context.Context, name string) (string, error) {
541541
if err := unix.Stat(common.HostDevWithContext(ctx, name), &stat); err != nil {
542542
return "", err
543543
}
544-
major := unix.Major(stat.Rdev)
545-
minor := unix.Minor(stat.Rdev)
544+
major := unix.Major(uint64(stat.Rdev))
545+
minor := unix.Minor(uint64(stat.Rdev))
546546

547547
label, err := udevData(ctx, major, minor, "E:ID_FS_LABEL")
548548
if err != nil {

0 commit comments

Comments
 (0)