From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOR8e-0008Dx-Ec for guix-patches@gnu.org; Mon, 11 Dec 2017 11:41:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOR8Y-0000ea-Ug for guix-patches@gnu.org; Mon, 11 Dec 2017 11:41:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:48439) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eOR8Y-0000eK-RG for guix-patches@gnu.org; Mon, 11 Dec 2017 11:41:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eOR8Y-0005U1-GQ for guix-patches@gnu.org; Mon, 11 Dec 2017 11:41:02 -0500 Subject: [bug#29409] [PATCH 4/4] bootloader: Factorize write-file-on-device. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <1512565193-3234-1-git-send-email-m.othacehe@gmail.com> <1512565193-3234-5-git-send-email-m.othacehe@gmail.com> Date: Mon, 11 Dec 2017 17:40:00 +0100 In-Reply-To: <1512565193-3234-5-git-send-email-m.othacehe@gmail.com> (m. othacehe's message of "Wed, 6 Dec 2017 13:59:53 +0100") Message-ID: <878te9w74v.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: m.othacehe@gmail.com Cc: 29409@debbugs.gnu.org m.othacehe@gmail.com skribis: > From: Mathieu Othacehe > > * gnu/bootloader/extlinux.scm (install-extlinux): Factorize bootloader > writing in a new procedure ... > * gnu/bootloader.scm (write-file-on-device): ... defined and exported her= e. 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=E2=80=99.