From a7e71faaaa0ed2672b956691833ca6c3a3431189 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 5 Dec 2014 17:54:29 -0400 Subject: forgot to add new Mount lib --- src/Propellor/Property/Mount.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Propellor/Property/Mount.hs diff --git a/src/Propellor/Property/Mount.hs b/src/Propellor/Property/Mount.hs new file mode 100644 index 00000000..f4d10302 --- /dev/null +++ b/src/Propellor/Property/Mount.hs @@ -0,0 +1,23 @@ +module Propellor.Property.Mount where + +import Propellor +import Utility.SafeCommand + +type FsType = String +type Source = String + +mountPoints :: IO [FilePath] +mountPoints = lines <$> readProcess "findmnt" ["-rn", "--output", "target"] + +getFsType :: FilePath -> IO (Maybe FsType) +getFsType mnt = catchDefaultIO Nothing $ + headMaybe . lines + <$> readProcess "findmnt" ["-n", mnt, "--output", "fstype"] + +umountLazy :: FilePath -> IO () +umountLazy mnt = + unlessM (boolSystem "umount" [ Param "-l", Param mnt ]) $ + errorMessage $ "failed unmounting " ++ mnt + +mount :: FsType -> Source -> FilePath -> IO Bool +mount fs src mnt = boolSystem "mount" [Param "-t", Param fs, Param src, Param mnt] -- cgit v1.2.3