From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Craven Subject: [PATCH 2/2] system: Add btrfs file system support. Date: Wed, 30 Nov 2016 19:36:35 +0100 Message-ID: <20161130183635.6513-2-david@craven.ch> References: <20161130183635.6513-1-david@craven.ch> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC9kX-0003b1-2d for guix-devel@gnu.org; Wed, 30 Nov 2016 13:36:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC9kS-00077C-92 for guix-devel@gnu.org; Wed, 30 Nov 2016 13:36:57 -0500 Received: from so254-10.mailgun.net ([198.61.254.10]:49463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cC9kS-00076V-41 for guix-devel@gnu.org; Wed, 30 Nov 2016 13:36:52 -0500 In-Reply-To: <20161130183635.6513-1-david@craven.ch> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/system/linux-initrd.scm (linux-modules, helper-packages): Add btrfs modules when a btrfs file-system is used. * gnu/build/file-systems.scm (check-file-system-irrecoverable-error, check-file-system-ext): New variables. (check-file-system): Support non ext file systems gracefully. --- gnu/build/file-systems.scm | 30 ++++++++++++++++++++---------- gnu/system/linux-initrd.scm | 10 +++++++--- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 431b287..9f57ee5 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -410,12 +410,15 @@ the following: (else (error "unknown device title" title)))) -(define (check-file-system device type) - "Run a file system check of TYPE on DEVICE." - (define fsck - (string-append "fsck." type)) - - (let ((status (system* fsck "-v" "-p" "-C" "0" device))) +(define (check-file-system-irrecoverable-error prog code device) + (format (current-error-port) + "'~a' exited with code ~a on ~a; spawning Bourne-like REPL~%" + prog code device) + (start-repl %bournish-language)) + +(define (check-file-system-ext device type) + (let* ((fsck (string-append "fsck." type)) + (status (system* fsck "-v" "-p" "-C" "0" device))) (match (status:exit-val status) (0 #t) @@ -428,10 +431,17 @@ the following: (sleep 3) (reboot)) (code - (format (current-error-port) "'~a' exited with code ~a on ~a; \ -spawning Bourne-like REPL~%" - fsck code device) - (start-repl %bournish-language))))) + (check-file-system-irrecoverable-error fsck code device))))) + +(define (check-file-system device type) + "Run a file system check of TYPE on DEVICE." + (cond + ((string-prefix? "ext" type) + (check-file-system-ext device type)) + ((string-prefix? "btrfs" type) + (zero? (system* "btrfs" "device" "scan"))) + (#t (format (current-error-port) + "Don't know how to check '~a' file systems; skipping~%" type)))) (define (mount-flags->bit-mask flags) "Return the number suitable for the 'flags' argument of 'mount' that diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 174239a..de8b785 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -193,6 +193,9 @@ 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 "btrfs") file-systems) + '("btrfs") + '()) ,@(if volatile-root? '("fuse") '()) @@ -200,11 +203,12 @@ loaded at boot time in the order in which they appear." (define helper-packages ;; Packages to be copied on the initrd. - `(,@(if (find (lambda (fs) - (string-prefix? "ext" (file-system-type fs))) - file-systems) + `(,@(if (find (file-system-type-predicate "ext4") file-systems) (list e2fsck/static) '()) + ,@(if (find (file-system-type-predicate "btrfs") file-systems) + (list btrfs-progs/static) + '()) ,@(if volatile-root? (list unionfs-fuse/static) '()))) -- 2.9.0