summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/DiskImage.hs
diff options
context:
space:
mode:
authorJoey Hess2017-07-05 14:03:07 -0400
committerJoey Hess2017-07-05 14:03:07 -0400
commit9d6c50fff28ed5ba7da7fdd2989c7773e357a3c3 (patch)
tree6fba6644518aecd6fedfde5c42fbe01783f37aab /src/Propellor/Property/DiskImage.hs
parent05b0648e0be87700ecd7ce3a36c966aa96beff7b (diff)
parente77e60604ac908e0895af202e83a47096d60b059 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/DiskImage.hs')
-rw-r--r--src/Propellor/Property/DiskImage.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 90b7010b..d5898d7c 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -247,7 +247,7 @@ getMountSz szm l (Just mntpt) =
--
-- If the file is too large, truncates it down to the specified size.
imageExists :: FilePath -> ByteSize -> Property Linux
-imageExists img sz = property ("disk image exists" ++ img) $ liftIO $ do
+imageExists img isz = property ("disk image exists" ++ img) $ liftIO $ do
ms <- catchMaybeIO $ getFileStatus img
case ms of
Just s
@@ -258,6 +258,12 @@ imageExists img sz = property ("disk image exists" ++ img) $ liftIO $ do
_ -> do
L.writeFile img (L.replicate (fromIntegral sz) 0)
return MadeChange
+ where
+ sz = ceiling (fromInteger isz / sectorsize) * ceiling sectorsize
+ -- Disks have a sector size, and making a disk image not
+ -- aligned to a sector size will confuse some programs.
+ -- Common sector sizes are 512 and 4096; use 4096 as it's larger.
+ sectorsize = 4096 :: Double
-- | A pair of properties. The first property is satisfied within the
-- chroot, and is typically used to download the boot loader.