Subject: bug#26815: [PATCH 2/3] vm: Support creating FAT partitions.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 08 May 2017 08:59:24 -0700

Hi,

Marius Bakke <[email-masked]> writes:

> * gnu/build/vm.scm (create-ext-file-system, create-fat-file-system): New procedures.
> (format-partition): Use procedures. Error for unknown file systems.
> * gnu/system/vm.scm (qemu-image): Add DOSFSTOOLS to the closure.
> * gnu/system/linux-initrd.scm (base-initrd): Add nls_is8859-1.ko regardless of
> whether a FAT filesystem is present.
> ---
>  gnu/build/vm.scm            | 43 ++++++++++++++++++++++++++++++++++++-------
>  gnu/system/linux-initrd.scm |  4 +---
>  gnu/system/vm.scm           |  2 +-
>  3 files changed, 38 insertions(+), 11 deletions(-)
>
> diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
> index 3286ffb02..ad39e29ce 100644
> --- a/gnu/build/vm.scm
> +++ b/gnu/build/vm.scm
> @@ -214,17 +214,46 @@ actual /dev name based on DEVICE."
>  
>  (define MS_BIND 4096)                             ; <sys/mounts.h> again!
>  
> +(define* (create-ext-file-system partition type
> +                                 #:key label)
> +  "Create an ext-family filesystem of TYPE on PARTITION.  If LABEL is true,
> +use that as the volume name."
> +  (format #t "creating ~a partition...\n" type)
> +  (apply system* (string-append "mkfs." type)

Is there a reason why we don't simply call system* directly here? And
similarly below. I don't see the gain of using `apply'. Maybe I'm
missing something.

> +         "-F" partition
> +         (if label
> +             `("-L" ,label)
> +             '())))
> +
> +(define* (create-fat32-file-system partition
> +                                   #:key label)
> +  "Create a FAT32 filesystem on PARTITION, which must be at least 32 MiB long.
> +If LABEL is true, use that as volume name."
> +  (format #t "Creating FAT32 partition...\n")
> +  ;; Without the -F parameter, mkfs.fat will automatically determine
> +  ;; the number of file allocation tables based on partition size.
> +  ;; Ensure a FAT32 partition for compatibility with e.g. UEFI.
> +  (apply system* "mkfs.fat" "-F32" partition
> +         (if label
> +             `("-n" ,label)
> +             '())))
> +

Maxim