haskell-examples/ZfsDevices.hs
2025-02-19 04:01:35 +00:00

34 lines
No EOL
710 B
Haskell

-- Copyright © 2025 Hashirama Senju
import System.Zfs.Zpool
import System.Zfs.Types
import System.Zfs
import Control.Monad.IO.Class
import System.Process (callCommand)
import Control.Concurrent (threadDelay)
main' :: Zfs ()
main' = do
forZpools_ $ \zpool -> do
nm <- getZpoolName zpool
liftIO $ putStrLn ("Pool: "++nm)
vdevs <- getVdevs zpool
liftIO $ print vdevs
enableDatasets zpool ""
liftIO $ putStrLn "Mounting..."
return ()
main :: IO ()
main = do
callCommand "zpool import -a -N > /dev/null 2>&1" -- detection, a ffi would be more elegant
threadDelay (10 * 1000000)
res <- runZfs main'
case res of
Left e -> print e
Right n -> return ()