I ended up needing to slightly modify the proposed algorithm, I was thinking the "partition" file in sysfs was a boolean indicating if it was a partition, but actually it corresponds literally to the partition number for that device, so the proposed logic should just check for the existence of the partition file. the proposed algorithm should now read something like this (note the if condition is different inside the for loop - that is the only change)
udevProps, err := $(udevadm info --query property --name /dev/block/$diskMajor:$devMinor)
if err != nil
return err("broken")
I ended up needing to slightly modify the proposed algorithm, I was thinking the "partition" file in sysfs was a boolean indicating if it was a partition, but actually it corresponds literally to the partition number for that device, so the proposed logic should just check for the existence of the partition file. the proposed algorithm should now read something like this (note the if condition is different inside the for loop - that is the only change)
udevProps, err := $(udevadm info --query property --name /dev/block/ $diskMajor: $devMinor)
if err != nil
return err("broken")
diskDevName = filepath. Base(udevProps[ "DEVNAME" ]) "DEVPATH" ]
diskDevPath = udevProps[
childPartitions = {}
partitionMajor = ueventFile["MAJOR"]
partitionMinor = ueventFile["MINOR"] $partitionMajor :$partitionMino r)
childPartition s[ udevProps[ "ID_FS_ LABEL_ENC" ] ] = udevProps[ "ID_PART_ ENTRY_UUID" ]
paths := glob("/sys" + diskDevPath + "/" + diskDevPath + "*")
for path in paths:
if fileExists(path + "/partition"):
ueventFile = readFile(path + "/uevent")
udevProps := $(udevadm info --query property --name /dev/block/