Merge pull request #442 from rhatdan/tmpfsperms

Mounting a tmpfs directory needs to inherit directory permissions from base
This commit is contained in:
Mrunal Patel 2015-03-11 21:10:31 -07:00
commit 58feafa848
1 changed files with 17 additions and 1 deletions

View File

@ -100,7 +100,23 @@ func mount(m *configs.Mount, rootfs, mountLabel string) error {
return err return err
} }
return syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), "") return syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), "")
case "tmpfs", "mqueue", "devpts", "sysfs": case "tmpfs":
stat, err := os.Stat(dest)
if err != nil {
if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
return err
}
}
if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data); err != nil {
return err
}
if stat != nil {
if err = os.Chmod(dest, stat.Mode()); err != nil {
return err
}
}
return nil
case "mqueue", "devpts", "sysfs":
if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) { if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
return err return err
} }