Skip to content

Commit 6342dae

Browse files
committed
Ensure that parent directories exist for config files
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent baf9418 commit 6342dae

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
* Fix bug in creation of `/dev/char` symlinks by failing operation if kernel modules are not loaded.
1414
* Add option to load kernel modules when creating device nodes
1515
* Add option to create device nodes when creating `/dev/char` symlinks
16-
* Bump CUDA base image version to 12.1.1.
16+
* Create ouput folders if required when running `nvidia-ctk runtime configure`
17+
1718

1819
* [libnvidia-container] Support OpenSSL 3 with the Encrypt/Decrypt library
1920

21+
* [toolkit-container] Bump CUDA base image version to 12.1.1.
22+
2023
## v1.13.1
2124

2225
* Update `update-ldcache` hook to only update ldcache if it exists.

pkg/config/engine/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package engine
1919
import (
2020
"fmt"
2121
"os"
22+
"path/filepath"
2223
)
2324

2425
// Config represents a runtime config
@@ -43,6 +44,13 @@ func (c Config) Write(output []byte) (int, error) {
4344
return 0, nil
4445
}
4546

47+
if dir := filepath.Dir(path); dir != "" {
48+
err := os.MkdirAll(dir, 0755)
49+
if err != nil {
50+
return 0, fmt.Errorf("unable to create directory %v: %v", dir, err)
51+
}
52+
}
53+
4654
f, err := os.Create(path)
4755
if err != nil {
4856
return 0, fmt.Errorf("unable to open %v for writing: %v", path, err)

0 commit comments

Comments
 (0)