unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: Chris Marusich <cmmarusich@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: GuixSD bootable ISO-9669 image (was: Re: GuixSD on servers [Fwd: [rtracker.1984.is #131647] A question about VServer system specific requirements])
Date: Fri, 28 Apr 2017 10:18:44 +0200	[thread overview]
Message-ID: <20170428101844.540ce399@scratchpost.org> (raw)
In-Reply-To: <20170427220009.1d0d4607@scratchpost.org>

Small fix below

On Thu, 27 Apr 2017 22:00:09 +0200
Danny Milosavljevic <dannym@scratchpost.org> wrote:

> Something like this (totally untested):
> 
> diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
> index 0cb84b8aa..be512d59c 100644
> --- a/gnu/build/file-systems.scm
> +++ b/gnu/build/file-systems.scm
> @@ -230,6 +230,55 @@ Trailing spaces are trimmed."
>  
>  ^L
>  ;;;
> +;;; ISO9660 file systems.
> +;;;
> +
> +;; <http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf>.
> +
> +;(define-syntax %iso9660-endianness
> +;  ;; Endianness of iso9660 file systems that we use.
> +;  ;; Actually, iso9660 has redundant data (i.e. data for both endiannesses).
> +;  (identifier-syntax (endianness little)))
> +
> +(define (iso9660-superblock? sblock)
> +  "Return #t when SBLOCK is a iso9660 superblock."
> +  (bytevector=? (sub-bytevector sblock 1 6)
> +                ;; Note: "\x01" is the volume descriptor format version
> +                (string->utf8 "CD001\x01")))
> +
> +(define (read-iso9660-primary-volume-descriptor device offset)
> +  "Find and read the first primary volume descriptor, starting at OFFSET.
> +   Return #f if not found."
> +  (let* ((sblock (read-superblock device offset 2048 iso9660-superblock?))
> +         (type-code (array-ref sblock 0))) ; FIXME if sblock

+         (type-code (if sblock (array-ref sblock 0) 255)))

> +    (match type-code
> +      (255 #f) ; Volume Descriptor Set Terminator.
> +      (1 sblock) ; Primary Volume Descriptor
> +      (_ (read-iso9660-primary-volume-descriptor device (+ offset 2048))))))
> +
> +(define (read-iso9660-superblock device)
> +  "Return the raw contents of DEVICE's iso9660 superblock as a bytevector, or
> +#f if DEVICE does not contain a iso9660 file system."
> +  ;; Start reading at sector 16.
> +  (read-iso9660-primary-volume-descriptor device (* 2048 16)))
> +
> +(define (iso9660-superblock-uuid sblock)
> +  "Return the Volume ID of a iso9660 superblock SBLOCK as a 4-byte bytevector."
> +  ;; Note: The field is the volume creation time.
> +  ;; FIXME Use only certain parts (See grub).
> +  ;; FIXME treat "all 0" as invalid.
> +  (sub-bytevector sblock 813 17))
> +
> +;; FIXME make result human-readable (See grub).
> +;(define (iso9660-uuid->string uuid)
> +
> +(define (iso9660-superblock-volume-name sblock)
> +  "Return the volume name of SBLOCK as a string.  The volume name is an ASCII
> +string.  Trailing spaces are trimmed."
> +  (string-trim-right (latin1->string (sub-bytevector sblock 40 32) (lambda (c) #f)) #\space))
> +
> +^L
> +;;;
>  ;;; LUKS encrypted devices.
>  ;;;
>  
> @@ -340,7 +389,9 @@ partition field reader that returned a value."
>      (_ #f)))
>  
>  (define %partition-label-readers
> -  (list (partition-field-reader read-ext2-superblock
> +  (list (partition-field-reader read-iso9660-superblock
> +                                iso9660-superblock-volume-name)
> +        (partition-field-reader read-ext2-superblock
>                                  ext2-superblock-volume-name)
>          (partition-field-reader read-btrfs-superblock
>                                  btrfs-superblock-volume-name)
> @@ -348,7 +399,9 @@ partition field reader that returned a value."
>                                  fat32-superblock-volume-name)))
>  
>  (define %partition-uuid-readers
> -  (list (partition-field-reader read-ext2-superblock
> +  (list (partition-field-reader read-iso9660-superblock
> +                                iso9660-superblock-uuid)
> +        (partition-field-reader read-ext2-superblock
>                                  ext2-superblock-uuid)
>          (partition-field-reader read-btrfs-superblock
>                                  btrfs-superblock-uuid)

  reply	other threads:[~2017-04-28  8:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 14:17 GuixSD on servers [Fwd: [rtracker.1984.is #131647] A question about VServer system specific requirements] ng0
2017-04-18 15:16 ` Chris Marusich
2017-04-19 20:59   ` Ludovic Courtès
2017-04-23  4:52     ` Chris Marusich
2017-04-24  5:11       ` GuixSD bootable ISO-9669 image (was: Re: GuixSD on servers [Fwd: [rtracker.1984.is #131647] A question about VServer system specific requirements]) Chris Marusich
2017-04-27 13:42         ` GuixSD bootable ISO-9669 image Ludovic Courtès
2017-04-27 17:08         ` GuixSD bootable ISO-9669 image (was: Re: GuixSD on servers [Fwd: [rtracker.1984.is #131647] A question about VServer system specific requirements]) Danny Milosavljevic
2017-04-27 20:00           ` Danny Milosavljevic
2017-04-28  8:18             ` Danny Milosavljevic [this message]
2017-05-02 12:37               ` GuixSD bootable ISO-9669 image Ludovic Courtès
2017-05-02 12:53                 ` ng0
2017-05-03  6:26                   ` Mark H Weaver
2017-05-02 20:09                 ` Danny Milosavljevic
2017-05-02 21:11                   ` Ludovic Courtès
2017-05-07 19:37                     ` Danny Milosavljevic
2017-05-08 14:14                       ` Ludovic Courtès
2017-05-11 23:30                         ` Danny Milosavljevic
2017-05-12 15:33                           ` Ludovic Courtès
2017-05-14 21:25                             ` Danny Milosavljevic
2017-05-16  8:31                               ` Ludovic Courtès
2017-06-06  9:35                                 ` Danny Milosavljevic
2017-06-08 12:25                                   ` Ludovic Courtès
2017-05-02 20:12                 ` Danny Milosavljevic

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20170428101844.540ce399@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=cmmarusich@gmail.com \
    --cc=guix-devel@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).