Skip to content

Commit

Permalink
overlord/snapstate/backend: use public StripGlobalRootDir
Browse files Browse the repository at this point in the history
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Aug 24, 2016
1 parent 78753be commit 04b09b4
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions overlord/snapstate/backend/mountunit.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ import (
"github.com/snapcore/snapd/systemd"
)

func stripGlobalRootDir(dir string) string {
if dirs.GlobalRootDir == "/" {
return dir
}

return dir[len(dirs.GlobalRootDir):]
}

func addMountUnit(s *snap.Info, meter progress.Meter) error {
squashfsPath := stripGlobalRootDir(s.MountFile())
whereDir := stripGlobalRootDir(s.MountDir())
squashfsPath := dirs.StripGlobalRootDir(s.MountFile())
whereDir := dirs.StripGlobalRootDir(s.MountDir())

sysd := systemd.New(dirs.GlobalRootDir, meter)
mountUnitName, err := sysd.WriteMountUnitFile(s.Name(), squashfsPath, whereDir, "squashfs")
Expand All @@ -64,7 +56,7 @@ func addMountUnit(s *snap.Info, meter progress.Meter) error {

func removeMountUnit(baseDir string, meter progress.Meter) error {
sysd := systemd.New(dirs.GlobalRootDir, meter)
unit := systemd.MountUnitPath(stripGlobalRootDir(baseDir), "mount")
unit := systemd.MountUnitPath(dirs.StripGlobalRootDir(baseDir), "mount")
if osutil.FileExists(unit) {
if err := sysd.Stop(filepath.Base(unit), time.Duration(1*time.Second)); err != nil {
return err
Expand Down

0 comments on commit 04b09b4

Please sign in to comment.