Skip to content

Commit 754cec1

Browse files
taukakaomirkobrombin
authored andcommitted
creates symlinks back to root
1 parent f818e46 commit 754cec1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

core/system.go

+32
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,31 @@ Options=%s
295295
return nil
296296
}
297297

298+
func (s *ABSystem) CreateRootSymlinks(systemNewPath string) error {
299+
PrintVerboseInfo("ABSystem.CreateRootSymlinks", "creating symlinks")
300+
links := []string{"mnt", "proc", "run", "dev", "media", "root", "sys", "tmp", "var"}
301+
302+
for _, link := range links {
303+
linkName := filepath.Join(systemNewPath, link)
304+
305+
err := os.RemoveAll(linkName)
306+
if err != nil {
307+
PrintVerboseErr("ABSystem.CreateRootSymlinks", 1, err)
308+
return err
309+
}
310+
311+
targetName := filepath.Join("/", link)
312+
313+
err = os.Symlink(targetName, linkName)
314+
if err != nil {
315+
PrintVerboseErr("ABSystem.CreateRootSymlinks", 2, err)
316+
return err
317+
}
318+
}
319+
320+
return nil
321+
}
322+
298323
// RunOperation executes a root-switching operation from the options below:
299324
//
300325
// UPGRADE:
@@ -730,6 +755,13 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error {
730755
return err
731756
}
732757

758+
// Create links back to the root system
759+
err = s.CreateRootSymlinks(systemNew)
760+
if err != nil {
761+
PrintVerboseErr("ABSystem.RunOperation", 7.8, err)
762+
return err
763+
}
764+
733765
// Stage 8: Sync /etc
734766
// ------------------------------------------------
735767
PrintVerboseSimple("[Stage 8] -------- ABSystemRunOperation")

0 commit comments

Comments
 (0)