[disk][freebsd] return empty serial on `(null)` geom disk ident
This commit is contained in:
parent
df68a56e2d
commit
0d33df272b
|
@ -176,13 +176,17 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
|
||||||
return "", fmt.Errorf("exec geom: %w", err)
|
return "", fmt.Errorf("exec geom: %w", err)
|
||||||
}
|
}
|
||||||
s := bufio.NewScanner(bytes.NewReader(geomOut))
|
s := bufio.NewScanner(bytes.NewReader(geomOut))
|
||||||
|
serial := ""
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
flds := strings.Fields(s.Text())
|
flds := strings.Fields(s.Text())
|
||||||
if len(flds) == 2 && flds[0] == "ident:" {
|
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) {
|
func LabelWithContext(ctx context.Context, name string) (string, error) {
|
||||||
|
|
Loading…
Reference in New Issue