diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-09-01 11:09:50 -0700 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-09-01 11:09:50 -0700 |
| commit | e85a15d160005929a9d5ea5cb21c25751856c5ae (patch) | |
| tree | 8ec3ce2792d50674a0f2e7f8a6de3c5fc2911cec /src/Propellor/Property/Parted.hs | |
| parent | 60950b159a2b800938929f8ae12823d5ec674667 (diff) | |
keystone for disk image creation
Untested, and grub booting not done.
Diffstat (limited to 'src/Propellor/Property/Parted.hs')
| -rw-r--r-- | src/Propellor/Property/Parted.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs index 29d94b4c..4e2efe24 100644 --- a/src/Propellor/Property/Parted.hs +++ b/src/Propellor/Property/Parted.hs @@ -3,12 +3,14 @@ module Propellor.Property.Parted ( TableType(..), PartTable(..), + partTableSize, Partition(..), mkPartition, Partition.Fs(..), PartSize(..), ByteSize, toPartSize, + fromPartSize, Partition.MkfsOpts, PartType(..), PartFlag(..), @@ -45,6 +47,12 @@ instance Monoid PartTable where -- | uses the TableType of the second parameter mappend (PartTable _l1 ps1) (PartTable l2 ps2) = PartTable l2 (ps1 ++ ps2) +-- | Gets the total size of the disk specified by the partition table. +partTableSize :: PartTable -> ByteSize +partTableSize (PartTable _ ps) = fromPartSize $ + -- add 1 megabyte to hold the partition table itself + mconcat (MegaBytes 1 : map partSize ps) + -- | A partition on the disk. data Partition = Partition { partType :: PartType @@ -89,6 +97,9 @@ instance PartedVal PartSize where toPartSize :: ByteSize -> PartSize toPartSize b = MegaBytes (b `div` 1000000) +fromPartSize :: PartSize -> ByteSize +fromPartSize (MegaBytes b) = b * 1000000 + instance Monoid PartSize where mempty = MegaBytes 0 mappend (MegaBytes a) (MegaBytes b) = MegaBytes (a + b) |
