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)
| 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) |
| 63 | func 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: |
no outgoing calls
no test coverage detected
searching dependent graphs…