mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-06 19:40:08 +00:00
Bump to use vfs4 (#240)
This commit is contained in:
@@ -133,7 +133,6 @@ func (c *Chroot) Close() error {
|
||||
// RunCallback runs the given callback in a chroot environment
|
||||
func (c *Chroot) RunCallback(callback func() error) (err error) {
|
||||
var currentPath string
|
||||
var oldRootF *os.File
|
||||
|
||||
// Store current path
|
||||
currentPath, err = os.Getwd()
|
||||
@@ -149,12 +148,11 @@ func (c *Chroot) RunCallback(callback func() error) (err error) {
|
||||
}()
|
||||
|
||||
// Store current root
|
||||
oldRootF, err = c.config.Fs.Open("/")
|
||||
rootPath, _ := c.config.Fs.RawPath("/")
|
||||
if err != nil {
|
||||
c.config.Logger.Errorf("Can't open current root")
|
||||
return err
|
||||
}
|
||||
defer oldRootF.Close()
|
||||
|
||||
if len(c.activeMounts) == 0 {
|
||||
err = c.Prepare()
|
||||
@@ -184,7 +182,7 @@ func (c *Chroot) RunCallback(callback func() error) (err error) {
|
||||
|
||||
// Restore to old root
|
||||
defer func() {
|
||||
tmpErr := oldRootF.Chdir()
|
||||
tmpErr := os.Chdir(rootPath)
|
||||
if tmpErr != nil {
|
||||
c.config.Logger.Errorf("Can't change to old root dir")
|
||||
if err == nil {
|
||||
|
Reference in New Issue
Block a user