Skip to content

Conversation

baier233
Copy link
Contributor

VolumeSerialNumber
Data type: string
Access type: Read-only

The volume serial number of the logical disk.
Example: "A8C3-D032"

Win32_LogicalDisk docs

Signed-off-by: Baier <68586144+baier233@users.noreply.github.com>
Name: strings.TrimSpace(*logicaldisk.Caption),
Label: strings.TrimSpace(*logicaldisk.Caption),
SizeBytes: *logicaldisk.Size,
MountPoint: *logicaldisk.DeviceID,
Type: *diskpartition.Type,
IsReadOnly: toReadOnly(*diskpartition.Access),
UUID: "",
UUID: *logicaldisk.VolumeSerialNumber,
Copy link
Owner

Choose a reason for hiding this comment

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

@baier233 I think the UUID field should only contain UUIDs, so I'm not sure that VolumeSerialNumber is appropriate for that field of Partition. What about either adding a new SerialNumber field to the Partition struct or using the existing FilesystemLabel field instead?

Copy link
Contributor Author

@baier233 baier233 Apr 22, 2025

Choose a reason for hiding this comment

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

I fully agree that Volume Serial Numbers are not RFC-compliant UUIDs.

I noticed that the Linux implementation of ghw obtains partition UUIDs through the ID_PART_ENTRY_UUID attribute from udev. This means that for non-GPT partitions, the UUID field will not be RFC-compliant (see systemd PR #3293).

As documented in Debian’s Part-UUID:

"FAT and NTFS filesystems have shorter names (e.g., sda6 and sdb1), but they are still listed by UUID."

Therefore, I don't believe the UUID field must strictly contain RFC-compliant value.

To maintain backward compatibility with existing applications that expect partition identifiers in the UUID field, I believe it would be appropriate to use VolumeSerialNumber in this field.

Copy link
Owner

Choose a reason for hiding this comment

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

@baier233 OK, makes sense to me :) Could you add a note to the Partition.UUID field's docstring that mentions this may not be a UUID format for Windows partitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@baier233 OK, makes sense to me :) Could you add a note to the Partition.UUID field's docstring that mentions this may not be a UUID format for Windows partitions?

Sure,I've also updated the README description for ghw.Partition.UUID to reflect the Windows support:

Updated documentation to clarify that the UUID field may contain
non-standard UUID formats on Windows systems.

Signed-off-by: Baier <68586144+baier233@users.noreply.github.com>
Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

awesome, thank you @baier233 ! :)

@jaypipes jaypipes merged commit 97b1a1a into jaypipes:main Apr 22, 2025
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants