Skip to content

Commit

Permalink
fixup! overlord/fdestate/fdestate.go: fix path to data mount point on…
Browse files Browse the repository at this point in the history
… hybrid
  • Loading branch information
valentindavid committed Nov 21, 2024
1 parent 457e84e commit 491569b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions dirs/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ var (

FeaturesDir string

RootDataDir string
// WritableMountPath is a path where writable root data is
// mounted. For Classic it is /, but Ubuntu Core it is
// /writable.
WritableMountPath string
)

// User defined home directory variables
Expand Down Expand Up @@ -639,10 +642,10 @@ func SetRootDir(rootdir string) {

if release.OnClassic {
// On Classic, the data disk is mounted as /
RootDataDir = rootdir
WritableMountPath = rootdir
} else {
// If on Core /writable is a bind mount from data dir
RootDataDir = filepath.Join(rootdir, "writable")
WritableMountPath = filepath.Join(rootdir, "writable")
}

}
Expand Down
8 changes: 4 additions & 4 deletions dirs/dirs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,16 @@ func (s *DirsTestSuite) TestLibexecdirOpenSUSEFlavors(c *C) {
c.Check(dirs.DistroLibExecDir, Equals, "/usr/libexec/snapd")
}

func (s *DirsTestSuite) TestRootDataDir(c *C) {
func (s *DirsTestSuite) TestWritableMountPath(c *C) {
release.MockOnClassic(true)
dirs.SetRootDir("/")

c.Check(dirs.RootDataDir, Equals, "/")
c.Check(dirs.WritableMountPath, Equals, "/")
}

func (s *DirsTestSuite) TestRootDataDirCore(c *C) {
func (s *DirsTestSuite) TestWritableMountPathCore(c *C) {
release.MockOnClassic(false)
dirs.SetRootDir("/")

c.Check(dirs.RootDataDir, Equals, "/writable")
c.Check(dirs.WritableMountPath, Equals, "/writable")
}
2 changes: 1 addition & 1 deletion overlord/fdestate/fdestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func initializeState(st *state.State) error {

// FIXME mount points will be different in recovery or factory-reset modes
// either inspect degraded.json, or use boot.HostUbuntuDataForMode()
dataUUID, dataErr := disksDMCryptUUIDFromMountPoint(dirs.RootDataDir)
dataUUID, dataErr := disksDMCryptUUIDFromMountPoint(dirs.WritableMountPath)
saveUUID, saveErr := disksDMCryptUUIDFromMountPoint(dirs.SnapSaveDir)
if errors.Is(saveErr, disks.ErrMountPointNotFound) {
// TODO: do we need to care about old cases where there is no save partition?
Expand Down

0 comments on commit 491569b

Please sign in to comment.