From 754cec1e762778c0b5cdd63a863849dc822f3f77 Mon Sep 17 00:00:00 2001 From: Tau Date: Sun, 2 Jun 2024 01:35:52 +0200 Subject: [PATCH] creates symlinks back to root --- core/system.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/core/system.go b/core/system.go index 4a019dda..1d96bf4b 100644 --- a/core/system.go +++ b/core/system.go @@ -295,6 +295,31 @@ Options=%s return nil } +func (s *ABSystem) CreateRootSymlinks(systemNewPath string) error { + PrintVerboseInfo("ABSystem.CreateRootSymlinks", "creating symlinks") + links := []string{"mnt", "proc", "run", "dev", "media", "root", "sys", "tmp", "var"} + + for _, link := range links { + linkName := filepath.Join(systemNewPath, link) + + err := os.RemoveAll(linkName) + if err != nil { + PrintVerboseErr("ABSystem.CreateRootSymlinks", 1, err) + return err + } + + targetName := filepath.Join("/", link) + + err = os.Symlink(targetName, linkName) + if err != nil { + PrintVerboseErr("ABSystem.CreateRootSymlinks", 2, err) + return err + } + } + + return nil +} + // RunOperation executes a root-switching operation from the options below: // // UPGRADE: @@ -730,6 +755,13 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error { return err } + // Create links back to the root system + err = s.CreateRootSymlinks(systemNew) + if err != nil { + PrintVerboseErr("ABSystem.RunOperation", 7.8, err) + return err + } + // Stage 8: Sync /etc // ------------------------------------------------ PrintVerboseSimple("[Stage 8] -------- ABSystemRunOperation")