Skip to content

Commit 90627f6

Browse files
authored
Merge pull request #4966 from cyphar/1.3-4964-fix-mips
[1.3] libct: fix mips compilation
2 parents 3cf5099 + 9381215 commit 90627f6

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
@@ -1047,10 +1047,10 @@ func mknodDevice(destDir *os.File, destName string, node *devices.Device) error
10471047
node.Type, node.Path,
10481048
stat.Mode&unix.S_IFMT, fileMode&unix.S_IFMT)
10491049
}
1050-
if stat.Rdev != dev {
1050+
if rdev := uint64(stat.Rdev); rdev != dev { //nolint:unconvert // Rdev is uint32 on MIPS.
10511051
return fmt.Errorf("new %c device inode %s has incorrect major:minor: %d:%d doesn't match expected %d:%d",
10521052
node.Type, node.Path,
1053-
unix.Major(stat.Rdev), unix.Minor(stat.Rdev),
1053+
unix.Major(rdev), unix.Minor(rdev),
10541054
unix.Major(dev), unix.Minor(dev))
10551055
}
10561056
return nil
@@ -1321,7 +1321,8 @@ func remountReadonly(m *configs.Mount) error {
13211321
}
13221322

13231323
func isDevNull(st *unix.Stat_t) bool {
1324-
return st.Mode&unix.S_IFMT == unix.S_IFCHR && st.Rdev == unix.Mkdev(1, 3)
1324+
//nolint:unconvert // Rdev is uint32 on MIPS.
1325+
return st.Mode&unix.S_IFMT == unix.S_IFCHR && uint64(st.Rdev) == unix.Mkdev(1, 3)
13251326
}
13261327

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

0 commit comments

Comments
 (0)