MCPcopy
hub / github.com/containerd/containerd / parseBlockCIMMount

Function parseBlockCIMMount

plugins/diff/windows/cimfs.go:163–200  ·  view source on GitHub ↗

parseBlockCIMMount parses the mount returned by the BlockCIM snapshotter and returns

(m *mount.Mount)

Source from the content-addressed store, hash-verified

161
162// parseBlockCIMMount parses the mount returned by the BlockCIM snapshotter and returns
163func parseBlockCIMMount(m *mount.Mount) (*cimfs.BlockCIM, []*cimfs.BlockCIM, error) {
164 var (
165 parentPaths []string
166 )
167
168 for _, option := range m.Options {
169 if val, ok := strings.CutPrefix(option, mount.ParentLayerCimPathsFlag); ok {
170 err := json.Unmarshal([]byte(val), &parentPaths)
171 if err != nil {
172 return nil, nil, err
173 }
174 } else if val, ok = strings.CutPrefix(option, mount.BlockCIMTypeFlag); ok {
175 // only support single file for extraction for now
176 if val != mount.BlockCIMTypeFile {
177 return nil, nil, fmt.Errorf("extraction doesn't support layer type `%s`", val)
178 }
179 }
180 }
181
182 var (
183 parentLayers []*cimfs.BlockCIM
184 extractionLayer *cimfs.BlockCIM
185 )
186
187 extractionLayer = &cimfs.BlockCIM{
188 Type: cimfs.BlockCIMTypeSingleFile,
189 BlockPath: filepath.Dir(m.Source),
190 CimName: filepath.Base(m.Source),
191 }
192 for _, p := range parentPaths {
193 parentLayers = append(parentLayers, &cimfs.BlockCIM{
194 Type: cimfs.BlockCIMTypeSingleFile,
195 BlockPath: filepath.Dir(p),
196 CimName: filepath.Base(p),
197 })
198 }
199 return extractionLayer, parentLayers, nil
200}
201
202// Apply applies the content associated with the provided digests onto the
203// provided mounts. Archive content will be extracted and decompressed if

Callers 1

ApplyMethod · 0.85

Calls 2

UnmarshalMethod · 0.80
DirMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…