From 88115a3c3667cadbb8a87bc6753641c8ad09a7b9 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Tue, 22 Oct 2024 11:14:01 -0400 Subject: [PATCH] feat(cli): add method to create empty ext2 drives --- apps/cli/src/exec/genext2fs.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apps/cli/src/exec/genext2fs.ts b/apps/cli/src/exec/genext2fs.ts index c2f7d8fa..7b69f014 100644 --- a/apps/cli/src/exec/genext2fs.ts +++ b/apps/cli/src/exec/genext2fs.ts @@ -13,6 +13,29 @@ const baseArgs = (options: { extraBlocks: number }) => [ `+${options.extraBlocks}`, ]; +export const empty = async ( + options: { + cwd?: string; + size: number; + output: string; + } & DockerFallbackOptions, +) => { + const { size, output } = options; + const blocks = Math.ceil(size / BLOCK_SIZE); // size in blocks + await execaDockerFallback( + "xgenext2fs", + [ + "--block-size", + BLOCK_SIZE.toString(), + "--faketime", + "--size-in-blocks", + blocks.toString(), + output, + ], + options, + ); +}; + export const fromDirectory = async ( options: { cwd?: string;