summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-05-27 17:00:16 -0400
committerAndrew Cady <d@jerkface.net>2020-05-28 03:29:39 -0400
commita35b2f7ba9d18ac7fb89111e55924218042cbc4a (patch)
tree05a6aa47601ed25cfb6e8df886a9958dc6ce4b07 /src
parent694309e7cae73b7f428238fc51242d1804c1cf4a (diff)
Begin support for "seeded images."
A seeded image keeps its parent image as a read-only "seed" device that joins the seeded image in a multi-device btrfs filesystem. That means that to mount such an image, the parent image must be made available as a block device (e.g. using losetup, or dd to an existing block device and run btfrs device scan). Such support had been added to the Samizdat Makefile, but more properly belongs here. This is the sequence of commands used by sami.git's Makefile to accomplish the effect: rm -f $@~tmp touch $@~tmp fallocate -l $(samizdat_btrfs_patch_size) $@~tmp test -d $@.mnt || mkdir $@.mnt ! mountpoint -q $@.mnt || umount $@.mnt mount -o compress,ro -t btrfs $< $@.mnt a=$(get_loop_dev); [ -z "$$a" ] || losetup -d $$a losetup -f $@~tmp btrfs device add $(get_loop_dev) $@.mnt mount -o compress,rw,remount $@.mnt The Makefile also defines: get_loop_dev="$$(sudo losetup -n -O name -j $@~tmp)" The same basic sequence is carried out here. The config file format is modified so that to get a seeded image you specify "seedme: <bytes>" where <bytes> is the size of the seeded image. This feature is complete enough to create a seeded image (i.e., to replace the Makefile), but children of a seeded image seem impossible to work because there is no code yet to run losetup on seed images of parents. Thus it can be expected that deriving from a parent with a seed will fail when fsmgr tries to mount the parent.
Diffstat (limited to 'src')
-rw-r--r--src/ConfigFile.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ConfigFile.hs b/src/ConfigFile.hs
index bc5e254..08aa914 100644
--- a/src/ConfigFile.hs
+++ b/src/ConfigFile.hs
@@ -48,6 +48,7 @@ data Patch = Patch deriving (Show, Read)
48data BaseImageSpecification 48data BaseImageSpecification
49 = EmptyImageOfBytes Int64 49 = EmptyImageOfBytes Int64
50 | ParentImageConfigFile FilePath 50 | ParentImageConfigFile FilePath
51 | SeededImage Int64 FilePath
51 deriving (Show, Read) 52 deriving (Show, Read)
52 53
53data DiskImageConfig = DiskImageConfig { 54data DiskImageConfig = DiskImageConfig {
@@ -60,6 +61,7 @@ data DiskImageConfig = DiskImageConfig {
60, chrootCommands :: Vector Text 61, chrootCommands :: Vector Text
61, skelFiles :: Vector Text 62, skelFiles :: Vector Text
62, optionalSkelFiles :: Vector Text 63, optionalSkelFiles :: Vector Text
64, newSeededImgSize :: Maybe Int64
63} deriving (Show, Read) 65} deriving (Show, Read)
64 66
65parsePackageName :: Text -> Package 67parsePackageName :: Text -> Package
@@ -77,7 +79,12 @@ diskImageConfigParser = object $
77 <*> defaultField "chroot-commands" Vector.empty (array string) 79 <*> defaultField "chroot-commands" Vector.empty (array string)
78 <*> defaultField "skel-files" Vector.empty (array string) 80 <*> defaultField "skel-files" Vector.empty (array string)
79 <*> defaultField "skel-files-optional" Vector.empty (array string) 81 <*> defaultField "skel-files-optional" Vector.empty (array string)
82 <*> optField "seedme" integer
83
84convSeeded :: DiskImageConfig -> DiskImageConfig
85convSeeded x@(DiskImageConfig (ParentImageConfigFile f) _ _ _ _ _ _ _ _ (Just size)) = x { initialImage = SeededImage size f }
86convSeeded x = x
80 87
81readCfg :: FilePath -> Action DiskImageConfig 88readCfg :: FilePath -> Action DiskImageConfig
82readCfg yaml = either error id . parse diskImageConfigParser . encodeUtf8 . pack <$> readFile' yaml 89readCfg yaml = either error convSeeded . parse diskImageConfigParser . encodeUtf8 . pack <$> readFile' yaml
83 90