summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/DiskImage/PartSpec.hs
blob: 6a29af4ea4005d033a1088fe44a560a763cb2a01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- | Disk image partition specification and combinators.

-- Partitions in disk images default to being sized large enough to hold
-- the files that appear in the directory where the partition is to be
-- mounted. Plus a fudge factor, since filesystems have some space
-- overhead.

module Propellor.Property.DiskImage.PartSpec (
	module Propellor.Types.PartSpec,
	module Propellor.Property.DiskImage.PartSpec,
) where

import Propellor.Base
import Propellor.Property.Parted
import Propellor.Types.PartSpec

-- | Adds additional free space to the partition.
addFreeSpace :: PartSpec t -> PartSize -> PartSpec t
addFreeSpace (mp, o, p, t) freesz = (mp, o, p', t)
  where
	p' = \sz -> p (sz <> freesz)

-- | Add 2% for filesystem overhead. Rationalle for picking 2%:
-- A filesystem with 1% overhead might just sneak by as acceptable.
-- Double that just in case. Add an additional 3 mb to deal with
-- non-scaling overhead of filesystems (eg, superblocks). 
-- Add an additional 200 mb for temp files, journals, etc.
fudge :: PartSize -> PartSize
fudge (MegaBytes n) = MegaBytes (n + n `div` 100 * 2 + 3 + 200)