Fix sector size detection on s390x

This commit is contained in:
Benjamin Gilbert 2020-08-12 10:55:51 -04:00
parent 0e08b0f288
commit e0fdfe16ef
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From 34e18b247876eb9b42417ca2702b047f29670fca Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert <bgilbert@redhat.com>
Date: Tue, 11 Aug 2020 08:11:58 -0400
Subject: [PATCH] blkid: fix invalid pointer cast in DumpDisk()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
LogicalSectorSize is a Go int (64 bits on 64-bit systems) and the
argument to blkid_get_logical_sector_size() is a C int * (pointer to
32 bits). The value fits in 32 bits and the field is initialized to
zero, so we get away with this on little-endian systems, but not on
s390x.
See also 76a71f08d3c1.
Reported-by: Jakub Čajka <jcajka@redhat.com>
---
internal/exec/util/blkid.go | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/internal/exec/util/blkid.go b/internal/exec/util/blkid.go
index 8e53e26c..3888ce54 100644
--- a/internal/exec/util/blkid.go
+++ b/internal/exec/util/blkid.go
@@ -147,10 +147,11 @@ func DumpDisk(device string) (DiskInfo, error) {
cDevice := C.CString(device)
defer C.free(unsafe.Pointer(cDevice))
- cSectorSizeRef := (*C.int)(unsafe.Pointer(&output.LogicalSectorSize))
- if err := cResultToErr(C.blkid_get_logical_sector_size(cDevice, cSectorSizeRef), device); err != nil {
+ var sectorSize C.int
+ if err := cResultToErr(C.blkid_get_logical_sector_size(cDevice, &sectorSize), device); err != nil {
return DiskInfo{}, err
}
+ output.LogicalSectorSize = int(sectorSize)
numParts := C.int(0)
cNumPartsRef := (*C.int)(unsafe.Pointer(&numParts))
--
2.25.4

View File

@ -61,11 +61,14 @@
Name: ignition
Version: 2.6.0
Release: 1.git%{shortcommit}%{?dist}
Release: 2.git%{shortcommit}%{?dist}
Summary: First boot installer and configuration tool
License: ASL 2.0
URL: https://%{provider_prefix}
Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
# Fix sector size detection on s390x
# https://github.com/coreos/ignition/pull/1070
Patch0: blkid-fix-invalid-pointer-cast-in-DumpDisk.patch
%define gopath %{_datadir}/gocode
ExcludeArch: ppc64
@ -429,6 +432,7 @@ Ignition project's Github releases page.
# setup command reference: http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html
# unpack source0 and apply patches
%setup -T -b 0 -q -n %{repo}-%{commit}
%patch0 -p1
%build
# Set up PWD as a proper import path for go
@ -588,6 +592,9 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
%endif
%changelog
* Wed Aug 12 2020 Benjamin Gilbert <bgilbert@redhat.com> - 2.6.0-2.git947598e
- Fix sector size detection on s390x
* Fri Aug 07 2020 Benjamin Gilbert <bgilbert@redhat.com> - 2.6.0-1.git947598e
- New release