mirror of
https://github.com/containers/podman.git
synced 2025-06-24 03:08:13 +08:00
Merge pull request #13258 from robbmanes/bitshift_st_rdev
Calculate device major/minor using bitshift
This commit is contained in:
@ -39,8 +39,10 @@ func FindDeviceNodes() (map[string]string, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("Could not convert stat output for use")
|
return errors.Errorf("Could not convert stat output for use")
|
||||||
}
|
}
|
||||||
major := sysstat.Rdev / 256
|
// We must typeconvert sysstat.Rdev from uint64->int to avoid constant overflow
|
||||||
minor := sysstat.Rdev % 256
|
rdev := int(sysstat.Rdev)
|
||||||
|
major := ((rdev >> 8) & 0xfff) | ((rdev >> 32) & ^0xfff)
|
||||||
|
minor := (rdev & 0xff) | ((rdev >> 12) & ^0xff)
|
||||||
|
|
||||||
nodes[fmt.Sprintf("%d:%d", major, minor)] = path
|
nodes[fmt.Sprintf("%d:%d", major, minor)] = path
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user