all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marius Bakke <mbakke@fastmail.com>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 26815@debbugs.gnu.org
Subject: bug#26815: [PATCH 2/3] vm: Support creating FAT partitions.
Date: Sun, 07 May 2017 21:15:28 +0200	[thread overview]
Message-ID: <87tw4wxyun.fsf@fastmail.com> (raw)
In-Reply-To: <20170507190637.0bf9c4ce@scratchpost.org>


[-- Attachment #1.1: Type: text/plain, Size: 948 bytes --]

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Marius,
>
> On Sun, 07 May 2017 17:52:43 +0200
> Marius Bakke <mbakke@fastmail.com> wrote:
>
>> I had that first, but the error handling was exactly identical, so opted
>> to just handle it in the caller. It does sound safer to handle errors
>> there instead of passing system* around though, will do that in lieu of
>> other comments. 
>
> Yeah, I did that in the past, too (and for many things still do).  But this procedure is critical enough that ignoring the return value would do some very strange things - and for those I lately do defensive programming.
>
>> > "format-procedure" is not actually the procedure, right? It's already the formatting-status ...  
>> 
>> Oops, an artifact of rebasing a lot of revisions...
>
> Your v2 patch still calls it that :)

D'oh. It could of course be much simpler after removing the error
handling too..

v3 attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-vm-Support-creating-FAT-partitions.patch --]
[-- Type: text/x-patch, Size: 4628 bytes --]

From 44c112dfe0d92847f32040d558f5970ae99c600d Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Sat, 6 May 2017 22:53:58 +0200
Subject: [PATCH] vm: Support creating FAT partitions.

* 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            | 31 +++++++++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +---
 gnu/system/vm.scm           |  2 +-
 3 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 3286ffb02..206696ef6 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -214,10 +214,10 @@ actual /dev name based on DEVICE."
 
 (define MS_BIND 4096)                             ; <sys/mounts.h> again!
 
-(define* (format-partition partition type
-                           #:key label)
-  "Create a file system TYPE on PARTITION.  If LABEL is true, use that as the
-volume name."
+(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)
   (unless (zero? (apply system* (string-append "mkfs." type)
                         "-F" partition
@@ -226,6 +226,29 @@ volume name."
                             '())))
     (error "failed to create partition")))
 
+(define* (create-fat-file-system partition
+                                 #:key label)
+  "Create a FAT filesystem on PARTITION.  The number of File Allocation Tables
+will be determined based on filesystem size.  If LABEL is true, use that as the
+volume name."
+  (format #t "creating FAT partition...\n")
+  (unless (zero? (apply system* "mkfs.fat" partition
+                        (if label
+                            `("-n" ,label)
+                            '())))
+    (error "failed to create FAT partition")))
+
+(define* (format-partition partition type
+                           #:key label)
+  "Create a file system TYPE on PARTITION.  If LABEL is true, use that as the
+volume name."
+  (cond
+   ((string-prefix? "ext" type)
+    (create-ext-file-system partition type #:label label))
+   ((string-suffix? "fat" type)
+    (create-fat-file-system partition #:label label))
+     (else (error "Unsupported file system."))))
+
 (define (initialize-partition partition)
   "Format PARTITION, a <partition> object with a non-#f 'device' field, mount
 it, run its initializer, and unmount it."
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index dfe198e43..3a5e76034 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -268,6 +268,7 @@ loaded at boot time in the order in which they appear."
       "usbhid" "hid-generic" "hid-apple"      ;keyboards during early boot
       "dm-crypt" "xts" "serpent_generic" "wp512" ;for encrypted root partitions
       "nvme"                                     ;for new SSD NVMe devices
+      "nls_iso8859-1"                            ;for `mkfs.fat`, et.al
       ,@(if (string-match "^(x86_64|i[3-6]86)-" (%current-system))
             '("pata_acpi" "pata_atiixp"    ;for ATA controllers
               "isci")                      ;for SAS controllers like Intel C602
@@ -281,9 +282,6 @@ loaded at boot time in the order in which they appear."
       ,@(if (find (file-system-type-predicate "9p") file-systems)
             virtio-9p-modules
             '())
-      ,@(if (find (file-system-type-predicate "vfat") file-systems)
-            '("nls_iso8859-1")
-            '())
       ,@(if (find (file-system-type-predicate "btrfs") file-systems)
             '("btrfs")
             '())
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 42c7690b1..099e3fac3 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -202,7 +202,7 @@ the image."
                       (guix build utils))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs)
+                '#$(append (list qemu parted e2fsprogs dosfstools)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
-- 
2.12.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2017-05-07 19:16 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 14:35 bug#26815: [PATCH 0/3] Hybrid UEFI disk image Marius Bakke
2017-05-07 14:36 ` bug#26815: [PATCH 1/3] vm: Add support for arbitrary partition flags Marius Bakke
2017-05-07 14:36   ` bug#26815: [PATCH 2/3] vm: Support creating FAT partitions Marius Bakke
2017-05-07 15:26     ` Danny Milosavljevic
2017-05-07 15:52       ` Marius Bakke
2017-05-07 16:32         ` bug#26815: [PATCH v2 " Marius Bakke
2017-05-07 17:06         ` bug#26815: [PATCH " Danny Milosavljevic
2017-05-07 19:15           ` Marius Bakke [this message]
2017-05-07 20:07             ` Danny Milosavljevic
2017-05-08 14:45               ` Ludovic Courtès
2017-05-08 15:59     ` Maxim Cournoyer
2017-05-07 14:36   ` bug#26815: [PATCH 3/3] vm: Support EFI boot in base image Marius Bakke
2017-05-07 15:18     ` Danny Milosavljevic
2017-05-07 15:41       ` Marius Bakke
2017-05-07 19:17       ` Marius Bakke
2017-05-08  9:06         ` Marius Bakke
2017-05-08 14:50           ` Ludovic Courtès
2017-05-10 19:52             ` bug#26815: [PATCH 1/3] vm: Support arbitrary partition flags Marius Bakke
2017-05-10 19:52               ` bug#26815: [PATCH 2/3] vm: Support creating FAT partitions Marius Bakke
2017-05-10 19:52               ` bug#26815: [PATCH 3/3] vm: Add UEFI loader to disk images Marius Bakke
2017-05-10 21:05                 ` Ludovic Courtès
2017-05-10 21:21                   ` Marius Bakke
2017-05-10 19:58             ` bug#26815: [PATCH 3/3] vm: Support EFI boot in base image Marius Bakke
2017-05-12 22:06               ` Ludovic Courtès
2017-05-12 23:12                 ` Marius Bakke
2017-05-13  9:17                   ` Mathieu Othacehe
2017-05-13 13:11                     ` Ludovic Courtès
2017-05-13 14:13                       ` Marius Bakke
2017-05-13 19:23                         ` Ludovic Courtès
2017-05-16 15:17                         ` Ludovic Courtès
2017-05-17 11:05                           ` Marius Bakke
2017-05-17 12:36                             ` Marius Bakke
2017-05-17 13:42                               ` Ricardo Wurmus
2017-05-17 19:47                               ` Ludovic Courtès
2017-05-17 11:05                           ` bug#26815: [PATCH v4 1/3] vm: Support arbitrary partition flags Marius Bakke
2017-05-17 11:05                             ` bug#26815: [PATCH v4 2/3] vm: Support creating FAT partitions Marius Bakke
2017-05-17 11:05                             ` bug#26815: [PATCH v4 3/3] vm: Add UEFI loader to disk images Marius Bakke
2017-05-17 21:28                               ` Ludovic Courtès
2017-05-18 16:21                                 ` Marius Bakke
2017-05-18 17:34                                   ` Marius Bakke
2017-05-18 20:59                                     ` Ludovic Courtès
2017-05-19 16:15                                       ` Marius Bakke
2017-05-19 17:37                                         ` Mathieu Othacehe
2017-05-19 18:06                                           ` Marius Bakke
2017-05-20  8:25                                             ` Ludovic Courtès
2017-05-20  8:55                                               ` Mathieu Othacehe
2017-05-20  9:23                                               ` Marius Bakke
2017-05-20  9:36                                                 ` Ludovic Courtès
2017-05-20  9:36                                             ` Mathieu Othacehe
2017-05-20 10:05                                               ` Marius Bakke
2017-05-19 21:21                                         ` Ludovic Courtès
2017-05-18 20:50                                   ` Ludovic Courtès
2017-05-18 22:52                                     ` Marius Bakke
2017-05-19  7:00                                       ` Ludovic Courtès
2017-05-17 21:21                             ` bug#26815: [PATCH v4 1/3] vm: Support arbitrary partition flags Ludovic Courtès
2017-05-07 15:28   ` bug#26815: [PATCH 1/3] vm: Add support for " Danny Milosavljevic
2017-05-08 14:43   ` Ludovic Courtès
2017-05-08 15:55   ` Maxim Cournoyer
2017-05-08 21:41   ` Danny Milosavljevic
2017-05-07 15:02 ` bug#26815: [PATCH 0/3] Hybrid UEFI disk image Marius Bakke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tw4wxyun.fsf@fastmail.com \
    --to=mbakke@fastmail.com \
    --cc=26815@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.