Signed-off-by: lifubang <lifubang@acmcoder.com>
func mountToRootfs(c *mountConfig, m mountEntry) error {
rootfs := c.root
+ defer func() {
+ if m.dstFile != nil {
+ _ = m.dstFile.Close()
+ m.dstFile = nil
+ }
+ }()
// procfs and sysfs are special because we need to ensure they are actually
// mounted on a specific path in a container without any funny business.
if err := m.createOpenMountpoint(rootfs); err != nil {
return fmt.Errorf("create mountpoint for %s mount: %w", m.Destination, err)
}
- defer func() {
- if m.dstFile != nil {
- _ = m.dstFile.Close()
- m.dstFile = nil
- }
- }()
switch m.Device {
case "mqueue":