unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#62827] [PATCH] image: Add partition type-uuid support.
@ 2023-04-14  6:53 Aleksandr Vityazev
  2023-05-13  8:06 ` Josselin Poiret via Guix-patches via
  2023-10-14 20:04 ` bug#62827: " Mathieu Othacehe
  0 siblings, 2 replies; 3+ messages in thread
From: Aleksandr Vityazev @ 2023-04-14  6:53 UTC (permalink / raw)
  To: 62827

* gnu/image.scm (<partition>)[type-uuid]: New field,
(partition-type-uuid): new exported procedure.
* gnu/system/image.scm (partition->dos-type, partition->gpt-type):
Adapt accordingly.
* doc/guix.texi (partition Reference): Document it.
---
 doc/guix.texi        | 5 +++++
 gnu/image.scm        | 4 ++++
 gnu/system/image.scm | 9 +++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index adb1975935..7e42fcd0fc 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -43834,6 +43834,11 @@ The partition UUID as an @code{uuid} record (@pxref{File Systems}).  By
 default it is @code{#false}, which means that the partition creation
 tool will attribute a random UUID to the partition.
 
+@item @code{type-uuid} (default: @code{#false})
+The partition type UUID as an @code{uuid} record.  By default it is
+@code{#false}, which means the type UUID will be defined according to
+@code{flags} or @code{file-system}.
+
 @item @code{flags} (default: @code{'()})
 The partition flags as a list of symbols.  Possible values are
 @code{'boot} and @code{'esp}.  The @code{'boot} flags should be set if
diff --git a/gnu/image.scm b/gnu/image.scm
index 523653dd77..be8b725d37 100644
--- a/gnu/image.scm
+++ b/gnu/image.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2020, 2022 Mathieu Othacehe <othacehe@gnu.org>
+;;; Copyright © 2023 Aleksandr Vityazev <avityazew@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@ (define-module (gnu image)
             partition-file-system-options
             partition-label
             partition-uuid
+            partition-type-uuid
             partition-flags
             partition-initializer
 
@@ -126,6 +128,8 @@ (define-record-type* <partition> partition make-partition
   (label                partition-label)  ;string
   (uuid                 partition-uuid
                         (default #false))  ;<uuid>
+  (type-uuid            partition-type-uuid ;<uuid>
+                        (default #false))
   (flags                partition-flags
                         (default '())  ;list of symbols
                         (sanitize validate-partition-flags))
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index afef79185f..cca3c54b1b 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2022 Pavel Shlyak <p.shlyak@pantherx.org>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2022 Alex Griffin <a@ajgrf.com>
+;;; Copyright © 2023 Aleksandr Vityazev <avityazew@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -364,8 +365,10 @@ (define (partition->dos-type partition)
       ;; Return the MBR partition type corresponding to the given PARTITION.
       ;; See: https://en.wikipedia.org/wiki/Partition_type.
       (let ((flags (partition-flags partition))
-            (file-system (partition-file-system partition)))
+            (file-system (partition-file-system partition))
+            (type-uuid (partition-type-uuid partition)))
         (cond
+         (type-uuid (uuid->string type-uuid))
          ((member 'esp flags) "0xEF")
          ((string-prefix? "ext" file-system) "0x83")
          ((or (string=? file-system "vfat")
@@ -383,8 +386,10 @@ (define (partition->gpt-type partition)
       ;; given PARTITION.  See:
       ;; https://github.com/pengutronix/genimage/blob/master/README.rst
       (let ((flags (partition-flags partition))
-            (file-system (partition-file-system partition)))
+            (file-system (partition-file-system partition))
+            (type-uuid (partition-type-uuid partition)))
         (cond
+         (type-uuid (uuid->string type-uuid))
          ((member 'esp flags) "U")
          ((string-prefix? "ext" file-system) "L")
          ((or (string=? file-system "vfat")

base-commit: c371555a4b46a5c9288f54753b0f158f9c4b8abc
prerequisite-patch-id: 170079138c52aa59aa21a917f8d6b178c80c85d8
prerequisite-patch-id: 947e2640dcf1b47e6b1160b7525cbe7f7300e50b
-- 
2.39.2


-- 

Aleksandr Vityazev




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#62827] [PATCH] image: Add partition type-uuid support.
  2023-04-14  6:53 [bug#62827] [PATCH] image: Add partition type-uuid support Aleksandr Vityazev
@ 2023-05-13  8:06 ` Josselin Poiret via Guix-patches via
  2023-10-14 20:04 ` bug#62827: " Mathieu Othacehe
  1 sibling, 0 replies; 3+ messages in thread
From: Josselin Poiret via Guix-patches via @ 2023-05-13  8:06 UTC (permalink / raw)
  To: Aleksandr Vityazev, 62827

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

Hi Aleksandr,

Aleksandr Vityazev <avityazew@gmail.com> writes:

> @@ -364,8 +365,10 @@ (define (partition->dos-type partition)
>        ;; Return the MBR partition type corresponding to the given PARTITION.
>        ;; See: https://en.wikipedia.org/wiki/Partition_type.
>        (let ((flags (partition-flags partition))
> -            (file-system (partition-file-system partition)))
> +            (file-system (partition-file-system partition))
> +            (type-uuid (partition-type-uuid partition)))
>          (cond
> +         (type-uuid (uuid->string type-uuid))
>           ((member 'esp flags) "0xEF")
>           ((string-prefix? "ext" file-system) "0x83")
>           ((or (string=? file-system "vfat")

MBR partitions use a single byte to represent the type, and we don't
have any corresponding uuid type for that, so this wouldn't work.
Adding a UUID type for MBR should be the way forward.

The GPT partition side seems good to me, but it would be nice if the
description in the manual included the expected formats of the UUIDs,
depending on the partition table type.  Examples would be welcome there
as well.

Best,
-- 
Josselin Poiret

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 682 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#62827: [PATCH] image: Add partition type-uuid support.
  2023-04-14  6:53 [bug#62827] [PATCH] image: Add partition type-uuid support Aleksandr Vityazev
  2023-05-13  8:06 ` Josselin Poiret via Guix-patches via
@ 2023-10-14 20:04 ` Mathieu Othacehe
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Othacehe @ 2023-10-14 20:04 UTC (permalink / raw)
  To: Aleksandr Vityazev; +Cc: 62827-done


Hello,

> -            (file-system (partition-file-system partition)))
> +            (file-system (partition-file-system partition))
> +            (type-uuid (partition-type-uuid partition)))
>          (cond
> +         (type-uuid (uuid->string type-uuid))
>           ((member 'esp flags) "0xEF")

This one was been opened for a while. There are no UUIDs on MBR so I
doubt this makes sense.

Closing,

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-14 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14  6:53 [bug#62827] [PATCH] image: Add partition type-uuid support Aleksandr Vityazev
2023-05-13  8:06 ` Josselin Poiret via Guix-patches via
2023-10-14 20:04 ` bug#62827: " Mathieu Othacehe

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).