35 lines
749 B
Go
35 lines
749 B
Go
package mountfilesystem
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
"kisekinopureya.com.tr/updater/internal/logger"
|
|
)
|
|
|
|
func MountFileSystem(source string, target string, fsType string, flags int, data string) {
|
|
logger.InitializeLogger("/tmp/mountLog")
|
|
|
|
if err := unix.Mkdir(target, 0755); err != nil && !os.IsExist(err) {
|
|
log.Panic(err)
|
|
}
|
|
|
|
err := unix.Mount(source, target, fsType, uintptr(flags), data)
|
|
if err != nil {
|
|
log.Panic(fmt.Errorf("mount failed: %w", err))
|
|
}
|
|
fmt.Println("Mounted successfully at", target)
|
|
}
|
|
|
|
func UnmountFileSystem(target string) {
|
|
logger.InitializeLogger("/tmp/unmountLog")
|
|
err := unix.Unmount(target, 0)
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
fmt.Println("Unmounted successfully at", target)
|
|
|
|
}
|