[disk][freebsd] return empty serial on `(null)` geom disk ident

This commit is contained in:
Ville Skyttä 2022-01-06 23:16:03 +02:00
parent df68a56e2d
commit 0d33df272b
1 changed files with 6 additions and 2 deletions

View File

@ -176,13 +176,17 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
return "", fmt.Errorf("exec geom: %w", err)
}
s := bufio.NewScanner(bytes.NewReader(geomOut))
serial := ""
for s.Scan() {
flds := strings.Fields(s.Text())
if len(flds) == 2 && flds[0] == "ident:" {
return flds[1], nil
if flds[1] != "(null)" {
serial = flds[1]
}
break
}
}
return "", nil
return serial, nil
}
func LabelWithContext(ctx context.Context, name string) (string, error) {