MCPcopy
hub / github.com/containerd/containerd / deserializeLinuxIDMapping

Function deserializeLinuxIDMapping

internal/userns/idmap.go:159–175  ·  view source on GitHub ↗

deserializeLinuxIDMapping unmarshals a string to a LinuxIDMapping object

(str string)

Source from the content-addressed store, hash-verified

157
158// deserializeLinuxIDMapping unmarshals a string to a LinuxIDMapping object
159func deserializeLinuxIDMapping(str string) (specs.LinuxIDMapping, error) {
160 var (
161 hostID, ctrID, length int64
162 )
163 _, err := fmt.Sscanf(str, "%d:%d:%d", &ctrID, &hostID, &length)
164 if err != nil {
165 return specs.LinuxIDMapping{}, fmt.Errorf("input value %s unparsable: %w", str, err)
166 }
167 if ctrID < 0 || ctrID >= invalidID || hostID < 0 || hostID >= invalidID || length < 0 || length >= invalidID {
168 return specs.LinuxIDMapping{}, fmt.Errorf("invalid mapping \"%s\"", str)
169 }
170 return specs.LinuxIDMapping{
171 ContainerID: uint32(ctrID),
172 HostID: uint32(hostID),
173 Size: uint32(length),
174 }, nil
175}

Callers 1

UnmarshalMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…