Skip to content

Commit

Permalink
feat: pass aliases to partitions info
Browse files Browse the repository at this point in the history
  • Loading branch information
slntopp committed Nov 14, 2024
1 parent 0d5431c commit a414f13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions providers/os/connection/snapshot/blockdevices.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ func (blockEntries BlockDevices) FindDevice(requested string) (BlockDevice, erro
func (device BlockDevice) GetMountablePartitions(includeAll bool) ([]*PartitionInfo, error) {
log.Debug().Str("device", device.Name).Msg("get partitions for device")

blockDevices := device.Children
blockDevices := &BlockDevices{
BlockDevices: device.Children,
}

// sort the candidates by size, so we can pick the largest one
sortBlockDevicesBySize(blockDevices)
sortBlockDevicesBySize(blockDevices.BlockDevices)
blockDevices.findAliases()

filter := func(partition BlockDevice) bool {
if partition.FsType == "" {
Expand All @@ -184,14 +187,15 @@ func (device BlockDevice) GetMountablePartitions(includeAll bool) ([]*PartitionI
}

partitions := []*PartitionInfo{}
for _, partition := range blockDevices {
for _, partition := range blockDevices.BlockDevices {
log.Debug().Str("name", partition.Name).Int64("size", int64(partition.Size)).Msg("checking partition")
if filter(partition) {
log.Debug().Str("name", partition.Name).Msg("found suitable partition")
devFsName := "/dev/" + partition.Name
partitions = append(partitions, &PartitionInfo{
Name: devFsName, FsType: partition.FsType,
Label: partition.Label, Uuid: partition.Uuid,
Aliases: partition.Aliases,
})
} else {
log.Debug().
Expand Down
1 change: 1 addition & 0 deletions providers/os/connection/snapshot/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type PartitionInfo struct {
Name string
FsType string

Aliases []string
// (optional) Label is the partition label
Label string
// (optional) UUID is the partition UUID
Expand Down

0 comments on commit a414f13

Please sign in to comment.