fsverity_test.go: fix major/minor device number resolving
Signed-off-by: Alexey Lunev <cheembox573@gmail.com> (cherry picked from commit f9537ae126fc2be685cc32d5c98b4189a72e02e9) Signed-off-by: Austin Vazquez <macedonv@amazon.com>
This commit is contained in:
parent
10996a334b
commit
30b929ece7
@ -29,6 +29,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/containerd/containerd/v2/pkg/testutil"
|
"github.com/containerd/containerd/v2/pkg/testutil"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
type superblockROFeatures struct {
|
type superblockROFeatures struct {
|
||||||
@ -143,8 +144,7 @@ func resolveDevicePath(path string) (_ string, e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resolve to device path
|
// resolve to device path
|
||||||
maj := (stat.Dev >> 8) & 0xff
|
major, minor := unix.Major(stat.Dev), unix.Minor(stat.Dev)
|
||||||
min := stat.Dev & 0xff
|
|
||||||
|
|
||||||
m, err := os.Open("/proc/self/mountinfo")
|
m, err := os.Open("/proc/self/mountinfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -162,7 +162,7 @@ func resolveDevicePath(path string) (_ string, e error) {
|
|||||||
scanner := bufio.NewScanner(m)
|
scanner := bufio.NewScanner(m)
|
||||||
|
|
||||||
var entry string
|
var entry string
|
||||||
sub := fmt.Sprintf("%d:%d", maj, min)
|
sub := fmt.Sprintf("%d:%d", major, minor)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
if strings.Contains(scanner.Text(), sub) {
|
if strings.Contains(scanner.Text(), sub) {
|
||||||
entry = scanner.Text()
|
entry = scanner.Text()
|
||||||
|
Loading…
Reference in New Issue
Block a user