guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: installer: parted: Retry failing read-partition-u


From: guix-commits
Subject: branch master updated: installer: parted: Retry failing read-partition-uuid call.
Date: Mon, 31 Oct 2022 04:34:25 -0400

This is an automated email from the git hooks/post-receive script.

mothacehe pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new ab974ed709 installer: parted: Retry failing read-partition-uuid call.
ab974ed709 is described below

commit ab974ed709976d34917c8f6f9e5cc0004547af45
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Sat Oct 22 22:27:57 2022 +0200

    installer: parted: Retry failing read-partition-uuid call.
    
    Fixes: <https://issues.guix.gnu.org/53541>.
    
    * gnu/installer/parted.scm (read-partition-uuid/retry): New procedure.
    (check-user-partitions): Use it.
---
 gnu/installer/parted.scm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index fcc936a391..82375d29e3 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -319,6 +319,25 @@ PARTED-OBJECT field equals PARTITION, return #f if not 
found."
                   partition))
         user-partitions))
 
+(define (read-partition-uuid/retry file-name)
+  "Call READ-PARTITION-UUID with 5 retries spaced by 1 second.  This is useful
+if the partition table is updated by the kernel at the time this function is
+called, causing the underlying /dev to be absent."
+  (define max-retries 5)
+
+  (let loop ((retry max-retries))
+    (catch #t
+      (lambda ()
+        (read-partition-uuid file-name))
+      (lambda _
+        (if (> retry 0)
+            (begin
+              (sleep 1)
+              (loop (- retry 1)))
+            (error
+             (format #f (G_ "Could not open ~a after ~a retries~%.")
+                     file-name max-retries)))))))
+
 
 ;;
 ;; Devices
@@ -1108,7 +1127,7 @@ Return #t if all the statements are valid."
                (need-formatting?
                 (user-partition-need-formatting? user-partition)))
            (or need-formatting?
-               (read-partition-uuid file-name)
+               (read-partition-uuid/retry file-name)
                (raise
                 (condition
                  (&cannot-read-uuid



reply via email to

[Prev in Thread] Current Thread [Next in Thread]