summaryrefslogtreecommitdiffhomepage
path: root/runsc/container/fs.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-01-15 14:12:19 -0800
committerShentubot <shentubot@google.com>2019-01-15 14:13:27 -0800
commit92cf3764e032740f0c84a1b242c54b99f45a6bf0 (patch)
tree9e82455ddf0894b177e24cf1d8289b30f9a82e8a /runsc/container/fs.go
parent9a01287d23fd4e70067ff82190e7df39a297395c (diff)
Create working directory if it doesn't yet exist
PiperOrigin-RevId: 229438125 Change-Id: I58eb0d10178d1adfc709d7b859189d1acbcb2f22
Diffstat (limited to 'runsc/container/fs.go')
-rw-r--r--runsc/container/fs.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/runsc/container/fs.go b/runsc/container/fs.go
index 41022686b..97195550f 100644
--- a/runsc/container/fs.go
+++ b/runsc/container/fs.go
@@ -87,7 +87,7 @@ func setupFS(spec *specs.Spec, conf *boot.Config, bundleDir string) ([]specs.Mou
// container.
dst, err := resolveSymlinks(spec.Root.Path, m.Destination)
if err != nil {
- return nil, fmt.Errorf("failed to resolve symlinks: %v", err)
+ return nil, fmt.Errorf("resolving symlinks to %q: %v", m.Destination, err)
}
flags := optionsToFlags(m.Options)
@@ -113,6 +113,16 @@ func setupFS(spec *specs.Spec, conf *boot.Config, bundleDir string) ([]specs.Mou
rv = append(rv, cpy)
}
+ if spec.Process.Cwd != "" {
+ dst, err := resolveSymlinks(spec.Root.Path, spec.Process.Cwd)
+ if err != nil {
+ return nil, fmt.Errorf("resolving symlinks to %q: %v", spec.Process.Cwd, err)
+ }
+ if err := os.MkdirAll(dst, 0755); err != nil {
+ return nil, err
+ }
+ }
+
// If root is read only, check if it needs to be remounted as readonly.
if spec.Root.Readonly {
isMountPoint, readonly, err := mountInfo(spec.Root.Path)