From ebe81e975882ca3d4fcfe8e80fe9747f0128e2bc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 28 Jul 2017 22:18:29 -0400 Subject: Added Mount.isMounted. * Added Mount.isMounted. * Grub.bootsMounted: Bugfix. --- src/Propellor/Property/Mount.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Propellor/Property/Mount.hs') diff --git a/src/Propellor/Property/Mount.hs b/src/Propellor/Property/Mount.hs index 5dcc5fe1..2c4d9620 100644 --- a/src/Propellor/Property/Mount.hs +++ b/src/Propellor/Property/Mount.hs @@ -78,6 +78,10 @@ mount fs src mnt opts = boolSystem "mount" $ mountPoints :: IO [MountPoint] mountPoints = lines <$> readProcess "findmnt" ["-rn", "--output", "target"] +-- | Checks if anything is mounted at the MountPoint. +isMounted :: MountPoint -> IO Bool +isMounted mnt = isJust <$> getFsType mnt + -- | Finds all filesystems mounted inside the specified directory. mountPointsBelow :: FilePath -> IO [MountPoint] mountPointsBelow target = filter (\p -> simplifyPath p /= simplifyPath target) @@ -129,12 +133,15 @@ blkidTag tag dev = catchDefaultIO Nothing $ -- | Unmounts a device or mountpoint, -- lazily so any running processes don't block it. +-- +-- Note that this will fail if it's not mounted. umountLazy :: FilePath -> IO () umountLazy mnt = unlessM (boolSystem "umount" [ Param "-l", Param mnt ]) $ stopPropellorMessage $ "failed unmounting " ++ mnt --- | Unmounts anything mounted inside the specified directory. +-- | Unmounts anything mounted inside the specified directory, +-- not including the directory itself. unmountBelow :: FilePath -> IO () unmountBelow d = do submnts <- mountPointsBelow d -- cgit v1.3-2-g0d8e