From 72037875343ef0ae83f307e727255fd465e8c899 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Mon, 7 Aug 2023 16:35:15 +0200 Subject: [PATCH] Semi force the umount of oem when dealing with mounts (#40) --- system/cloudconfig.go | 5 +---- system/grub.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/system/cloudconfig.go b/system/cloudconfig.go index 47e3722..bad9358 100644 --- a/system/cloudconfig.go +++ b/system/cloudconfig.go @@ -35,14 +35,11 @@ func addCloudConfig(cloudConfig, filename string) error { func writeCloudConfig(oem state.PartitionState, cloudConfig, subpath, filename string) error { mountPath := "/tmp/oem" + defer mounts.Umount(state.PartitionState{Mounted: true, MountPoint: mountPath}) //nolint:errcheck if err := mounts.PrepareWrite(oem, mountPath); err != nil { return err } - defer func() { - oem.MountPoint = mountPath - mounts.Umount(oem) //nolint:errcheck - }() _ = os.MkdirAll(filepath.Join(mountPath, subpath), 0650) return os.WriteFile(filepath.Join(mountPath, subpath, fmt.Sprintf("%s.yaml", filename)), []byte(cloudConfig), 0650) } diff --git a/system/grub.go b/system/grub.go index ce67236..ad83a7c 100644 --- a/system/grub.go +++ b/system/grub.go @@ -19,6 +19,7 @@ func SetGRUBOptions(opts map[string]string) Option { func setGRUBOptions(opts map[string]string) error { mountPath := "/tmp/oem" + defer mounts.Umount(state.PartitionState{Mounted: true, MountPoint: mountPath}) //nolint:errcheck runtime, err := state.NewRuntime() if err != nil { return err @@ -32,10 +33,6 @@ func setGRUBOptions(opts map[string]string) error { if err := mounts.PrepareWrite(oem, mountPath); err != nil { return err } - defer func() { - oem.MountPoint = mountPath - mounts.Umount(oem) //nolint:errcheck - }() for k, v := range opts { out, err := utils.SH(fmt.Sprintf(`%s /tmp/oem/grubenv set "%s=%s"`, utils.FindCommand("grub2-editenv", []string{"grub2-editenv", "grub-editenv"}), k, v))