From d9866a1ba5d0a4adca8bd026c652b762302bba45 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 5 Sep 2017 16:30:58 -0400 Subject: move parseFs to Property.Partition --- ...reation__44___resize__44___format___38___removal.mdwn | 2 ++ .../comment_5_aee8b3d2768fb7307a6cc2e3295fd1f6._comment | 7 +++++++ src/Propellor/Property/Lvm.hs | 16 ++-------------- src/Propellor/Property/Partition.hs | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal/comment_5_aee8b3d2768fb7307a6cc2e3295fd1f6._comment diff --git a/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal.mdwn b/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal.mdwn index 0910ef5d..4b3198ee 100644 --- a/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal.mdwn +++ b/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal.mdwn @@ -5,3 +5,5 @@ I am not confident my haskell code is good looking as this is my first real life You can pull the lvm branch at http://git.ni.fr.eu.org/nicolas/propellor.git Thanks! + +> merge [[done]] --[[Joey]] diff --git a/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal/comment_5_aee8b3d2768fb7307a6cc2e3295fd1f6._comment b/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal/comment_5_aee8b3d2768fb7307a6cc2e3295fd1f6._comment new file mode 100644 index 00000000..8d007461 --- /dev/null +++ b/doc/todo/LVM_logical_volume_creation__44___resize__44___format___38___removal/comment_5_aee8b3d2768fb7307a6cc2e3295fd1f6._comment @@ -0,0 +1,7 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 5""" + date="2017-09-05T20:23:44Z" + content=""" +Looks good to me, merged. Thanks for your contribution! +"""]] diff --git a/src/Propellor/Property/Lvm.hs b/src/Propellor/Property/Lvm.hs index e1f3b934..c5d215bc 100644 --- a/src/Propellor/Property/Lvm.hs +++ b/src/Propellor/Property/Lvm.hs @@ -142,27 +142,15 @@ lvState lv = do then return Nothing else do s <- readLvSize - fs <- readFs + fs <- maybe Nothing (Partition.parseFs . takeWhile (/= '\n')) <$> readFs return $ do size <- s - return $ LvState size $ parseFs $ - takeWhile (/= '\n') <$> fs + return $ LvState size fs where readLvSize = catchDefaultIO Nothing $ readish <$> readProcess "lvs" [ "-o", "size", "--noheadings", "--nosuffix", "--units", "b", vglv lv ] readFs = Mount.blkidTag "TYPE" (path lv) - parseFs (Just "ext2") = Just Partition.EXT2 - parseFs (Just "ext3") = Just Partition.EXT3 - parseFs (Just "ext4") = Just Partition.EXT4 - parseFs (Just "btrfs") = Just Partition.BTRFS - parseFs (Just "reiserfs") = Just Partition.REISERFS - parseFs (Just "xfs") = Just Partition.XFS - parseFs (Just "fat") = Just Partition.FAT - parseFs (Just "vfat") = Just Partition.VFAT - parseFs (Just "ntfs") = Just Partition.NTFS - parseFs (Just "swap") = Just Partition.LinuxSwap - parseFs _ = Nothing -- Read extent size (or Nothing on error). vgExtentSize :: VolumeGroup -> IO (Maybe Integer) diff --git a/src/Propellor/Property/Partition.hs b/src/Propellor/Property/Partition.hs index 679675b7..27ae89ff 100644 --- a/src/Propellor/Property/Partition.hs +++ b/src/Propellor/Property/Partition.hs @@ -15,6 +15,20 @@ import Data.Char data Fs = EXT2 | EXT3 | EXT4 | BTRFS | REISERFS | XFS | FAT | VFAT | NTFS | LinuxSwap deriving (Show, Eq) +-- | Parse commonly used names of filesystems. +parseFs :: String -> Maybe Fs +parseFs "ext2" = Just EXT2 +parseFs "ext3" = Just EXT3 +parseFs "ext4" = Just EXT4 +parseFs "btrfs" = Just BTRFS +parseFs "reiserfs" = Just REISERFS +parseFs "xfs" = Just XFS +parseFs "fat" = Just FAT +parseFs "vfat" = Just VFAT +parseFs "ntfs" = Just NTFS +parseFs "swap" = Just LinuxSwap +parseFs _ = Nothing + data Eep = YesReallyFormatPartition -- | Formats a partition. -- cgit v1.2.3