summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Mount.hs
blob: f4d10302c557170da36f0dd5813a7494bb363031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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]