Add ZfsDevices.hs

This commit is contained in:
千住柱間 2025-02-19 00:54:01 +00:00
commit 382943544e

30
ZfsDevices.hs Normal file
View file

@ -0,0 +1,30 @@
-- Copyright © 2025 Hashirama Senju
import System.Zfs.Zpool
import System.Zfs.Types
import System.Zfs
import Control.Monad.IO.Class
{-
zfs functions can only be accessed throught the zfs monad.
-}
main' :: Zfs ()
main' = do
forZpools_ $ \zpool -> do
nm <- getZpoolName zpool
-- effects also must be done within the zfs monad
liftIO $ putStrLn ("Pool: "++nm)
vdevs <- getVdevs zpool
liftIO $ print vdevs
return ()
main :: IO ()
main = do
-- and you can only run the zfs monad using the "runZfs" function
res <- runZfs main'
case res of
Left e -> print e
Right n -> return ()