From 16f503c0486fa511ecd4186ea6fb9b3e49c496f6 Mon Sep 17 00:00:00 2001 From: Dominic Date: Thu, 1 Aug 2019 16:48:48 +0800 Subject: [PATCH] cast Dev and Rdev of Stat_t to uint64 for mips Signed-off-by: Dominic Signed-off-by: Dominic Yin (cherry picked from commit 5f0231bca193320e1a3d785a3ade0e64241fe580) Signed-off-by: Dominic Yin --- daemon/daemon_unix.go | 10 ++++++---- daemon/graphdriver/copy/copy.go | 3 ++- daemon/graphdriver/devmapper/deviceset.go | 6 ++++-- pkg/loopback/loopback.go | 3 ++- pkg/system/stat_linux.go | 3 ++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 066d52328f..4ee3437408 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -193,8 +193,9 @@ func getBlkioWeightDevices(config containertypes.Resources) ([]specs.LinuxWeight } weight := weightDevice.Weight d := specs.LinuxWeightDevice{Weight: &weight} - d.Major = int64(unix.Major(stat.Rdev)) - d.Minor = int64(unix.Minor(stat.Rdev)) + // The type is 32bit on mips. + d.Major = int64(unix.Major(uint64(stat.Rdev))) // nolint: unconvert + d.Minor = int64(unix.Minor(uint64(stat.Rdev))) // nolint: unconvert blkioWeightDevices = append(blkioWeightDevices, d) } @@ -264,8 +265,9 @@ func getBlkioThrottleDevices(devs []*blkiodev.ThrottleDevice) ([]specs.LinuxThro return nil, err } d := specs.LinuxThrottleDevice{Rate: d.Rate} - d.Major = int64(unix.Major(stat.Rdev)) - d.Minor = int64(unix.Minor(stat.Rdev)) + // the type is 32bit on mips + d.Major = int64(unix.Major(uint64(stat.Rdev))) // nolint: unconvert + d.Minor = int64(unix.Minor(uint64(stat.Rdev))) // nolint: unconvert throttleDevices = append(throttleDevices, d) } diff --git a/daemon/graphdriver/copy/copy.go b/daemon/graphdriver/copy/copy.go index f8125403c4..62d42433fd 100644 --- a/daemon/graphdriver/copy/copy.go +++ b/daemon/graphdriver/copy/copy.go @@ -146,7 +146,8 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error { switch mode := f.Mode(); { case mode.IsRegular(): - id := fileID{dev: stat.Dev, ino: stat.Ino} + //the type is 32bit on mips + id := fileID{dev: uint64(stat.Dev), ino: stat.Ino} // nolint: unconvert if copyMode == Hardlink { isHardlink = true if err2 := os.Link(srcPath, dstPath); err2 != nil { diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index c41b50c119..30bbfd8533 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -1527,7 +1527,8 @@ func getDeviceMajorMinor(file *os.File) (uint64, uint64, error) { return 0, 0, err } - dev := stat.Rdev + // the type is 32bit on mips + dev := uint64(stat.Rdev) // nolint: unconvert majorNum := major(dev) minorNum := minor(dev) @@ -1738,7 +1739,8 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) { // - Managed by docker // - The target of this device is at major and minor // - If is defined, use that file inside the device as a loopback image. Otherwise use the device itself. - devices.devicePrefix = fmt.Sprintf("docker-%d:%d-%d", major(st.Dev), minor(st.Dev), st.Ino) + // The type Dev in Stat_t is 32bit on mips. + devices.devicePrefix = fmt.Sprintf("docker-%d:%d-%d", major(uint64(st.Dev)), minor(uint64(st.Dev)), st.Ino) // nolint: unconvert logger.Debugf("Generated prefix: %s", devices.devicePrefix) // Check for the existence of the thin-pool device diff --git a/pkg/loopback/loopback.go b/pkg/loopback/loopback.go index 086655bc1a..03e335d097 100644 --- a/pkg/loopback/loopback.go +++ b/pkg/loopback/loopback.go @@ -37,7 +37,8 @@ func FindLoopDeviceFor(file *os.File) *os.File { return nil } targetInode := stat.Ino - targetDevice := stat.Dev + // the type is 32bit on mips + targetDevice := uint64(stat.Dev) // nolint: unconvert for i := 0; true; i++ { path := fmt.Sprintf("/dev/loop%d", i) diff --git a/pkg/system/stat_linux.go b/pkg/system/stat_linux.go index 98c9eb18d1..17d5d131a3 100644 --- a/pkg/system/stat_linux.go +++ b/pkg/system/stat_linux.go @@ -8,7 +8,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) { mode: s.Mode, uid: s.Uid, gid: s.Gid, - rdev: s.Rdev, + // the type is 32bit on mips + rdev: uint64(s.Rdev), // nolint: unconvert mtim: s.Mtim}, nil }