unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Alex Kost <alezost@gmail.com>
Cc: 25573@debbugs.gnu.org
Subject: bug#25573: Adding btrfs support may break reconfigured system
Date: Mon, 30 Jan 2017 10:41:49 +0100	[thread overview]
Message-ID: <87sho0evfm.fsf@gnu.org> (raw)
In-Reply-To: <87wpddzqsz.fsf@gmail.com> (Alex Kost's message of "Sun, 29 Jan 2017 21:03:56 +0300")

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

Hi,

Alex Kost <alezost@gmail.com> skribis:

> Hello, recently I found that "guix system" makes a "broken" system for
> me.  When I boot a freshly created system, I get something like this:
>
>   In procedure <...> at ./gnu/build/file-systems.scm:282:4 (device)
>   In procedure fport_seek: Invalid argument
>
> and I'm thrown at the Guile promt.

I think this is due to ‘read-superblock’ trying to seek beyond the end
of one of the devices that’s on your machine.

Could you try the attached patch and see if it solves the problem?

Thanks for reporting it!

Ludo’.


[-- Attachment #2: Type: text/x-patch, Size: 1988 bytes --]

diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 6e5c6aaf1..f8ab95370 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -72,14 +72,25 @@
   "Bind-mount SOURCE at TARGET."
   (mount source target "" MS_BIND))
 
+(define (seek* fd/port offset whence)
+  "Like 'seek' but return -1 instead of throwing to 'system-error' upon
+EINVAL.  This makes it easier to catch cases like OFFSET being too large for
+FD/PORT."
+  (catch 'system-error
+    (lambda ()
+      (seek fd/port offset whence))
+    (lambda args
+      (if (= EINVAL (system-error-errno args))
+          -1
+          (apply throw args)))))
+
 (define (read-superblock device offset size magic?)
   "Read a superblock of SIZE from OFFSET and DEVICE.  Return the raw
 superblock on success, and #f if no valid superblock was found.  MAGIC?
 takes a bytevector and returns #t when it's a valid superblock."
   (call-with-input-file device
     (lambda (port)
-      (seek port offset SEEK_SET)
-
+      (and (= offset (seek* port offset SEEK_SET))
            (let ((block (make-bytevector size)))
              (match (get-bytevector-n! port block 0 (bytevector-length block))
                ((? eof-object?)
@@ -87,7 +98,7 @@ takes a bytevector and returns #t when it's a valid superblock."
                ((? number? len)
                 (and (= len (bytevector-length block))
                      (and (magic? block)
-                     block))))))))
+                          block)))))))))
 
 (define (sub-bytevector bv start size)
   "Return a copy of the SIZE bytes of BV starting from offset START."

  reply	other threads:[~2017-01-30  9:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-29 18:03 bug#25573: Adding btrfs support may break reconfigured system Alex Kost
2017-01-30  9:41 ` Ludovic Courtès [this message]
2017-01-31 17:29   ` Alex Kost
2017-01-31 22:23     ` 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

  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=87sho0evfm.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=25573@debbugs.gnu.org \
    --cc=alezost@gmail.com \
    /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).