all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 28696@debbugs.gnu.org
Subject: [bug#28696] [PATCH 3/5] file-systems: Add support for FAT16.
Date: Wed,  4 Oct 2017 09:25:52 +0200	[thread overview]
Message-ID: <20171004072554.1377-3-ludo@gnu.org> (raw)
In-Reply-To: <20171004072554.1377-1-ludo@gnu.org>

* gnu/build/file-systems.scm (check-fat32-file-system): Rename to...
(check-fat-file-system): ... this.
(check-file-system): Adjust accordingly.
(fat16-superblock?, read-fat16-superblock)
(fat16-superblock-uuid, fat16-superblock-volume-name): New procedures.
(%partition-label-readers, %partition-uuid-readers): Add FAT16.
---
 gnu/build/file-systems.scm | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index dea5bc619..5d6c335bb 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -194,7 +194,7 @@ if DEVICE does not contain a btrfs file system."
 Trailing spaces are trimmed."
   (string-trim-right (latin1->string (sub-bytevector sblock 71 11) (lambda (c) #f)) #\space))
 
-(define (check-fat32-file-system device)
+(define (check-fat-file-system device)
   "Return the health of a fat file system on DEVICE."
   (match (status:exit-val
           (system* "fsck.vfat" "-v" "-a" device))
@@ -203,6 +203,33 @@ Trailing spaces are trimmed."
     (_ 'fatal-error)))
 
 \f
+;;;
+;;; FAT16 file systems.
+;;;
+
+(define (fat16-superblock? sblock)
+  "Return #t when SBLOCK is a fat16 boot record."
+  (bytevector=? (sub-bytevector sblock 54 8)
+                (string->utf8 "FAT16   ")))
+
+(define (read-fat16-superblock device)
+  "Return the raw contents of DEVICE's fat16 superblock as a bytevector, or
+#f if DEVICE does not contain a fat16 file system."
+  (read-superblock device 0 62 fat16-superblock?))
+
+(define (fat16-superblock-uuid sblock)
+  "Return the Volume ID of a fat superblock SBLOCK as a 4-byte bytevector."
+  (sub-bytevector sblock 39 4))
+
+(define (fat16-superblock-volume-name sblock)
+  "Return the volume name of SBLOCK as a string of at most 11 characters, or
+#f if SBLOCK has no volume name.  The volume name is a latin1 string.
+Trailing spaces are trimmed."
+  (string-trim-right (latin1->string (sub-bytevector sblock 43 11)
+                                     (lambda (c) #f))
+                     #\space))
+
+\f
 ;;;
 ;;; ISO9660 file systems.
 ;;;
@@ -386,7 +413,9 @@ partition field reader that returned a value."
         (partition-field-reader read-btrfs-superblock
                                 btrfs-superblock-volume-name)
         (partition-field-reader read-fat32-superblock
-                                fat32-superblock-volume-name)))
+                                fat32-superblock-volume-name)
+        (partition-field-reader read-fat16-superblock
+                                fat16-superblock-volume-name)))
 
 (define %partition-uuid-readers
   (list (partition-field-reader read-iso9660-superblock
@@ -396,7 +425,9 @@ partition field reader that returned a value."
         (partition-field-reader read-btrfs-superblock
                                 btrfs-superblock-uuid)
         (partition-field-reader read-fat32-superblock
-                                fat32-superblock-uuid)))
+                                fat32-superblock-uuid)
+        (partition-field-reader read-fat16-superblock
+                                fat16-superblock-uuid)))
 
 (define read-partition-label
   (cut read-partition-field <> %partition-label-readers))
@@ -511,7 +542,7 @@ the following:
     (cond
      ((string-prefix? "ext" type) check-ext2-file-system)
      ((string-prefix? "btrfs" type) check-btrfs-file-system)
-     ((string-suffix? "fat" type) check-fat32-file-system)
+     ((string-suffix? "fat" type) check-fat-file-system)
      (else #f)))
 
   (if check-procedure
-- 
2.14.2

  parent reply	other threads:[~2017-10-04  7:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04  7:24 [bug#28696] [PATCH 0/5] Support UUIDs for the EFI System Partition (FAT) Ludovic Courtès
2017-10-04  7:25 ` [bug#28696] [PATCH 1/5] file-systems: 'mount-file-system' now takes a <file-system> object Ludovic Courtès
2017-10-04  7:25   ` [bug#28696] [PATCH 2/5] file-systems: Preserve UUID types when serializing Ludovic Courtès
2017-10-04  7:25   ` Ludovic Courtès [this message]
2017-10-04  7:25   ` [bug#28696] [PATCH 4/5] uuid: Change "fat32" to "fat" Ludovic Courtès
2017-10-04  7:25   ` [bug#28696] [PATCH 5/5] doc: Give an example with a FAT UUID Ludovic Courtès
2017-10-09 20:54 ` [bug#28696] [PATCH 0/5] Support UUIDs for the EFI System Partition (FAT) Roel Janssen
2017-10-11 19:49   ` Ludovic Courtès
2017-10-11  9:13 ` bug#28696: " Ludovic Courtès

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=20171004072554.1377-3-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=28696@debbugs.gnu.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.