From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id OIYHEvRoX2V75gAAauVa8A:P1 (envelope-from ) for ; Thu, 23 Nov 2023 16:00:04 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id OIYHEvRoX2V75gAAauVa8A (envelope-from ) for ; Thu, 23 Nov 2023 16:00:04 +0100 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 A3C955DF05 for ; Thu, 23 Nov 2023 16:00:03 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lease-up.com header.s=2017 header.b=lbrpZWlW; 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-Seal: i=1; s=key1; d=yhetil.org; t=1700751604; a=rsa-sha256; cv=none; b=omAYd0hvh33mZZ+wAsZe2dQdT40jDA8W77GFRyYRaHABS/QmM/6572dekAEXNoAPBkJPhy 4j6WAbFRFVAsNH+Y6B1kWrjspe78nTXhVpy+2O4eyuibLK6iWjJKbZxpqZCn01kP+r0xjt EMnZUsa+EO7RqPUqXZd5+vbGUkOXOUZCrvapFpmk+VXFfhL8XUTZzV9r+WCi45/KmWymdP uFaPuVxRt3l7DAfQqgw82QdseiL3R8SfWyoRpFLlKQeqedi7Rx8SjG0SOT766bIIpPnj9Z AMzbzBs2J4r7xOFeIpuPXi2ZPzhirNf+54BZJAIgJIou/0XqRdf0iYoCM50Ceg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lease-up.com header.s=2017 header.b=lbrpZWlW; 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=1700751604; 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=q8U4xagcEBxnvfLIkHeN9av7BFTl+np8rm8hoIf6/dA=; b=V47sjoa2/PnNw7FaO/DPtRvvFEOiUjGITnvKdh2yWvafuQfsvMFu3hi3m7g0ELQPwrwZL6 k56hNTOS/f4bX6EaB71+jMiT8b1M9N3OfIxycJk8A6kV8d+fkKlfwDyoD4Xc+RBqNLHOYT eBbmVL9bTf51amICE5Ekh8VZOpwmEmraDwl3B2QOa4Vps3Kg0sEQeRuMHqT+7wVUl17IuO wNsW9TuVMW+Osl0ovLl9FevVKWyNiflzYGA8KOAf3vfQQcazCXK5WZI+Uj4CSLlGz4Vufd 6mKCsgxQbS+NapWgULCAVPBLKHhQA25dhpxIhw94ZUBCBlBbX9aY2VDIgpWMnQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6BBQ-0007yZ-0j; Thu, 23 Nov 2023 10:00:00 -0500 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 1r6BBO-0007xr-M8 for guix-patches@gnu.org; Thu, 23 Nov 2023 09:59:58 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6BBO-0003k9-De for guix-patches@gnu.org; Thu, 23 Nov 2023 09:59:58 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6BBS-0007iV-7a for guix-patches@gnu.org; Thu, 23 Nov 2023 10:00:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#64259] [PATCH v2 1/2] Offer an mdadm variant of uuids. References: In-Reply-To: Resent-From: Felix Lechner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 23 Nov 2023 15:00: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: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Felix Lechner Received: via spool by 64259-submit@debbugs.gnu.org id=B64259.170075155129559 (code B ref 64259); Thu, 23 Nov 2023 15:00:02 +0000 Received: (at 64259) by debbugs.gnu.org; 23 Nov 2023 14:59:11 +0000 Received: from localhost ([127.0.0.1]:34583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6BAd-0007gh-1T for submit@debbugs.gnu.org; Thu, 23 Nov 2023 09:59:11 -0500 Received: from sail-ipv4.us-core.com ([208.82.101.137]:34494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6BAa-0007gY-4G for 64259@debbugs.gnu.org; Thu, 23 Nov 2023 09:59:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=eAdH9YAxLlQDx43 nOb2mHRSAJ6iwa27eVqrldvINybo=; h=date:subject:cc:to:from; d=lease-up.com; b=lbrpZWlWWTk3Sp3GrLyOYpBuStDXrEEKmp/HAEL8B7ebT7pZmPY8 JScvGnhPZn/dr6DIV7wrgyr3Xm/s8L1lYYPXttATv9rIasm3i7kn22X0LA1uT6sVEnLPrL jgDt+a4x1tJsoxQXTezsbng4WJJxTbt6XQ8wsm0jfDkM7gnPw= Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id a8ea84f7 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Thu, 23 Nov 2023 14:59:02 +0000 (UTC) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 16c8b611; Thu, 23 Nov 2023 14:59:02 +0000 (UTC) Date: Thu, 23 Nov 2023 06:56:59 -0800 Message-ID: <9b4c88707c00531fa2a43e5172d1fc0c4f4af3d9.1700751420.git.felix.lechner@lease-up.com> X-Mailer: git-send-email 2.41.0 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: A3C955DF05 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -6.12 X-Spam-Score: -6.12 X-TUID: DmJyKiiQlfHy --- 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)) base-commit: 5283d24062be62f59ff9f14fa7095ebcfcb7a9a4 -- 2.41.0