Skip to content

Commit cc2dd88

Browse files
Unmount the block device after use:
This clean up is needed to avoid any possible issues with subsequent Actions. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent 7ac1b83 commit cc2dd88

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

writefile/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ func main() {
8585
logger.Error("Mounting block device", "blockDevice", blockDevice, "mountAction", mountAction, "error", err)
8686
os.Exit(1)
8787
}
88-
88+
defer func() {
89+
if err := syscall.Unmount(mountAction, 0); err != nil {
90+
logger.Error("Error unmounting device", "source", blockDevice, "destination", mountAction, "error", err)
91+
} else {
92+
logger.Info("Unmounted device successfully", "source", blockDevice, "destination", mountAction)
93+
}
94+
}()
8995
logger.Info("Mounted device successfully", "source", blockDevice, "destination", mountAction)
9096

9197
if err := recursiveEnsureDir(mountAction, dirPath, newDirMode, fileUID, fileGID); err != nil {

0 commit comments

Comments
 (0)