summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/fs.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-06-04 12:30:47 -0700
committerShentubot <shentubot@google.com>2018-06-04 12:31:35 -0700
commit6c585b8eb69362db9af5ed150763096874832b86 (patch)
tree12f2269ec85c4e58d121377686377fd09a9d4e7e /runsc/boot/fs.go
parent78ccd1298e1386d9c5e0eb10d328ecb16b28ea02 (diff)
Create destination mount dir if it doesn't exist
PiperOrigin-RevId: 199175296 Change-Id: I694ad1cfa65572c92f77f22421fdcac818f44630
Diffstat (limited to 'runsc/boot/fs.go')
-rw-r--r--runsc/boot/fs.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/runsc/boot/fs.go b/runsc/boot/fs.go
index e5b7663d0..82bbea4d7 100644
--- a/runsc/boot/fs.go
+++ b/runsc/boot/fs.go
@@ -288,11 +288,21 @@ func mountSubmount(ctx context.Context, spec *specs.Spec, conf *Config, mns *fs.
if useOverlay {
log.Debugf("Adding overlay on top of mount %q", m.Destination)
- if inode, err = addOverlay(ctx, conf, inode, m.Type, mf); err != nil {
+ inode, err = addOverlay(ctx, conf, inode, m.Type, mf)
+ if err != nil {
return err
}
}
+ // Create destination in case it doesn't exist. This is required, in addition
+ // to 'addSubmountOverlay', in case there are symlinks to create directories
+ // in the right location, e.g.
+ // mount: /var/run/secrets, may be created in '/run/secrets' if
+ // '/var/run' => '/var'.
+ if err := mkdirAll(ctx, mns, m.Destination); err != nil {
+ return err
+ }
+
root := mns.Root()
defer root.DecRef()
dirent, err := mns.FindInode(ctx, root, nil, m.Destination, linux.MaxSymlinkTraversals)