Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow separating the WWN vendor extension #363

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,13 @@ type Disk struct {
Model string `json:"model"`
// SerialNumber is the serial number of the disk.
SerialNumber string `json:"serial_number"`
// WWN is the World-wide Number of the disk.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, thanks for the correction!

// WWN is the World-wide Name of the disk.
// See: https://en.wikipedia.org/wiki/World_Wide_Name
WWN string `json:"wwn"`
// WWNNoExtension is the World-wide Name of the disk with any vendor
// extensions excluded.
// See: https://en.wikipedia.org/wiki/World_Wide_Name
WWNNoExtension string `json:"wwnNoExtension"`
// Partitions contains an array of pointers to `Partition` structs, one for
// each partition on the disk.
Partitions []*Partition `json:"partitions"`
Expand Down
1 change: 1 addition & 0 deletions pkg/block/block_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func (info *Info) load() error {
Model: ioregPlist.ModelNumber,
SerialNumber: ioregPlist.SerialNumber,
WWN: "",
WWNNoExtension: "",
Partitions: make([]*Partition, 0, len(disk.Partitions)+len(disk.APFSVolumes)),
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/block/block_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ func diskBusPath(paths *linuxpath.Paths, disk string) string {
return util.UNKNOWN
}

func diskWWNNoExtension(paths *linuxpath.Paths, disk string) string {
info, err := udevInfoDisk(paths, disk)
if err != nil {
return util.UNKNOWN
}

if wwn, ok := info["ID_WWN"]; ok {
return wwn
}
return util.UNKNOWN
}

func diskWWN(paths *linuxpath.Paths, disk string) string {
info, err := udevInfoDisk(paths, disk)
if err != nil {
Expand Down Expand Up @@ -326,6 +338,7 @@ func disks(ctx *context.Context, paths *linuxpath.Paths) []*Disk {
model := diskModel(paths, dname)
serialNo := diskSerialNumber(paths, dname)
wwn := diskWWN(paths, dname)
wwnNoExtension := diskWWNNoExtension(paths, dname)
removable := diskIsRemovable(paths, dname)

if storageController == STORAGE_CONTROLLER_LOOP && size == 0 {
Expand All @@ -345,6 +358,7 @@ func disks(ctx *context.Context, paths *linuxpath.Paths) []*Disk {
Model: model,
SerialNumber: serialNo,
WWN: wwn,
WWNNoExtension: wwnNoExtension,
}

parts := diskPartitions(ctx, paths, dname)
Expand Down
1 change: 1 addition & 0 deletions pkg/block/block_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (i *Info) load() error {
Model: strings.TrimSpace(*diskdrive.Caption),
SerialNumber: strings.TrimSpace(*diskdrive.SerialNumber),
WWN: util.UNKNOWN, // TODO: add information
WWNNoExtension: util.UNKNOWN, // TODO: add information
Partitions: make([]*Partition, 0),
}
for _, diskpartition := range win32DiskPartitionDescriptions {
Expand Down
Loading