Fix use of mounted() in overlay.

Handle error and mounted case separately.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
(cherry picked from commit 57ca2a2101)
This commit is contained in:
Anusha Ragunathan 2016-03-23 13:20:46 -07:00 committed by Tibor Vass
parent 6be088a3eb
commit c985e2b84b

View file

@ -365,6 +365,16 @@ func (d *Driver) Get(id string, mountLabel string) (string, error) {
mergedDir := path.Join(dir, "merged")
opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerDir, upperDir, workDir)
// if it's mounted already, just return
mounted, err := d.mounted(mergedDir)
if err != nil {
return "", err
}
if mounted {
return mergedDir, nil
}
if err := syscall.Mount("overlay", mergedDir, "overlay", 0, label.FormatMountLabel(opts, mountLabel)); err != nil {
return "", fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err)
}