diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-09-04 14:20:13 -0700 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-09-04 14:20:13 -0700 |
| commit | 555c82f69eaa929ac5aef9e277a488e9d38ea626 (patch) | |
| tree | 5f9d902ac7c49e4a09e3fdcb3fbd97abf5947b1d /src/Propellor/Property/DiskImage.hs | |
| parent | 6db275cc18a24bf9bf3bf2a173aa2ce56974d86c (diff) | |
fudge factor for partition sizes
Diffstat (limited to 'src/Propellor/Property/DiskImage.hs')
| -rw-r--r-- | src/Propellor/Property/DiskImage.hs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index 2e1ebc46..3cd4b46a 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -118,7 +118,7 @@ imageBuiltFrom img chrootdir tabletype partspec final = mkimg <!> rmimg liftIO $ unmountBelow chrootdir szm <- M.mapKeys (toSysDir chrootdir) . M.map toPartSize <$> liftIO (dirSizes chrootdir) - let calcsz = \mnts -> fromMaybe defSz . getMountSz szm mnts + let calcsz = \mnts -> maybe defSz fudge . getMountSz szm mnts -- tie the knot! let (mnts, t) = fitChrootSize tabletype partspec (map (calcsz mnts) mnts) ensureProperty $ @@ -194,11 +194,6 @@ dirSizes top = go M.empty top [top] else go (M.insertWith (+) dir sz m) dir is subdirof parent i = not (i `equalFilePath` parent) && takeDirectory i `equalFilePath` parent --- | Gets the size to allocate for a particular mount point, given the --- map of sizes. --- --- A list of all mount points is provided, so that when eg calculating --- the size for /, if /boot is a mount point, its size can be subtracted. getMountSz :: (M.Map FilePath PartSize) -> [MountPoint] -> MountPoint -> Maybe PartSize getMountSz _ _ Nothing = Nothing getMountSz szm l (Just mntpt) = @@ -226,11 +221,14 @@ type MountPoint = Maybe FilePath defSz :: PartSize defSz = MegaBytes 128 +fudge :: PartSize -> PartSize +fudge (MegaBytes n) = MegaBytes (n + n `div` 10) + -- | Specifies a mount point and a constructor for a Partition. -- -- The size that is eventually provided is the amount of space needed to -- hold the files that appear in the directory where the partition is to be --- mounted. +-- mounted. Plus a fudge factor, since filesystems have some space overhead. -- -- (Partitions that are not to be mounted (ie, LinuxSwap), or that have -- no corresponding directory in the chroot will have 128 MegaBytes |
