|
@@ -52,7 +52,7 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
|
|
numFields := len(fields)
|
|
numFields := len(fields)
|
|
if numFields < 10 {
|
|
if numFields < 10 {
|
|
// should be at least 10 fields
|
|
// should be at least 10 fields
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: not enough fields (%d)", text, numFields)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: not enough fields (%d)", text, numFields)
|
|
}
|
|
}
|
|
|
|
|
|
// separator field
|
|
// separator field
|
|
@@ -67,7 +67,7 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
|
|
for fields[sepIdx] != "-" {
|
|
for fields[sepIdx] != "-" {
|
|
sepIdx--
|
|
sepIdx--
|
|
if sepIdx == 5 {
|
|
if sepIdx == 5 {
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: missing - separator", text)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: missing - separator", text)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -75,46 +75,39 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
|
|
|
|
|
|
p.Mountpoint, err = unescape(fields[4])
|
|
p.Mountpoint, err = unescape(fields[4])
|
|
if err != nil {
|
|
if err != nil {
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: mount point: %w", fields[4], err)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: mount point: %w", fields[4], err)
|
|
}
|
|
}
|
|
p.FSType, err = unescape(fields[sepIdx+1])
|
|
p.FSType, err = unescape(fields[sepIdx+1])
|
|
if err != nil {
|
|
if err != nil {
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
|
|
}
|
|
}
|
|
p.Source, err = unescape(fields[sepIdx+2])
|
|
p.Source, err = unescape(fields[sepIdx+2])
|
|
if err != nil {
|
|
if err != nil {
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: source: %w", fields[sepIdx+2], err)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: source: %w", fields[sepIdx+2], err)
|
|
}
|
|
}
|
|
p.VFSOptions = fields[sepIdx+3]
|
|
p.VFSOptions = fields[sepIdx+3]
|
|
|
|
|
|
// ignore any numbers parsing errors, as there should not be any
|
|
// ignore any numbers parsing errors, as there should not be any
|
|
p.ID, _ = strconv.Atoi(fields[0])
|
|
p.ID, _ = strconv.Atoi(fields[0])
|
|
p.Parent, _ = strconv.Atoi(fields[1])
|
|
p.Parent, _ = strconv.Atoi(fields[1])
|
|
- mm := strings.Split(fields[2], ":")
|
|
|
|
|
|
+ mm := strings.SplitN(fields[2], ":", 3)
|
|
if len(mm) != 2 {
|
|
if len(mm) != 2 {
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: unexpected minor:major pair %s", text, mm)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: unexpected major:minor pair %s", text, mm)
|
|
}
|
|
}
|
|
p.Major, _ = strconv.Atoi(mm[0])
|
|
p.Major, _ = strconv.Atoi(mm[0])
|
|
p.Minor, _ = strconv.Atoi(mm[1])
|
|
p.Minor, _ = strconv.Atoi(mm[1])
|
|
|
|
|
|
p.Root, err = unescape(fields[3])
|
|
p.Root, err = unescape(fields[3])
|
|
if err != nil {
|
|
if err != nil {
|
|
- return nil, fmt.Errorf("Parsing '%s' failed: root: %w", fields[3], err)
|
|
|
|
|
|
+ return nil, fmt.Errorf("parsing '%s' failed: root: %w", fields[3], err)
|
|
}
|
|
}
|
|
|
|
|
|
p.Options = fields[5]
|
|
p.Options = fields[5]
|
|
|
|
|
|
// zero or more optional fields
|
|
// zero or more optional fields
|
|
- switch {
|
|
|
|
- case sepIdx == 6:
|
|
|
|
- // zero, do nothing
|
|
|
|
- case sepIdx == 7:
|
|
|
|
- p.Optional = fields[6]
|
|
|
|
- default:
|
|
|
|
- p.Optional = strings.Join(fields[6:sepIdx-1], " ")
|
|
|
|
- }
|
|
|
|
|
|
+ p.Optional = strings.Join(fields[6:sepIdx], " ")
|
|
|
|
|
|
- // Run the filter after parsing all of the fields.
|
|
|
|
|
|
+ // Run the filter after parsing all fields.
|
|
var skip, stop bool
|
|
var skip, stop bool
|
|
if filter != nil {
|
|
if filter != nil {
|
|
skip, stop = filter(p)
|
|
skip, stop = filter(p)
|