Skip to content

Commit d110727

Browse files
committed
fix: provide offset for partitions in discovered volumes
This was missing in the resource which makes rendering partitions in the GUI hard. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 39eeae9 commit d110727

File tree

6 files changed

+47
-2
lines changed

6 files changed

+47
-2
lines changed

api/resource/definitions/block/block.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ message DiscoveredVolumeSpec {
4242
string dev_path = 17;
4343
string parent_dev_path = 18;
4444
string pretty_size = 19;
45+
uint64 offset = 20;
4546
}
4647

4748
// DiscoveryRefreshRequestSpec is the spec for DiscoveryRefreshRequest.

internal/app/machined/pkg/controllers/block/discovery.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func (ctrl *DiscoveryController) rescan(ctx context.Context, r controller.Runtim
215215
dv.TypedSpec().ParentDevPath = filepath.Join("/dev", device.TypedSpec().Parent)
216216
}
217217

218+
dv.TypedSpec().Offset = 0
218219
dv.TypedSpec().SetSize(info.Size)
219220
dv.TypedSpec().SectorSize = info.SectorSize
220221
dv.TypedSpec().IOSize = info.IOSize
@@ -238,6 +239,7 @@ func (ctrl *DiscoveryController) rescan(ctx context.Context, r controller.Runtim
238239
dv.TypedSpec().Parent = id
239240
dv.TypedSpec().ParentDevPath = filepath.Join("/dev", id)
240241

242+
dv.TypedSpec().Offset = nested.PartitionOffset
241243
dv.TypedSpec().SetSize(nested.PartitionSize)
242244

243245
dv.TypedSpec().SectorSize = info.SectorSize

pkg/machinery/api/resource/definitions/block/block.pb.go

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/machinery/api/resource/definitions/block/block_vtproto.pb.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/machinery/resources/block/discovered_volume.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type DiscoveredVolumeSpec struct {
3030
Parent string `yaml:"parent,omitempty" protobuf:"16"`
3131
ParentDevPath string `yaml:"parent_dev_path,omitempty" protobuf:"18"`
3232

33+
// Offset of the partition/volume inside Parent device (in bytes).
34+
Offset uint64 `yaml:"offset" protobuf:"20"`
35+
3336
// Overall size of the probed device (in bytes).
3437
Size uint64 `yaml:"size" protobuf:"1"`
3538
PrettySize string `yaml:"pretty_size" protobuf:"19"`

website/content/v1.12/reference/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5545,6 +5545,7 @@ DiscoveredVolumeSpec is the spec for DiscoveredVolumes resource.
55455545
| dev_path | [string](#string) | | |
55465546
| parent_dev_path | [string](#string) | | |
55475547
| pretty_size | [string](#string) | | |
5548+
| offset | [uint64](#uint64) | | |
55485549

55495550

55505551

0 commit comments

Comments
 (0)