Add ZfsDevices.hs
This commit is contained in:
parent
1e4ba9d4ed
commit
382943544e
1 changed files with 30 additions and 0 deletions
30
ZfsDevices.hs
Normal file
30
ZfsDevices.hs
Normal 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 ()
|
||||
Loading…
Reference in a new issue