diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-02-17 04:20:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 04:20:00 -0500 |
commit | 3c99cff3d13276b73011047e92f3d952bacbb8a2 (patch) | |
tree | 2f887c7b4df3a1df1e9e1208c56d060b9a9be134 | |
parent | f918a9418f5eeb00b289c127142953da2c394867 (diff) | |
parent | 90066af62e08da7a2795d163f181e4a4b2225869 (diff) | |
download | podman-3c99cff3d13276b73011047e92f3d952bacbb8a2.tar.gz podman-3c99cff3d13276b73011047e92f3d952bacbb8a2.tar.bz2 podman-3c99cff3d13276b73011047e92f3d952bacbb8a2.zip |
Merge pull request #13258 from robbmanes/bitshift_st_rdev
Calculate device major/minor using bitshift
-rw-r--r-- | pkg/util/utils_linux.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/util/utils_linux.go b/pkg/util/utils_linux.go index 288137ca5..1cffab19d 100644 --- a/pkg/util/utils_linux.go +++ b/pkg/util/utils_linux.go @@ -39,8 +39,10 @@ func FindDeviceNodes() (map[string]string, error) { if !ok { return errors.Errorf("Could not convert stat output for use") } - major := sysstat.Rdev / 256 - minor := sysstat.Rdev % 256 + // We must typeconvert sysstat.Rdev from uint64->int to avoid constant overflow + 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 |