Subject: Re: [bug#29409] [PATCH 4/4] bootloader: Factorize write-file-on-device.

From: [email-masked] (Ludovic Courtès)
Date: Mon, 11 Dec 2017 17:40:00 +0100

[email-masked] skribis:

> From: Mathieu Othacehe <[email-masked]>
>
> * gnu/bootloader/extlinux.scm (install-extlinux): Factorize bootloader
>   writing in a new procedure ...
> * gnu/bootloader.scm (write-file-on-device): ... defined and exported here.

LGTM!

> +(define write-file-on-device
> +  #~(lambda (file size device offset)
> +      ;; Write SIZE bytes from FILE to DEVICE starting at OFFSET.
> +      (call-with-input-file file
> +        (lambda (input)
> +          (let ((bv (get-bytevector-n input size)))
> +            (call-with-output-file device
> +              (lambda (output)
> +                (seek output offset SEEK_SET)
> +                (put-bytevector output bv))
> +              #:binary #t))))))

Eventually we might want to move it to (gnu build vm) or to create a new
(gnu build bootloader) module with build-side code for bootloaders.

Thanks!

Ludo’.