Skip to content

Commit f738142

Browse files
committed
merge #4964 into opencontainers/runc:main
Kir Kolyshkin (1): libct: fix mips compilation LGTMs: AkihiroSuda cyphar
2 parents 2f74f4a + 1b954f1 commit f738142

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

libcontainer/console_linux.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ func checkPtmxHandle(ptmx *os.File) error {
3333
if stat.Ino != PTMX_INO {
3434
return fmt.Errorf("ptmx handle has wrong inode number: %v", stat.Ino)
3535
}
36-
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || stat.Rdev != unix.Mkdev(PTMX_MAJOR, PTMX_MINOR) {
36+
rdev := uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on MIPS.
37+
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || rdev != unix.Mkdev(PTMX_MAJOR, PTMX_MINOR) {
3738
return fmt.Errorf("ptmx handle is not a real char ptmx device: ftype %#x %d:%d",
38-
stat.Mode&unix.S_IFMT, unix.Major(stat.Rdev), unix.Minor(stat.Rdev))
39+
stat.Mode&unix.S_IFMT, unix.Major(rdev), unix.Minor(rdev))
3940
}
4041
return nil
4142
})
@@ -79,9 +80,10 @@ func getPtyPeer(pty console.Console, unsafePeerPath string, flags int) (*os.File
7980
if statfs.Type != unix.DEVPTS_SUPER_MAGIC {
8081
return fmt.Errorf("pty peer handle is not on a real devpts mount: super magic is %#x", statfs.Type)
8182
}
82-
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || stat.Rdev != wantPeerDev {
83+
rdev := uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on MIPS.
84+
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || rdev != wantPeerDev {
8385
return fmt.Errorf("pty peer handle is not the real char device for pty %d: ftype %#x %d:%d",
84-
peerNum, stat.Mode&unix.S_IFMT, unix.Major(stat.Rdev), unix.Minor(stat.Rdev))
86+
peerNum, stat.Mode&unix.S_IFMT, unix.Major(rdev), unix.Minor(rdev))
8587
}
8688
return nil
8789
}); err != nil {

libcontainer/rootfs_linux.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,10 +1044,10 @@ func mknodDevice(destDir *os.File, destName string, node *devices.Device) error
10441044
node.Type, node.Path,
10451045
stat.Mode&unix.S_IFMT, fileMode&unix.S_IFMT)
10461046
}
1047-
if stat.Rdev != dev {
1047+
if rdev := uint64(stat.Rdev); rdev != dev { //nolint:unconvert // Rdev is uint32 on MIPS.
10481048
return fmt.Errorf("new %c device inode %s has incorrect major:minor: %d:%d doesn't match expected %d:%d",
10491049
node.Type, node.Path,
1050-
unix.Major(stat.Rdev), unix.Minor(stat.Rdev),
1050+
unix.Major(rdev), unix.Minor(rdev),
10511051
unix.Major(dev), unix.Minor(dev))
10521052
}
10531053
return nil
@@ -1318,7 +1318,8 @@ func remountReadonly(m *configs.Mount) error {
13181318
}
13191319

13201320
func isDevNull(st *unix.Stat_t) bool {
1321-
return st.Mode&unix.S_IFMT == unix.S_IFCHR && st.Rdev == unix.Mkdev(1, 3)
1321+
//nolint:unconvert // Rdev is uint32 on MIPS.
1322+
return st.Mode&unix.S_IFMT == unix.S_IFCHR && uint64(st.Rdev) == unix.Mkdev(1, 3)
13221323
}
13231324

13241325
func verifyDevNull(f *os.File) error {

0 commit comments

Comments
 (0)