Skip to content

Commit

Permalink
mountinfo: GetMountsFromReader: inline some assignments
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jul 21, 2024
1 parent cb890fc commit b145b7c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions mountinfo/mountinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
}

p := &Info{
ID: toInt(fields[0]),
Parent: toInt(fields[1]),
Major: toInt(major),
Minor: toInt(minor),
ID: toInt(fields[0]),
Parent: toInt(fields[1]),
Major: toInt(major),
Minor: toInt(minor),
Options: fields[5],
Optional: strings.Join(fields[6:sepIdx], " "), // zero or more optional fields
VFSOptions: fields[sepIdx+3],
}

p.Mountpoint, err = unescape(fields[4])
Expand All @@ -99,18 +102,12 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
if err != nil {
return nil, fmt.Errorf("parsing '%s' failed: source: %w", fields[sepIdx+2], err)
}
p.VFSOptions = fields[sepIdx+3]

p.Root, err = unescape(fields[3])
if err != nil {
return nil, fmt.Errorf("parsing '%s' failed: root: %w", fields[3], err)
}

p.Options = fields[5]

// zero or more optional fields
p.Optional = strings.Join(fields[6:sepIdx], " ")

// Run the filter after parsing all fields.
var skip, stop bool
if filter != nil {
Expand Down

0 comments on commit b145b7c

Please sign in to comment.