From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id +EDSDRlQlmSALQAASxT56A (envelope-from ) for ; Sat, 24 Jun 2023 04:08:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mKpGDRlQlmS0YAEAG6o9tA (envelope-from ) for ; Sat, 24 Jun 2023 04:08:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C3B5C47939 for ; Sat, 24 Jun 2023 04:08:24 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCsh2-0004QI-AU; Fri, 23 Jun 2023 22:08:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCsh0-0004Pf-M6 for guix-patches@gnu.org; Fri, 23 Jun 2023 22:08:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCsh0-0006S6-CG for guix-patches@gnu.org; Fri, 23 Jun 2023 22:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCsh0-0002mV-6O for guix-patches@gnu.org; Fri, 23 Jun 2023 22:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64259] [PATCH 1/2] Offer an mdadm variant of uuids. Resent-From: Felix Lechner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 24 Jun 2023 02:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64259 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64259@debbugs.gnu.org Cc: Felix Lechner Received: via spool by 64259-submit@debbugs.gnu.org id=B64259.168757245010641 (code B ref 64259); Sat, 24 Jun 2023 02:08:02 +0000 Received: (at 64259) by debbugs.gnu.org; 24 Jun 2023 02:07:30 +0000 Received: from localhost ([127.0.0.1]:39727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCsgT-0002lZ-I2 for submit@debbugs.gnu.org; Fri, 23 Jun 2023 22:07:29 -0400 Received: from sail-ipv4.us-core.com ([208.82.101.137]:40014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCsgQ-0002lK-OH for 64259@debbugs.gnu.org; Fri, 23 Jun 2023 22:07:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=uy5rDqWgjexWPdw FzoVajMo/6sMUCCcljDA7Yy0bwf8=; h=references:in-reply-to:date:subject: cc:to:from; d=lease-up.com; b=rHvNoO8XIRgIuFNe4k7edm4NhN2iuIh/Kpg47dUi Osxb+E4L46Rx7K2NnSzpI/CHmaENIQJWXfwGwrnDbBs6/eJTjIImmTtdBgJM4APef0+0Fj 71bs9sqfhDjz+UkRtRgVSjZIBCPm5tR00UIQER+f9dKteRlnUSHRkAWBy9sP8= Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id ae1dea98 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Sat, 24 Jun 2023 02:07:25 +0000 (UTC) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 48153a98; Sat, 24 Jun 2023 02:07:24 +0000 (UTC) Date: Fri, 23 Jun 2023 19:07:22 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Felix Lechner X-ACL-Warn: , Felix Lechner via Guix-patches From: Felix Lechner via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1687572505; a=rsa-sha256; cv=none; b=LvrYeFyc+y73xQgcnRdnQjVa7JuX8+E4+k8Qj7nDaDnhlAGQ88ubk/1M+avVfgvTAplnR2 uFW1ei+/w9KQM4AMpgxOQhlgOR1tVilJrpMXTttWQbA5v6Z2KIbpU8/yWB7gEjgVV6ZK+e PZ+Bs+Oj/AngB5hIkVUfo8nICbXBMFFRa9i7I95FmRZeHLVplvA6fNrruVYZz8CW6BDVJ8 SlFv1k5Dey2o/RQwg9BmKfyTT8TQxoSf7Zhfz3la2veFtFis1uEOzd8ehlLqEefJE55Q1z fmP2+AxixlqLvUAVnBwbifhAPT61D7530RBjMR8apzDKe1yAPjidQzd0d5fYoQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lease-up.com header.s=2017 header.b=rHvNoO8X; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1687572505; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=x8BZUJPW5eZ4Tqdblv5gVNDl3C3Js6hsBDztLF2x42w=; b=eM22TMcDK7I1d9wtiwFbELPm2d/4cBOtUM4YqyyrUFWW/LeiFuEbLkFBPVMM7By+T1Ln6l 2bXjGzqG1bYPJ2fcoD47AVSieLqlYODBXNDi6/yqpOpkjG4sPrx94+jBUj/RCkFYS3DvBR 7nm2udYVqLrFu6dp1BXYx6m2uBOuB2VzqxtuQZQ5mypv0nlCDfN0gNFuahCIJoh97hqv+9 T/vxawpapCFlcZwrlEZUsqXgycp63Dh/VH8wb06vCLk1WBHx6Vbtid4lnmnD79krZJbIMd NRExt19NsyBfVtGh28rdMYtARl48vLRDGB7Iucf9S+kYHAer/2GJFxBpvi/fUQ== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lease-up.com header.s=2017 header.b=rHvNoO8X; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -4.05 X-Spam-Score: -4.05 X-Migadu-Queue-Id: C3B5C47939 X-TUID: mLVn+Kb4Io71 The main executable to set up and manage Linux MD arrays, mdadm, uses a UUID format that is different from other standards. The variant is here provided for the benefit of Guix users. * gnu/system/uuid.scm: Offer an mdadm variant of uuids. --- gnu/system/uuid.scm | 46 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm index 8f967387ad..dc8bb3f7b7 100644 --- a/gnu/system/uuid.scm +++ b/gnu/system/uuid.scm @@ -82,8 +82,9 @@ (define-syntax %network-byte-order (identifier-syntax (endianness big))) (define (dce-uuid->string uuid) - "Convert UUID, a 16-byte bytevector, to its string representation, something -like \"6b700d61-5550-48a1-874c-a3d86998990e\"." + "Convert UUID, a 16-byte bytevector, to its DCE string representation (see +), which looks something like +\"6b700d61-5550-48a1-874c-a3d86998990e\"." ;; See . (let ((time-low (bytevector-uint-ref uuid 0 %network-byte-order 4)) (time-mid (bytevector-uint-ref uuid 4 %network-byte-order 2)) @@ -93,7 +94,7 @@ (define (dce-uuid->string uuid) (format #f "~8,'0x-~4,'0x-~4,'0x-~4,'0x-~12,'0x" time-low time-mid time-hi clock-seq node))) -(define %uuid-rx +(define %dce-uuid-rx ;; The regexp of a UUID. (make-regexp "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$")) @@ -101,7 +102,7 @@ (define (string->dce-uuid str) "Parse STR as a DCE UUID (see ) and return its contents as a 16-byte bytevector. Return #f if STR is not a valid UUID representation." - (and=> (regexp-exec %uuid-rx str) + (and=> (regexp-exec %dce-uuid-rx str) (lambda (match) (letrec-syntax ((hex->number (syntax-rules () @@ -167,6 +168,41 @@ (define (digits->string bytes) (parts (list year month day hour minute second hundredths))) (string-append (string-join (map digits->string parts) "-")))) + +;;; +;;; Mdadm. +;;; + +(define (mdadm-uuid->string uuid) + "Convert UUID, a 16-byte bytevector, to its Mdadm string representation, +which looks something like \"6b700d61:555048a1:874ca3d8:6998990e\"." + ;; See . + (format #f "~8,'0x:~8,'0x:~8,'0x:~8,'0x" + (bytevector-uint-ref uuid 0 %network-byte-order 4) + (bytevector-uint-ref uuid 4 %network-byte-order 4) + (bytevector-uint-ref uuid 8 %network-byte-order 4) + (bytevector-uint-ref uuid 12 %network-byte-order 4))) + +(define %mdadm-uuid-rx + (make-regexp "^([[:xdigit:]]{8}):([[:xdigit:]]{8}):([[:xdigit:]]{8}):([[:xdigit:]]{8})$")) + +(define (string->mdadm-uuid str) + "Parse STR, which is in Mdadm format, and return a bytevector or #f." + (match (regexp-exec %mdadm-uuid-rx str) + (#f + #f) + (rx-match + (uint-list->bytevector (list (string->number + (match:substring rx-match 1) 16) + (string->number + (match:substring rx-match 2) 16) + (string->number + (match:substring rx-match 3) 16) + (string->number + (match:substring rx-match 4) 16)) + %network-byte-order + 4)))) + ;;; ;;; FAT32/FAT16. @@ -259,6 +295,7 @@ (define %uuid-parsers ('dce 'ext2 'ext3 'ext4 'bcachefs 'btrfs 'f2fs 'jfs 'xfs 'luks => string->dce-uuid) ('fat32 'fat16 'fat => string->fat-uuid) + ('mdadm => string->mdadm-uuid) ('ntfs => string->ntfs-uuid) ('iso9660 => string->iso9660-uuid))) @@ -268,6 +305,7 @@ (define %uuid-printers => dce-uuid->string) ('iso9660 => iso9660-uuid->string) ('fat32 'fat16 'fat => fat-uuid->string) + ('mdadm => mdadm-uuid->string) ('ntfs => ntfs-uuid->string))) (define* (string->uuid str #:optional (type 'dce)) -- 2.40.1