(context *cli.Context)
| 81 | } |
| 82 | |
| 83 | func prepareImagePaths(context *cli.Context) (string, string, error) { |
| 84 | imagePath := context.String("image-path") |
| 85 | if imagePath == "" { |
| 86 | imagePath = getDefaultImagePath() |
| 87 | } |
| 88 | |
| 89 | if err := os.MkdirAll(imagePath, 0o600); err != nil { |
| 90 | return "", "", err |
| 91 | } |
| 92 | |
| 93 | parentPath := context.String("parent-path") |
| 94 | if parentPath == "" { |
| 95 | return imagePath, parentPath, nil |
| 96 | } |
| 97 | |
| 98 | if filepath.IsAbs(parentPath) { |
| 99 | return "", "", errors.New("--parent-path must be relative") |
| 100 | } |
| 101 | |
| 102 | realParent := filepath.Join(imagePath, parentPath) |
| 103 | fi, err := os.Stat(realParent) |
| 104 | if err == nil && !fi.IsDir() { |
| 105 | err = &os.PathError{Path: realParent, Err: unix.ENOTDIR} |
| 106 | } |
| 107 | |
| 108 | if err != nil { |
| 109 | return "", "", fmt.Errorf("invalid --parent-path: %w", err) |
| 110 | } |
| 111 | |
| 112 | return imagePath, parentPath, nil |
| 113 | } |
| 114 | |
| 115 | func criuOptions(context *cli.Context) (*libcontainer.CriuOpts, error) { |
| 116 | imagePath, parentPath, err := prepareImagePaths(context) |
no test coverage detected
searching dependent graphs…