Skip to content

Commit

Permalink
do not re-use the rootfs name for overlay upper dir
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Dykstra <2129743+DrDaveD@users.noreply.github.com>
  • Loading branch information
DrDaveD authored and edytuk committed Jul 7, 2023
1 parent c3fa965 commit d4fdf44
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/ocibundle/tools/overlay_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,21 @@ func CreateOverlay(bundlePath string) error {
Writable: true,
}}

return olSet.Mount(RootFs(bundlePath).Path())
upDir := filepath.Join(bundlePath, "upper")
if err := os.MkdirAll(upDir, 0o755); err != nil {
return fmt.Errorf("failed to create %s: %s", upDir, err)
}

return olSet.Mount(filepath.Join(upDir))
}

// DeleteOverlay deletes an overlay previously created using a directory inside
// the OCI bundle.
func DeleteOverlay(bundlePath string) error {
olDir := filepath.Join(bundlePath, "overlay")
rootFsDir := RootFs(bundlePath).Path()
upDir := filepath.Join(bundlePath, "upper")

if err := overlay.DetachMount(rootFsDir); err != nil {
if err := overlay.DetachMount(upDir); err != nil {
return err
}

Expand Down Expand Up @@ -100,7 +105,7 @@ func CreateOverlayTmpfs(bundlePath string, sizeMiB int) (string, error) {
Writable: true,
}}

err = olSet.Mount(RootFs(bundlePath).Path())
err = olSet.Mount(filepath.Join(bundlePath, "upper"))
if err != nil {
return "", err
}
Expand All @@ -110,9 +115,9 @@ func CreateOverlayTmpfs(bundlePath string, sizeMiB int) (string, error) {

// DeleteOverlayTmpfs deletes an overlay previously created using tmpfs.
func DeleteOverlayTmpfs(bundlePath, olDir string) error {
rootFsDir := RootFs(bundlePath).Path()
upDir := filepath.Join(bundlePath, "upper")

if err := overlay.DetachMount(rootFsDir); err != nil {
if err := overlay.DetachMount(upDir); err != nil {
return err
}

Expand Down

0 comments on commit d4fdf44

Please sign in to comment.