MCPcopy
hub / github.com/containerd/containerd / apply

Function apply

core/diff/apply/apply_linux.go:34–73  ·  view source on GitHub ↗
(ctx context.Context, mounts []mount.Mount, r io.Reader, sync bool)

Source from the content-addressed store, hash-verified

32)
33
34func apply(ctx context.Context, mounts []mount.Mount, r io.Reader, sync bool) (retErr error) {
35 switch {
36 case len(mounts) == 1 && mounts[0].Type == "overlay":
37 // OverlayConvertWhiteout (mknod c 0 0) doesn't work in userns.
38 // https://github.com/containerd/containerd/issues/3762
39 if userns.RunningInUserNS() {
40 break
41 }
42 path, parents, err := getOverlayPath(mounts[0].Options)
43 if err != nil {
44 if errdefs.IsInvalidArgument(err) {
45 break
46 }
47 return err
48 }
49 opts := []archive.ApplyOpt{
50 archive.WithConvertWhiteout(archive.OverlayConvertWhiteout),
51 }
52 if len(parents) > 0 {
53 opts = append(opts, archive.WithParents(parents))
54 }
55 _, err = archive.Apply(ctx, path, r, opts...)
56 if err == nil && sync {
57 err = doSyncFs(path)
58 }
59 return err
60 case sync && len(mounts) == 1 && mounts[0].Type == "bind":
61 defer func() {
62 if retErr != nil {
63 return
64 }
65
66 retErr = doSyncFs(mounts[0].Source)
67 }()
68 }
69 return mount.WithTempMount(ctx, mounts, func(root string) error {
70 _, err := archive.Apply(ctx, root, r)
71 return err
72 })
73}
74
75func getOverlayPath(options []string) (upper string, lower []string, err error) {
76 const upperdirPrefix = "upperdir="

Callers

nothing calls this directly

Calls 6

WithConvertWhiteoutFunction · 0.92
WithParentsFunction · 0.92
ApplyFunction · 0.92
WithTempMountFunction · 0.92
getOverlayPathFunction · 0.85
doSyncFsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…