Browse code

cast Dev and Rdev of Stat_t to uint64 for mips

Signed-off-by: Dominic <yindongchao@inspur.com>
Signed-off-by: Dominic Yin <yindongchao@inspur.com>
(cherry picked from commit 5f0231bca193320e1a3d785a3ade0e64241fe580)
Signed-off-by: Dominic Yin <yindongchao@inspur.com>

Dominic authored on 2019/08/01 17:48:48
Showing 5 changed files
... ...
@@ -193,8 +193,9 @@ func getBlkioWeightDevices(config containertypes.Resources) ([]specs.LinuxWeight
193 193
 		}
194 194
 		weight := weightDevice.Weight
195 195
 		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
198 199
 		blkioWeightDevices = append(blkioWeightDevices, d)
199 200
 	}
200 201
 
... ...
@@ -264,8 +265,9 @@ func getBlkioThrottleDevices(devs []*blkiodev.ThrottleDevice) ([]specs.LinuxThro
264 264
 			return nil, err
265 265
 		}
266 266
 		d := specs.LinuxThrottleDevice{Rate: d.Rate}
267
-		d.Major = int64(unix.Major(stat.Rdev))
268
-		d.Minor = int64(unix.Minor(stat.Rdev))
267
+		// the type is 32bit on mips
268
+		d.Major = int64(unix.Major(uint64(stat.Rdev))) // nolint: unconvert
269
+		d.Minor = int64(unix.Minor(uint64(stat.Rdev))) // nolint: unconvert
269 270
 		throttleDevices = append(throttleDevices, d)
270 271
 	}
271 272
 
... ...
@@ -146,7 +146,8 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error {
146 146
 
147 147
 		switch mode := f.Mode(); {
148 148
 		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
150 151
 			if copyMode == Hardlink {
151 152
 				isHardlink = true
152 153
 				if err2 := os.Link(srcPath, dstPath); err2 != nil {
... ...
@@ -1527,7 +1527,8 @@ func getDeviceMajorMinor(file *os.File) (uint64, uint64, error) {
1527 1527
 		return 0, 0, err
1528 1528
 	}
1529 1529
 
1530
-	dev := stat.Rdev
1530
+	// the type is 32bit on mips
1531
+	dev := uint64(stat.Rdev) // nolint: unconvert
1531 1532
 	majorNum := major(dev)
1532 1533
 	minorNum := minor(dev)
1533 1534
 
... ...
@@ -1738,7 +1739,8 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) {
1738 1738
 	//	- Managed by docker
1739 1739
 	//	- The target of this device is at major <maj> and minor <min>
1740 1740
 	//	- 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)
1741
+	// The type Dev in Stat_t is 32bit on mips.
1742
+	devices.devicePrefix = fmt.Sprintf("docker-%d:%d-%d", major(uint64(st.Dev)), minor(uint64(st.Dev)), st.Ino) // nolint: unconvert
1742 1743
 	logger.Debugf("Generated prefix: %s", devices.devicePrefix)
1743 1744
 
1744 1745
 	// Check for the existence of the thin-pool device
... ...
@@ -37,7 +37,8 @@ func FindLoopDeviceFor(file *os.File) *os.File {
37 37
 		return nil
38 38
 	}
39 39
 	targetInode := stat.Ino
40
-	targetDevice := stat.Dev
40
+	// the type is 32bit on mips
41
+	targetDevice := uint64(stat.Dev) // nolint: unconvert
41 42
 
42 43
 	for i := 0; true; i++ {
43 44
 		path := fmt.Sprintf("/dev/loop%d", i)
... ...
@@ -8,7 +8,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
8 8
 		mode: s.Mode,
9 9
 		uid:  s.Uid,
10 10
 		gid:  s.Gid,
11
-		rdev: s.Rdev,
11
+		// the type is 32bit on mips
12
+		rdev: uint64(s.Rdev), // nolint: unconvert
12 13
 		mtim: s.Mtim}, nil
13 14
 }
14 15