Skip to content

Commit

Permalink
Merge pull request #1884 from giuseppe/revert-bring-read-mappings-proc
Browse files Browse the repository at this point in the history
Revert "bring read mappings proc into c/storage"
  • Loading branch information
openshift-merge-bot[bot] committed Apr 11, 2024
2 parents dfdc6bf + 5d45d46 commit 1fd0dc1
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions pkg/unshare/unshare_linux.go
Expand Up @@ -708,37 +708,6 @@ func GetSubIDMappings(user, group string) ([]specs.LinuxIDMapping, []specs.Linux
return uidmap, gidmap, nil
}

// ReadMappingsProc parses and returns the ID mappings at the specified path.
func ReadMappingsProc(path string) ([]idtools.IDMap, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()

mappings := []idtools.IDMap{}

buf := bufio.NewReader(file)
for {
line, _, err := buf.ReadLine()
if err != nil {
if err == io.EOF {
return mappings, nil
}
return nil, fmt.Errorf("cannot read line from %s: %w", path, err)
}
if line == nil {
return mappings, nil
}

containerID, hostID, size := 0, 0, 0
if _, err := fmt.Sscanf(string(line), "%d %d %d", &containerID, &hostID, &size); err != nil {
return nil, fmt.Errorf("cannot parse %s: %w", string(line), err)
}
mappings = append(mappings, idtools.IDMap{ContainerID: containerID, HostID: hostID, Size: size})
}
}

// ParseIDMappings parses mapping triples.
func ParseIDMappings(uidmap, gidmap []string) ([]idtools.IDMap, []idtools.IDMap, error) {
uid, err := idtools.ParseIDMap(uidmap, "userns-uid-map")
Expand Down

0 comments on commit 1fd0dc1

Please sign in to comment.