diff --git a/providers/os/connection/device/device_connection.go b/providers/os/connection/device/device_connection.go index 9119c54c5..7057ffcee 100644 --- a/providers/os/connection/device/device_connection.go +++ b/providers/os/connection/device/device_connection.go @@ -5,7 +5,6 @@ package device import ( "errors" - "path" "runtime" "strings" @@ -191,10 +190,7 @@ func (p *DeviceConnection) Partitions() map[string]*snapshot.PartitionInfo { // tryDetectAsset tries to detect the OS on a given block device func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inventory.Config, asset *inventory.Asset) (*fs.FileSystemConnection, error) { - fsPath := partition.MountPoint - if partition.Bind != "" { - fsPath = path.Join(fsPath, partition.Bind) - } + fsPath := partition.RootDir() // create and initialize fs provider log.Debug().Str("path", fsPath).Msg("device connection> trying to detect asset") diff --git a/providers/os/connection/snapshot/partition.go b/providers/os/connection/snapshot/partition.go index 33163fbd7..b96997038 100644 --- a/providers/os/connection/snapshot/partition.go +++ b/providers/os/connection/snapshot/partition.go @@ -4,6 +4,7 @@ package snapshot import ( + "path" "strings" ) @@ -51,3 +52,7 @@ func (entry BlockDevice) isMounted() bool { func (entry PartitionInfo) key() string { return strings.Join(append([]string{entry.Name, entry.Uuid}, entry.MountOptions...), "|") } + +func (i PartitionInfo) RootDir() string { + return path.Join(i.MountPoint, i.Bind) +}