Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 27678e7

Browse files
authored
Merge pull request #438 from ydcool/19.03_backport_fix_compiling_errors_on_mips
[19.03 backport] cast Dev and Rdev of Stat_t to uint64 for mips Upstream-commit: 96582ab4ba132e574e1ebc52d4645ca58748cd0b Component: engine
2 parents 78173b2 + 169540b commit 27678e7

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

components/engine/daemon/daemon_unix.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ func getBlkioWeightDevices(config containertypes.Resources) ([]specs.LinuxWeight
193193
}
194194
weight := weightDevice.Weight
195195
d := specs.LinuxWeightDevice{Weight: &weight}
196-
d.Major = int64(unix.Major(stat.Rdev))
197-
d.Minor = int64(unix.Minor(stat.Rdev))
196+
// The type is 32bit on mips.
197+
d.Major = int64(unix.Major(uint64(stat.Rdev))) // nolint: unconvert
198+
d.Minor = int64(unix.Minor(uint64(stat.Rdev))) // nolint: unconvert
198199
blkioWeightDevices = append(blkioWeightDevices, d)
199200
}
200201

@@ -264,8 +265,9 @@ func getBlkioThrottleDevices(devs []*blkiodev.ThrottleDevice) ([]specs.LinuxThro
264265
return nil, err
265266
}
266267
d := specs.LinuxThrottleDevice{Rate: d.Rate}
267-
d.Major = int64(unix.Major(stat.Rdev))
268-
d.Minor = int64(unix.Minor(stat.Rdev))
268+
// the type is 32bit on mips
269+
d.Major = int64(unix.Major(uint64(stat.Rdev))) // nolint: unconvert
270+
d.Minor = int64(unix.Minor(uint64(stat.Rdev))) // nolint: unconvert
269271
throttleDevices = append(throttleDevices, d)
270272
}
271273

components/engine/daemon/graphdriver/copy/copy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error {
146146

147147
switch mode := f.Mode(); {
148148
case mode.IsRegular():
149-
id := fileID{dev: stat.Dev, ino: stat.Ino}
149+
//the type is 32bit on mips
150+
id := fileID{dev: uint64(stat.Dev), ino: stat.Ino} // nolint: unconvert
150151
if copyMode == Hardlink {
151152
isHardlink = true
152153
if err2 := os.Link(srcPath, dstPath); err2 != nil {

components/engine/daemon/graphdriver/devmapper/deviceset.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,8 @@ func getDeviceMajorMinor(file *os.File) (uint64, uint64, error) {
15271527
return 0, 0, err
15281528
}
15291529

1530-
dev := stat.Rdev
1530+
// the type is 32bit on mips
1531+
dev := uint64(stat.Rdev) // nolint: unconvert
15311532
majorNum := major(dev)
15321533
minorNum := minor(dev)
15331534

@@ -1738,7 +1739,8 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) {
17381739
// - Managed by docker
17391740
// - The target of this device is at major <maj> and minor <min>
17401741
// - If <inode> is defined, use that file inside the device as a loopback image. Otherwise use the device itself.
1741-
devices.devicePrefix = fmt.Sprintf("docker-%d:%d-%d", major(st.Dev), minor(st.Dev), st.Ino)
1742+
// The type Dev in Stat_t is 32bit on mips.
1743+
devices.devicePrefix = fmt.Sprintf("docker-%d:%d-%d", major(uint64(st.Dev)), minor(uint64(st.Dev)), st.Ino) // nolint: unconvert
17421744
logger.Debugf("Generated prefix: %s", devices.devicePrefix)
17431745

17441746
// Check for the existence of the thin-pool device

components/engine/pkg/loopback/loopback.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ func FindLoopDeviceFor(file *os.File) *os.File {
3737
return nil
3838
}
3939
targetInode := stat.Ino
40-
targetDevice := stat.Dev
40+
// the type is 32bit on mips
41+
targetDevice := uint64(stat.Dev) // nolint: unconvert
4142

4243
for i := 0; true; i++ {
4344
path := fmt.Sprintf("/dev/loop%d", i)

components/engine/pkg/system/stat_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
88
mode: s.Mode,
99
uid: s.Uid,
1010
gid: s.Gid,
11-
rdev: s.Rdev,
11+
// the type is 32bit on mips
12+
rdev: uint64(s.Rdev), // nolint: unconvert
1213
mtim: s.Mtim}, nil
1314
}
1415

0 commit comments

Comments
 (0)