MCPcopy
hub / github.com/opencontainers/runc / prepareImagePaths

Function prepareImagePaths

checkpoint.go:83–113  ·  view source on GitHub ↗
(context *cli.Context)

Source from the content-addressed store, hash-verified

81}
82
83func 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
115func criuOptions(context *cli.Context) (*libcontainer.CriuOpts, error) {
116 imagePath, parentPath, err := prepareImagePaths(context)

Callers 1

criuOptionsFunction · 0.85

Calls 2

getDefaultImagePathFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…