virtcontainers: Convert stats dev_t to uint64

We need to convert them to uint64 as their types may differ on various
host OSes, but unix.Major|Minor takes a uint64 regardless.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
This commit is contained in:
Samuel Ortiz 2021-11-25 10:17:08 +01:00 committed by Eric Ernst
parent 56751089c0
commit ad0449195d
5 changed files with 13 additions and 13 deletions

View File

@ -629,8 +629,8 @@ func (c *Container) createBlockDevices(ctx context.Context) error {
HostPath: m.Source, HostPath: m.Source,
ContainerPath: m.Destination, ContainerPath: m.Destination,
DevType: "b", DevType: "b",
Major: int64(unix.Major(stat.Rdev)), Major: int64(unix.Major(uint64(stat.Rdev))),
Minor: int64(unix.Minor(stat.Rdev)), Minor: int64(unix.Minor(uint64(stat.Rdev))),
ReadOnly: m.ReadOnly, ReadOnly: m.ReadOnly,
} }
// Check whether source can be used as a pmem device // Check whether source can be used as a pmem device
@ -1226,8 +1226,8 @@ func (c *Container) plugDevice(ctx context.Context, devicePath string) error {
HostPath: devicePath, HostPath: devicePath,
ContainerPath: filepath.Join(kataGuestSharedDir(), c.id), ContainerPath: filepath.Join(kataGuestSharedDir(), c.id),
DevType: "b", DevType: "b",
Major: int64(unix.Major(stat.Rdev)), Major: int64(unix.Major(uint64(stat.Rdev))),
Minor: int64(unix.Minor(stat.Rdev)), Minor: int64(unix.Minor(uint64(stat.Rdev))),
}) })
if err != nil { if err != nil {
return fmt.Errorf("device manager failed to create rootfs device for %q: %v", devicePath, err) return fmt.Errorf("device manager failed to create rootfs device for %q: %v", devicePath, err)

View File

@ -425,8 +425,8 @@ func getVhostUserDevName(dirname string, majorNum, minorNum uint32) (string, err
return "", err return "", err
} }
devMajor := unix.Major(devStat.Rdev) devMajor := unix.Major(uint64(devStat.Rdev))
devMinor := unix.Minor(devStat.Rdev) devMinor := unix.Minor(uint64(devStat.Rdev))
if devMajor == majorNum && devMinor == minorNum { if devMajor == majorNum && devMinor == minorNum {
return file.Name(), nil return file.Name(), nil
} }

View File

@ -51,8 +51,8 @@ func PmemDeviceInfo(source, destination string) (*DeviceInfo, error) {
device := &DeviceInfo{ device := &DeviceInfo{
ContainerPath: destination, ContainerPath: destination,
DevType: "b", DevType: "b",
Major: int64(unix.Major(stat.Dev)), Major: int64(unix.Major(uint64(stat.Dev))),
Minor: int64(unix.Minor(stat.Dev)), Minor: int64(unix.Minor(uint64(stat.Dev))),
Pmem: true, Pmem: true,
DriverOptions: make(map[string]string), DriverOptions: make(map[string]string),
} }

View File

@ -2084,7 +2084,7 @@ func (k *kataAgent) copyFile(ctx context.Context, src, dst string) error {
cpReq := &grpc.CopyFileRequest{ cpReq := &grpc.CopyFileRequest{
Path: dst, Path: dst,
DirMode: uint32(DirMode), DirMode: uint32(DirMode),
FileMode: st.Mode, FileMode: uint32(st.Mode),
FileSize: fileSize, FileSize: fileSize,
Uid: int32(st.Uid), Uid: int32(st.Uid),
Gid: int32(st.Gid), Gid: int32(st.Gid),

View File

@ -144,8 +144,8 @@ func getDeviceForPath(path string) (device, error) {
if isHostDevice(path) { if isHostDevice(path) {
// stat.Rdev describes the device that this file (inode) represents. // stat.Rdev describes the device that this file (inode) represents.
devMajor = major(stat.Rdev) devMajor = major(uint64(stat.Rdev))
devMinor = minor(stat.Rdev) devMinor = minor(uint64(stat.Rdev))
return device{ return device{
major: devMajor, major: devMajor,
@ -154,8 +154,8 @@ func getDeviceForPath(path string) (device, error) {
}, nil }, nil
} }
// stat.Dev points to the underlying device containing the file // stat.Dev points to the underlying device containing the file
devMajor = major(stat.Dev) devMajor = major(uint64(stat.Dev))
devMinor = minor(stat.Dev) devMinor = minor(uint64(stat.Dev))
path, err = filepath.Abs(path) path, err = filepath.Abs(path)
if err != nil { if err != nil {