diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-05-13 00:30:42 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-13 00:30:42 +0000 |
commit | e2755f43b8b7f63d3b06008816c7b7dcb56bd9c2 (patch) | |
tree | 895fd463a7e2f9f9e6d224eef84696957a5e21ba /runsc/boot | |
parent | c6a3b4e89350ca8bcd7c77a8c80ae5ee233c8813 (diff) | |
parent | 305f786e51ea2092c633d97b06818e59c5f40552 (diff) |
Merge release-20200422.0-294-g305f786 (automated)
Diffstat (limited to 'runsc/boot')
-rwxr-xr-x | runsc/boot/vfs.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/runsc/boot/vfs.go b/runsc/boot/vfs.go index b94211866..ef95d0c65 100755 --- a/runsc/boot/vfs.go +++ b/runsc/boot/vfs.go @@ -245,7 +245,6 @@ func (c *containerMounter) mountSubmountVFS2(ctx context.Context, conf *Config, if err := c.makeSyntheticMount(ctx, submount.Destination, root, creds); err != nil { return err } - log.Debugf("directory exists or made directory for submount: %s", submount.Destination) opts := &vfs.MountOptions{ GetFilesystemOptions: vfs.GetFilesystemOptions{ @@ -260,7 +259,7 @@ func (c *containerMounter) mountSubmountVFS2(ctx context.Context, conf *Config, if err := c.k.VFS().MountAt(ctx, creds, "", target, fsName, opts); err != nil { return fmt.Errorf("failed to mount %q (type: %s): %w, opts: %v", submount.Destination, submount.Type, err, opts) } - log.Infof("Mounted %q to %q type: %s, internal-options: %q", submount.Source, submount.Destination, submount.Type, opts) + log.Infof("Mounted %q to %q type: %s, internal-options: %q", submount.Source, submount.Destination, submount.Type, opts.GetFilesystemOptions.Data) return nil } @@ -321,23 +320,23 @@ func (c *containerMounter) makeSyntheticMount(ctx context.Context, currentPath s Start: root, Path: fspath.Parse(currentPath), } - _, err := c.k.VFS().StatAt(ctx, creds, target, &vfs.StatOptions{}) - switch { - case err == syserror.ENOENT: - if err := c.makeSyntheticMount(ctx, path.Dir(currentPath), root, creds); err != nil { - return err - } - mkdirOpts := &vfs.MkdirOptions{Mode: 0777, ForSyntheticMountpoint: true} - if err := c.k.VFS().MkdirAt(ctx, creds, target, mkdirOpts); err != nil { - return fmt.Errorf("failed to makedir for mount %+v: %w", target, err) - } + if err == nil { + // Mount point exists, nothing else to do. return nil + } + if err != syserror.ENOENT { + return fmt.Errorf("stat failed for %q during mount point creation: %w", currentPath, err) + } - case err != nil: - return fmt.Errorf("stat failed for mount %+v: %w", target, err) - - default: - return nil + // Recurse to ensure parent is created and then create the mount point. + if err := c.makeSyntheticMount(ctx, path.Dir(currentPath), root, creds); err != nil { + return err + } + log.Debugf("Creating dir %q for mount point", currentPath) + mkdirOpts := &vfs.MkdirOptions{Mode: 0777, ForSyntheticMountpoint: true} + if err := c.k.VFS().MkdirAt(ctx, creds, target, mkdirOpts); err != nil { + return fmt.Errorf("failed to create directory %q for mount: %w", currentPath, err) } + return nil } |