MCPcopy Create free account
hub / github.com/containerd/nerdctl / getRoot

Function getRoot

pkg/containerutil/cp_linux.go:63–80  ·  view source on GitHub ↗

getRoot will tentatively return the root of the container on the host (/proc/pid/root), along with the pid, (eg: doable when the container is running)

(ctx context.Context, container containerd.Container)

Source from the content-addressed store, hash-verified

61// getRoot will tentatively return the root of the container on the host (/proc/pid/root), along with the pid,
62// (eg: doable when the container is running)
63func getRoot(ctx context.Context, container containerd.Container) (string, int, error) {
64 task, err := container.Task(ctx, nil)
65 if err != nil {
66 return "", 0, err
67 }
68
69 status, err := task.Status(ctx)
70 if err != nil {
71 return "", 0, err
72 }
73
74 if status.Status != containerd.Running {
75 return "", 0, nil
76 }
77 pid := int(task.Pid())
78
79 return fmt.Sprintf("/proc/%d/root", pid), pid, nil
80}
81
82// CopyFiles implements `nerdctl cp`
83// It currently depends on the following assumptions:

Callers 1

CopyFilesFunction · 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…