Skip to content

Commit

Permalink
feat: RootDir method
Browse files Browse the repository at this point in the history
  • Loading branch information
slntopp committed Dec 19, 2024
1 parent f85f980 commit 099237d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions providers/os/connection/device/device_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package device

import (
"errors"
"path"
"runtime"
"strings"

Expand Down Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions providers/os/connection/snapshot/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package snapshot

import (
"path"
"strings"
)

Expand Down Expand Up @@ -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)
}

0 comments on commit 099237d

Please sign in to comment.