(ctx context.Context, mounts []mount.Mount, r io.Reader, sync bool)
| 32 | ) |
| 33 | |
| 34 | func 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 | |
| 75 | func getOverlayPath(options []string) (upper string, lower []string, err error) { |
| 76 | const upperdirPrefix = "upperdir=" |
nothing calls this directly
no test coverage detected
searching dependent graphs…