From 413626d37f79fb12ff8de436c61e9bc1b7e47565 Mon Sep 17 00:00:00 2001 From: Preslav Date: Fri, 24 May 2024 09:36:36 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=B9=20Add=20new=20methods=20for=20?= =?UTF-8?q?detecting=20and=20mounting=20in=20the=20volume=20mounter.=20Pre?= =?UTF-8?q?viously=20that=20was=20all=20done=20in=20one=20function,=20we?= =?UTF-8?q?=20now=20split=20those.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Preslav --- .../os/connection/device/device_connection.go | 4 +- .../os/connection/device/device_manager.go | 12 +++- .../connection/device/linux/device_manager.go | 72 ++++++++----------- .../os/connection/snapshot/blockdevices.go | 38 +++++----- .../connection/snapshot/blockdevices_test.go | 40 +++++------ .../os/connection/snapshot/volumemounter.go | 70 +++++++++++++++--- 6 files changed, 141 insertions(+), 95 deletions(-) diff --git a/providers/os/connection/device/device_connection.go b/providers/os/connection/device/device_connection.go index 952e2cd695..586f4d7929 100644 --- a/providers/os/connection/device/device_connection.go +++ b/providers/os/connection/device/device_connection.go @@ -47,7 +47,7 @@ func NewDeviceConnection(connId uint32, conf *inventory.Config, asset *inventory } log.Debug().Str("manager", manager.Name()).Msg("device manager created") - blocks, err := manager.IdentifyBlockDevice(conf.Options) + blocks, err := manager.IdentifyMountTargets(conf.Options) if err != nil { return nil, err } @@ -56,7 +56,7 @@ func NewDeviceConnection(connId uint32, conf *inventory.Config, asset *inventory return nil, errors.New("internal>blocks size is not equal to 1.") } block := blocks[0] - log.Debug().Str("device", block.DeviceName).Msg("identified block for mounting") + log.Debug().Str("name", block.Name).Str("type", block.FsType).Msg("identified partition for mounting") res := &DeviceConnection{ Connection: plugin.NewConnection(connId, asset), diff --git a/providers/os/connection/device/device_manager.go b/providers/os/connection/device/device_manager.go index da8b214d79..f8ea0b0dc3 100644 --- a/providers/os/connection/device/device_manager.go +++ b/providers/os/connection/device/device_manager.go @@ -3,11 +3,17 @@ package device -import "go.mondoo.com/cnquery/v11/providers/os/connection/device/shared" +import ( + "go.mondoo.com/cnquery/v11/providers/os/connection/snapshot" +) type DeviceManager interface { + // Name returns the name of the device manager Name() string - IdentifyBlockDevice(opts map[string]string) ([]shared.MountInfo, error) - Mount(mi shared.MountInfo) (string, error) + // IdentifyMountTargets returns a list of partitions that match the given options and can be mounted + IdentifyMountTargets(opts map[string]string) ([]*snapshot.PartitionInfo, error) + // Mounts the partition and returns the directory it was mounted to + Mount(pi *snapshot.PartitionInfo) (string, error) + // UnmountAndClose unmounts the partitions from the specified dirs and closes the device manager UnmountAndClose() } diff --git a/providers/os/connection/device/linux/device_manager.go b/providers/os/connection/device/linux/device_manager.go index a3f5b83c4a..a8bb8c4b19 100644 --- a/providers/os/connection/device/linux/device_manager.go +++ b/providers/os/connection/device/linux/device_manager.go @@ -8,7 +8,6 @@ import ( "github.com/cockroachdb/errors" "github.com/rs/zerolog/log" - "go.mondoo.com/cnquery/v11/providers/os/connection/device/shared" "go.mondoo.com/cnquery/v11/providers/os/connection/snapshot" ) @@ -37,7 +36,7 @@ func (d *LinuxDeviceManager) Name() string { return "linux" } -func (d *LinuxDeviceManager) IdentifyBlockDevice(opts map[string]string) ([]shared.MountInfo, error) { +func (d *LinuxDeviceManager) IdentifyMountTargets(opts map[string]string) ([]*snapshot.PartitionInfo, error) { if err := validateOpts(opts); err != nil { return nil, err } @@ -46,20 +45,26 @@ func (d *LinuxDeviceManager) IdentifyBlockDevice(opts map[string]string) ([]shar if err != nil { return nil, err } - return d.identifyViaLun(lun) + pi, err := d.identifyViaLun(lun) + if err != nil { + return nil, err + } + return []*snapshot.PartitionInfo{pi}, nil } - return d.identifyViaDeviceName(opts[DeviceName]) + pi, err := d.identifyViaDeviceName(opts[DeviceName]) + if err != nil { + return nil, err + } + return []*snapshot.PartitionInfo{pi}, nil } -func (d *LinuxDeviceManager) Mount(mi shared.MountInfo) (string, error) { - // TODO: we should make the volume mounter return the scan dir from Mount() - // TODO: use the mount info to mount the volume - err := d.volumeMounter.Mount() +func (d *LinuxDeviceManager) Mount(pi *snapshot.PartitionInfo) (string, error) { + scanDir, err := d.volumeMounter.MountP(pi) if err != nil { return "", err } - return d.volumeMounter.ScanDir, nil + return scanDir, nil } func (d *LinuxDeviceManager) UnmountAndClose() { @@ -92,7 +97,7 @@ func validateOpts(opts map[string]string) error { return nil } -func (c *LinuxDeviceManager) identifyViaLun(lun int) ([]shared.MountInfo, error) { +func (c *LinuxDeviceManager) identifyViaLun(lun int) (*snapshot.PartitionInfo, error) { scsiDevices, err := c.listScsiDevices() if err != nil { return nil, err @@ -104,43 +109,26 @@ func (c *LinuxDeviceManager) identifyViaLun(lun int) ([]shared.MountInfo, error) return nil, errors.New("no matching scsi devices found") } + var target string // if we have exactly one device present at the LUN we can directly point the volume mounter towards it if len(filteredScsiDevices) == 1 { - return []shared.MountInfo{{DeviceName: filteredScsiDevices[0].VolumePath}}, nil - } - - // we have multiple devices at the same LUN. we find the first non-mounted block devices in that list - blockDevices, err := c.volumeMounter.CmdRunner.GetBlockDevices() - if err != nil { - return nil, err - } - target, err := findMatchingDeviceByBlock(filteredScsiDevices, blockDevices) - if err != nil { - return nil, err - } - c.volumeMounter.VolumeAttachmentLoc = target - return []shared.MountInfo{{DeviceName: target}}, nil -} - -func (c *LinuxDeviceManager) identifyViaDeviceName(deviceName string) ([]shared.MountInfo, error) { - blockDevices, err := c.volumeMounter.CmdRunner.GetBlockDevices() - if err != nil { - return nil, err - } - // this is a best-effort approach, we try to find the first unmounted block device as we don't have the device name - if deviceName == "" { - fsInfo, err := blockDevices.GetUnmountedBlockEntry() + target = filteredScsiDevices[0].VolumePath + } else { + // we have multiple devices at the same LUN. we find the first non-mounted block devices in that list + blockDevices, err := c.volumeMounter.CmdRunner.GetBlockDevices() + if err != nil { + return nil, err + } + target, err = findMatchingDeviceByBlock(filteredScsiDevices, blockDevices) if err != nil { return nil, err } - c.volumeMounter.VolumeAttachmentLoc = deviceName - return []shared.MountInfo{{DeviceName: fsInfo.Name}}, nil } - fsInfo, err := blockDevices.GetBlockEntryByName(deviceName) - if err != nil { - return nil, err - } - c.volumeMounter.VolumeAttachmentLoc = deviceName - return []shared.MountInfo{{DeviceName: fsInfo.Name}}, nil + return c.volumeMounter.GetDeviceForMounting(target) +} + +func (c *LinuxDeviceManager) identifyViaDeviceName(deviceName string) (*snapshot.PartitionInfo, error) { + // GetDeviceForMounting also supports passing in empty strings, in that case we do a best-effort guess + return c.volumeMounter.GetDeviceForMounting(deviceName) } diff --git a/providers/os/connection/snapshot/blockdevices.go b/providers/os/connection/snapshot/blockdevices.go index f7810d8511..0538ced3a3 100644 --- a/providers/os/connection/snapshot/blockdevices.go +++ b/providers/os/connection/snapshot/blockdevices.go @@ -27,7 +27,7 @@ type BlockDevice struct { FsUse string `json:"fsuse%,omitempty"` } -type fsInfo struct { +type PartitionInfo struct { Name string FsType string } @@ -55,7 +55,7 @@ func (cmdRunner *LocalCommandRunner) GetBlockDevices() (*BlockDevices, error) { return blockEntries, nil } -func (blockEntries BlockDevices) GetRootBlockEntry() (*fsInfo, error) { +func (blockEntries BlockDevices) GetRootBlockEntry() (*PartitionInfo, error) { log.Debug().Msg("get root block entry") for i := range blockEntries.BlockDevices { d := blockEntries.BlockDevices[i] @@ -64,14 +64,14 @@ func (blockEntries BlockDevices) GetRootBlockEntry() (*fsInfo, error) { entry := d.Children[i] if entry.IsNoBootVolume() { devFsName := "/dev/" + entry.Name - return &fsInfo{Name: devFsName, FsType: entry.FsType}, nil + return &PartitionInfo{Name: devFsName, FsType: entry.FsType}, nil } } } return nil, errors.New("target volume not found on instance") } -func (blockEntries BlockDevices) GetBlockEntryByName(name string) (*fsInfo, error) { +func (blockEntries BlockDevices) GetBlockEntryByName(name string) (*PartitionInfo, error) { log.Debug().Str("name", name).Msg("get matching block entry") var secondName string if strings.HasPrefix(name, "/dev/sd") { @@ -91,35 +91,35 @@ func (blockEntries BlockDevices) GetBlockEntryByName(name string) (*fsInfo, erro continue } } - log.Debug().Msg("found match") + log.Debug().Str("location", d.Name).Msg("found match") for i := range d.Children { entry := d.Children[i] if entry.IsNotBootOrRootVolumeAndUnmounted() { devFsName := "/dev/" + entry.Name - return &fsInfo{Name: devFsName, FsType: entry.FsType}, nil + return &PartitionInfo{Name: devFsName, FsType: entry.FsType}, nil } } } return nil, errors.New("target volume not found on instance") } -func (blockEntries BlockDevices) GetUnnamedBlockEntry() (*fsInfo, error) { - fsInfo, err := blockEntries.GetUnmountedBlockEntry() - if err == nil && fsInfo != nil { - return fsInfo, nil +func (blockEntries BlockDevices) GetUnnamedBlockEntry() (*PartitionInfo, error) { + pInfo, err := blockEntries.GetUnmountedBlockEntry() + if err == nil && pInfo != nil { + return pInfo, nil } else { // if we get here, there was no non-root, non-mounted volume on the instance // this is expected in the "no setup" case where we start an instance with the target // volume attached and only that volume attached - fsInfo, err = blockEntries.GetRootBlockEntry() - if err == nil && fsInfo != nil { - return fsInfo, nil + pInfo, err = blockEntries.GetRootBlockEntry() + if err == nil && pInfo != nil { + return pInfo, nil } } return nil, errors.New("target volume not found on instance") } -func (blockEntries BlockDevices) GetUnmountedBlockEntry() (*fsInfo, error) { +func (blockEntries BlockDevices) GetUnmountedBlockEntry() (*PartitionInfo, error) { log.Debug().Msg("get unmounted block entry") for i := range blockEntries.BlockDevices { d := blockEntries.BlockDevices[i] @@ -127,21 +127,21 @@ func (blockEntries BlockDevices) GetUnmountedBlockEntry() (*fsInfo, error) { if d.MountPoint != "" { // empty string means it is not mounted continue } - if fsinfo := findVolume(d.Children); fsinfo != nil { - return fsinfo, nil + if pInfo := findVolume(d.Children); pInfo != nil { + return pInfo, nil } } return nil, errors.New("target volume not found on instance") } -func findVolume(children []BlockDevice) *fsInfo { - var fs *fsInfo +func findVolume(children []BlockDevice) *PartitionInfo { + var fs *PartitionInfo for i := range children { entry := children[i] if entry.IsNotBootOrRootVolumeAndUnmounted() { // we are NOT searching for the root volume here, so we can exclude the "sda" and "xvda" volumes devFsName := "/dev/" + entry.Name - fs = &fsInfo{Name: devFsName, FsType: entry.FsType} + fs = &PartitionInfo{Name: devFsName, FsType: entry.FsType} } } return fs diff --git a/providers/os/connection/snapshot/blockdevices_test.go b/providers/os/connection/snapshot/blockdevices_test.go index b649b1f487..c54bd8846d 100644 --- a/providers/os/connection/snapshot/blockdevices_test.go +++ b/providers/os/connection/snapshot/blockdevices_test.go @@ -21,9 +21,9 @@ func TestGetMatchingBlockEntryByName(t *testing.T) { {Name: "sdx", Children: []BlockDevice{{Uuid: "12346", FsType: "xfs", Label: "ROOT", Name: "sdh1"}, {Uuid: "12345", FsType: "", Label: "EFI"}}}, }...) - realFsInfo, err := blockEntries.GetBlockEntryByName("/dev/sdx") + realPartitionInfo, err := blockEntries.GetBlockEntryByName("/dev/sdx") require.Nil(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/sdh1"}, *realFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/sdh1"}, *realPartitionInfo) blockEntries = BlockDevices{BlockDevices: []BlockDevice{RootDevice}} blockEntries.BlockDevices = append(blockEntries.BlockDevices, []BlockDevice{ @@ -31,9 +31,9 @@ func TestGetMatchingBlockEntryByName(t *testing.T) { {Name: "xvdx", Children: []BlockDevice{{Uuid: "12346", FsType: "xfs", Label: "ROOT", Name: "xvdh1"}, {Uuid: "12345", FsType: "", Label: "EFI"}}}, }...) - realFsInfo, err = blockEntries.GetBlockEntryByName("/dev/sdx") + realPartitionInfo, err = blockEntries.GetBlockEntryByName("/dev/sdx") require.Nil(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/xvdh1"}, *realFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/xvdh1"}, *realPartitionInfo) blockEntries = BlockDevices{BlockDevices: []BlockDevice{RootDevice}} blockEntries.BlockDevices = append(blockEntries.BlockDevices, []BlockDevice{ @@ -41,20 +41,20 @@ func TestGetMatchingBlockEntryByName(t *testing.T) { {Name: "xvdh", Children: []BlockDevice{{Uuid: "12346", FsType: "xfs", Label: "ROOT", Name: "xvdh1"}, {Uuid: "12345", FsType: "", Label: "EFI"}}}, }...) - realFsInfo, err = blockEntries.GetBlockEntryByName("/dev/xvdh") + realPartitionInfo, err = blockEntries.GetBlockEntryByName("/dev/xvdh") require.Nil(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/xvdh1"}, *realFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/xvdh1"}, *realPartitionInfo) blockEntries = BlockDevices{BlockDevices: []BlockDevice{RootDevice}} blockEntries.BlockDevices = append(blockEntries.BlockDevices, []BlockDevice{ {Name: "nvme0n1", Children: []BlockDevice{{Uuid: "12345", FsType: "xfs", Label: "ROOT", Name: "nvmd1n1"}, {Uuid: "12345", FsType: "", Label: "EFI"}}}, }...) - realFsInfo, err = blockEntries.GetBlockEntryByName("/dev/sdh") + _, err = blockEntries.GetBlockEntryByName("/dev/sdh") require.Error(t, err) blockEntries = BlockDevices{BlockDevices: []BlockDevice{RootDevice}} - realFsInfo, err = blockEntries.GetBlockEntryByName("/dev/sdh") + _, err = blockEntries.GetBlockEntryByName("/dev/sdh") require.Error(t, err) } @@ -63,16 +63,16 @@ func TestGetNonRootBlockEntry(t *testing.T) { blockEntries.BlockDevices = append(blockEntries.BlockDevices, []BlockDevice{ {Name: "nvme0n1", Children: []BlockDevice{{Uuid: "12345", FsType: "xfs", Label: "ROOT", Name: "nvmd1n1"}, {Uuid: "12345", FsType: "", Label: "EFI"}}}, }...) - realFsInfo, err := blockEntries.GetUnmountedBlockEntry() + realPartitionInfo, err := blockEntries.GetUnmountedBlockEntry() require.Nil(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/nvmd1n1"}, *realFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/nvmd1n1"}, *realPartitionInfo) } func TestGetRootBlockEntry(t *testing.T) { blockEntries := BlockDevices{BlockDevices: []BlockDevice{RootDevice}} - realFsInfo, err := blockEntries.GetRootBlockEntry() + realPartitionInfo, err := blockEntries.GetRootBlockEntry() require.Nil(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/sda1"}, *realFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/sda1"}, *realPartitionInfo) } func TestGetRootBlockEntryRhel8(t *testing.T) { @@ -83,13 +83,13 @@ func TestGetRootBlockEntryRhel8(t *testing.T) { err = json.Unmarshal(data, &blockEntries) require.NoError(t, err) - rootFsInfo, err := blockEntries.GetRootBlockEntry() + rootPartitionInfo, err := blockEntries.GetRootBlockEntry() require.NoError(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/sda2"}, *rootFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/sda2"}, *rootPartitionInfo) - rootFsInfo, err = blockEntries.GetUnnamedBlockEntry() + rootPartitionInfo, err = blockEntries.GetUnnamedBlockEntry() require.NoError(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/sdc2"}, *rootFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/sdc2"}, *rootPartitionInfo) } func TestGetRootBlockEntryRhelNoLabels(t *testing.T) { @@ -100,13 +100,13 @@ func TestGetRootBlockEntryRhelNoLabels(t *testing.T) { err = json.Unmarshal(data, &blockEntries) require.NoError(t, err) - rootFsInfo, err := blockEntries.GetRootBlockEntry() + rootPartitionInfo, err := blockEntries.GetRootBlockEntry() require.NoError(t, err) - require.Equal(t, fsInfo{FsType: "xfs", Name: "/dev/sda2"}, *rootFsInfo) + require.Equal(t, PartitionInfo{FsType: "xfs", Name: "/dev/sda2"}, *rootPartitionInfo) - rootFsInfo, err = blockEntries.GetUnnamedBlockEntry() + rootPartitionInfo, err = blockEntries.GetUnnamedBlockEntry() require.NoError(t, err) - require.Equal(t, fsInfo{FsType: "ext4", Name: "/dev/sdb1"}, *rootFsInfo) + require.Equal(t, PartitionInfo{FsType: "ext4", Name: "/dev/sdb1"}, *rootPartitionInfo) } func TestAttachedBlockEntry(t *testing.T) { diff --git a/providers/os/connection/snapshot/volumemounter.go b/providers/os/connection/snapshot/volumemounter.go index 8a3c82cb5d..820bd547f5 100644 --- a/providers/os/connection/snapshot/volumemounter.go +++ b/providers/os/connection/snapshot/volumemounter.go @@ -35,13 +35,13 @@ func NewVolumeMounter(shell []string) *VolumeMounter { } } +// we should try and migrate this towards MountP where we specifically mount a target partition. +// the detection of the partition should be done in the caller (separately from Mount) func (m *VolumeMounter) Mount() error { - err := m.createScanDir() + _, err := m.createScanDir() if err != nil { return err } - // we should consider dropping this if VolumeAttachmentLoc is set. we need to also add FsType but - // otherwise that means we're listing the devices twice fsInfo, err := m.getFsInfo() if err != nil { return err @@ -53,18 +53,36 @@ func (m *VolumeMounter) Mount() error { return m.mountVolume(fsInfo) } -func (m *VolumeMounter) createScanDir() error { +// Mounts a specific partition and returns the directory it was mounted to +func (m *VolumeMounter) MountP(partition *PartitionInfo) (string, error) { + if partition == nil { + return "", errors.New("mount device> partition is required") + } + if partition.Name == "" { + return "", errors.New("mount device> partition name is required") + } + if partition.FsType == "" { + return "", errors.New("mount device> partition fs type is required") + } + dir, err := m.createScanDir() + if err != nil { + return "", err + } + return dir, m.mountVolume(partition) +} + +func (m *VolumeMounter) createScanDir() (string, error) { dir, err := os.MkdirTemp("", "cnspec-scan") if err != nil { log.Error().Err(err).Msg("error creating directory") - return err + return "", err } m.ScanDir = dir log.Debug().Str("dir", dir).Msg("created tmp scan dir") - return nil + return dir, nil } -func (m *VolumeMounter) getFsInfo() (*fsInfo, error) { +func (m *VolumeMounter) getFsInfo() (*PartitionInfo, error) { log.Debug().Str("volume attachment loc", m.VolumeAttachmentLoc).Msg("search for target volume") // TODO: replace with mql query once version with lsblk resource is released @@ -81,7 +99,7 @@ func (m *VolumeMounter) getFsInfo() (*fsInfo, error) { if err := json.Unmarshal(data, &blockEntries); err != nil { return nil, err } - var fsInfo *fsInfo + var fsInfo *PartitionInfo if m.opts[NoSetup] == "true" { // this means we didn't attach the volume to the instance // so we need to make a best effort guess @@ -102,7 +120,37 @@ func (m *VolumeMounter) getFsInfo() (*fsInfo, error) { return nil, err } -func (m *VolumeMounter) mountVolume(fsInfo *fsInfo) error { +// GetDeviceForMounting iterates through all the partitions of the target and returns the first one that matches the filters +// If target is empty, it will return the first unnamed block device (best-effort guessing) +// E.g. if target is "sda", it will return the first partition of the block device "sda" that satisfies the filters +func (m *VolumeMounter) GetDeviceForMounting(target string) (*PartitionInfo, error) { + if target == "" { + log.Debug().Msg("no target provided, searching for unnamed block device") + } else { + log.Debug().Str("target", target).Msg("search for target partition") + } + + cmd, err := m.CmdRunner.RunCommand("sudo lsblk -f --json") + if err != nil { + return nil, err + } + data, err := io.ReadAll(cmd.Stdout) + if err != nil { + return nil, err + } + blockEntries := BlockDevices{} + if err := json.Unmarshal(data, &blockEntries); err != nil { + return nil, err + } + if target == "" { + // TODO: i dont know what the difference between GetUnnamedBlockEntry and GetUnmountedBlockEntry is + // we need to simplify those + return blockEntries.GetUnnamedBlockEntry() + } + return blockEntries.GetBlockEntryByName(target) +} + +func (m *VolumeMounter) mountVolume(fsInfo *PartitionInfo) error { opts := []string{} if fsInfo.FsType == "xfs" { opts = append(opts, "nouuid") @@ -113,6 +161,10 @@ func (m *VolumeMounter) mountVolume(fsInfo *fsInfo) error { } func (m *VolumeMounter) UnmountVolumeFromInstance() error { + if m.ScanDir == "" { + log.Warn().Msg("no scan dir to unmount, skipping") + return nil + } log.Debug().Str("dir", m.ScanDir).Msg("unmount volume") if err := Unmount(m.ScanDir); err != nil { log.Error().Err(err).Msg("failed to unmount dir") From 87d7c46b7cd950e3cc30f0b66870e645a7cfffde Mon Sep 17 00:00:00 2001 From: Preslav Date: Fri, 24 May 2024 15:14:36 +0200 Subject: [PATCH 2/2] Drop unused file. --- providers/os/connection/device/linux/device_manager.go | 6 +----- providers/os/connection/device/shared/mountinfo.go | 8 -------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 providers/os/connection/device/shared/mountinfo.go diff --git a/providers/os/connection/device/linux/device_manager.go b/providers/os/connection/device/linux/device_manager.go index a8bb8c4b19..350fb28b49 100644 --- a/providers/os/connection/device/linux/device_manager.go +++ b/providers/os/connection/device/linux/device_manager.go @@ -60,11 +60,7 @@ func (d *LinuxDeviceManager) IdentifyMountTargets(opts map[string]string) ([]*sn } func (d *LinuxDeviceManager) Mount(pi *snapshot.PartitionInfo) (string, error) { - scanDir, err := d.volumeMounter.MountP(pi) - if err != nil { - return "", err - } - return scanDir, nil + return d.volumeMounter.MountP(pi) } func (d *LinuxDeviceManager) UnmountAndClose() { diff --git a/providers/os/connection/device/shared/mountinfo.go b/providers/os/connection/device/shared/mountinfo.go deleted file mode 100644 index 2ade0714a2..0000000000 --- a/providers/os/connection/device/shared/mountinfo.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Mondoo, Inc. -// SPDX-License-Identifier: BUSL-1.1 - -package shared - -type MountInfo struct { - DeviceName string -}