From patchwork Thu Jan 2 00:38:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "ashish.is--- via Guix-patches\" via" X-Patchwork-Id: 19515 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id AB698179D3; Thu, 2 Jan 2020 00:40:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 515BC179BD for ; Thu, 2 Jan 2020 00:40:12 +0000 (GMT) Received: from localhost ([::1]:34972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imoX5-00074A-8I for patchwork@mira.cbaines.net; Wed, 01 Jan 2020 19:40:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35033) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imoWx-00073Y-N6 for guix-patches@gnu.org; Wed, 01 Jan 2020 19:40:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imoWw-0003uU-F0 for guix-patches@gnu.org; Wed, 01 Jan 2020 19:40:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:60075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1imoWw-0003tp-BE for guix-patches@gnu.org; Wed, 01 Jan 2020 19:40:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1imoWw-0003eI-7Q for guix-patches@gnu.org; Wed, 01 Jan 2020 19:40:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38860] [PATCH 1/7] file-systems: Add support for JFS. References: <87r20ivh15.fsf@nckx> In-Reply-To: <87r20ivh15.fsf@nckx> Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 02 Jan 2020 00:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38860 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 38860@debbugs.gnu.org Received: via spool by 38860-submit@debbugs.gnu.org id=B38860.157792555513898 (code B ref 38860); Thu, 02 Jan 2020 00:40:02 +0000 Received: (at 38860) by debbugs.gnu.org; 2 Jan 2020 00:39:15 +0000 Received: from localhost ([127.0.0.1]:37793 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imoWB-0003c6-F8 for submit@debbugs.gnu.org; Wed, 01 Jan 2020 19:39:15 -0500 Received: from tobias.gr ([80.241.217.52]:39910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imoW9-0003bs-KI for 38860@debbugs.gnu.org; Wed, 01 Jan 2020 19:39:14 -0500 Received: by tobias.gr (OpenSMTPD) with ESMTP id 5ab6b4ab for <38860@debbugs.gnu.org>; Thu, 2 Jan 2020 00:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tobias.gr; h=from:to :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=2018; i=me@tobias.gr; bh=PduQN1d9v EYyvyn2cV0i38AjZUbnPL3GNOYsD04kQVk=; b=WIQVmaBVOGz2Sn7Uw2GcIM00p npaZ0pOtxHrYai+467kdCrtdUQiCZkqf5wWwk7cFuo5JrnMytV/kknXFbIaQilo7 Giw+7H2Af4EBd9MC+OMwgInHGkjiodS+r7gBRTiiUOJTjtxMq0y1r7MVIiYyRGwf iIpJhd5QYyxLEDt1tsPrTyZmoySJaH7QhyaB3O1GqoF2w/xkesXAOOhd3pZm4qQj b0JTmD0hR2eQ+m5c+Z/9Xp47FJ4aXAxCQevDVfI1t4enxLKVBPTqMTVH+b4bZ1Nd PNtblco5w6dgdMbPcTZTxMQ3lbbqmGjiwRzEFZl30Nrnvm5NwAmWkMfB/VuYA== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 02b171db (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for <38860@debbugs.gnu.org>; Thu, 2 Jan 2020 00:39:11 +0000 (UTC) Date: Thu, 2 Jan 2020 01:38:56 +0100 Message-Id: <20200102003902.15205-1-me@tobias.gr> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice , Tobias Geerinckx-Rice via Guix-patches X-Patchwork-Original-From: Tobias Geerinckx-Rice via Guix-patches via From: "ashish.is--- via Guix-patches\" via" X-getmail-retrieved-from-mailbox: Patches * gnu/build/file-systems.scm (%jfs-endianness): New syntax. (jfs-superblock?, read-jfs-superblock, jfs-superblock-uuid) (jfs-superblock-volume-name, check-jfs-file-system): New procedures. (%partition-label-readers, %partition-uuid-readers, check-file-system): Register them. --- gnu/build/file-systems.scm | 49 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 13c44aa728..9299cc2e4c 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2016, 2017 David Craven ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2019 Guillaume Le Vaillant +;;; Copyright © 2019 Tobias Geerinckx-Rice ;;; ;;; This file is part of GNU Guix. ;;; @@ -294,6 +295,45 @@ string. Trailing spaces are trimmed." (string-trim-right (latin1->string (sub-bytevector sblock 40 32) (lambda (c) #f)) #\space)) + +;;; +;;; JFS file systems. +;;; + +;; Taken from /fs/jfs/jfs_superblock.h. + +(define-syntax %jfs-endianness + ;; Endianness of JFS file systems. + (identifier-syntax (endianness little))) + +(define (jfs-superblock? sblock) + "Return #t when SBLOCK is a JFS superblock." + (bytevector=? (sub-bytevector sblock 0 4) + (string->utf8 "JFS1"))) + +(define (read-jfs-superblock device) + "Return the raw contents of DEVICE's JFS superblock as a bytevector, or #f +if DEVICE does not contain a JFS file system." + (read-superblock device 32768 184 jfs-superblock?)) + +(define (jfs-superblock-uuid sblock) + "Return the UUID of JFS superblock SBLOCK as a 16-byte bytevector." + (sub-bytevector sblock 136 16)) + +(define (jfs-superblock-volume-name sblock) + "Return the volume name of SBLOCK as a string of at most 16 characters, or +#f if SBLOCK has no volume name." + (null-terminated-latin1->string (sub-bytevector sblock 152 16))) + +(define (check-jfs-file-system device) + "Return the health of a JFS file system on DEVICE." + (match (status:exit-val + (system* "jfs_fsck" "-p" "-v" device)) + (0 'pass) + (1 'errors-corrected) + (2 'reboot-required) + (_ 'fatal-error))) + ;;; ;;; LUKS encrypted devices. @@ -420,7 +460,9 @@ partition field reader that returned a value." (partition-field-reader read-fat32-superblock fat32-superblock-volume-name) (partition-field-reader read-fat16-superblock - fat16-superblock-volume-name))) + fat16-superblock-volume-name) + (partition-field-reader read-jfs-superblock + jfs-superblock-volume-name))) (define %partition-uuid-readers (list (partition-field-reader read-iso9660-superblock @@ -432,7 +474,9 @@ partition field reader that returned a value." (partition-field-reader read-fat32-superblock fat32-superblock-uuid) (partition-field-reader read-fat16-superblock - fat16-superblock-uuid))) + fat16-superblock-uuid) + (partition-field-reader read-jfs-superblock + jfs-superblock-uuid))) (define read-partition-label (cut read-partition-field <> %partition-label-readers)) @@ -527,6 +571,7 @@ were found." ((string-prefix? "ext" type) check-ext2-file-system) ((string-prefix? "btrfs" type) check-btrfs-file-system) ((string-suffix? "fat" type) check-fat-file-system) + ((string-prefix? "jfs" type) check-jfs-file-system) (else #f))) (if check-procedure