Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ydcool committed Aug 1, 2019
1 parent 928381b commit 5f0231b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
10 changes: 6 additions & 4 deletions daemon/daemon_unix.go
Expand Up @@ -192,8 +192,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)
}

Expand Down Expand Up @@ -263,8 +264,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)
}

Expand Down
3 changes: 2 additions & 1 deletion daemon/graphdriver/copy/copy.go
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions daemon/graphdriver/devmapper/deviceset.go
Expand Up @@ -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)

Expand Down Expand Up @@ -1738,7 +1739,8 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) {
// - Managed by docker
// - The target of this device is at major <maj> and minor <min>
// - If <inode> 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
Expand Down
3 changes: 2 additions & 1 deletion pkg/loopback/loopback.go
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/system/stat_linux.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 5f0231b

Please sign in to comment.