[PATCH] image: Add partition type-uuid support.

  • Done
  • quality assurance status badge
Details
3 participants
  • Aleksandr Vityazev
  • Josselin Poiret
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Aleksandr Vityazev
Severity
normal

Debbugs page

Aleksandr Vityazev wrote 2 years ago
(address . guix-patches@gnu.org)
87pm87j6p1.fsf@gmail.com
* 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(-)

Toggle diff (91 lines)
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
Josselin Poiret wrote 2 years ago
87ttwgac5y.fsf@jpoiret.xyz
Hi Aleksandr,

Aleksandr Vityazev <avityazew@gmail.com> writes:

Toggle quote (13 lines)
> @@ -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
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmRfROkQHGRldkBqcG9p
cmV0Lnh5egAKCRBQXkC5FhcaipnuC/9G7Vr9qyfWBhFHuusXcZn78eskgzDGHebx
5Av7niB/zYvSeSTGV++7Dv8T2ubrWXMnll9fkyHyIcd6BUO2Jf/H4cdzcVvmJquV
/oE65i5Z345h1b9UOHsamE5/kxVUsRACUoeD6L3nSVRGecGVW/BuLVtbyHMP3Qma
G9TUS5NHlhYHUuQU6SB9BJWP9R+6XY39eg2kcuqPVD0mDIH6CnWMF9sONE2ZyBn/
ouNCNP6xBs4juVMLvegkM+lt2AbRYuDU2IVobdbpLjhN0MvYpW6LSit2jav1TnaT
Lg8RzNlshabLfwQAsDoymUGPpdUNIS8j556KCJS/UKOntMqxHL0jxdxqaMmuYJdA
IHRAgg5VUNGE0nYVsB5y9veXzGSxC52RJtDXqKH0sgITZZSaq+Xk01mFqOAOR0Zh
E0mKyrd3Njm/QNJdIX3eXMF1ZprpxzeyXr9xoWzYb63oIJN6wiBERX1V++djD3Y+
HDWOqKXm/VO7FYGpUwppQ2GeAf/xcZ4=
=x5zA
-----END PGP SIGNATURE-----

Mathieu Othacehe wrote 1 years ago
(name . Aleksandr Vityazev)(address . avityazew@gmail.com)(address . 62827-done@debbugs.gnu.org)
87o7h1j7h6.fsf@gnu.org
Hello,

Toggle quote (7 lines)
> - (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
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 62827@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 62827
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help