aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-04-22 22:41:01 +0200
committerLudovic Courtès <ludo@gnu.org>2021-04-23 00:32:30 +0200
commit09ce4568f2cc1f87c5a5e0aa1643780c39a73088 (patch)
treef787b824f597fbbc44220009b6ddf03a30581aea /gnu
parent34db952a4b655cca9d5dc7158e9a8552d389cbcf (diff)
downloadguix-09ce4568f2cc1f87c5a5e0aa1643780c39a73088.tar.gz
guix-09ce4568f2cc1f87c5a5e0aa1643780c39a73088.zip
file-systems: read-partition-{uuid,label} don't swallow ENOENT & co.
Previously, (read-partition-uuid "/does/not/exist") would return #f. With this change, a 'system-error exception is raised as expected. * gnu/build/file-systems.scm (ENOENT-safe): Clarify docstring. (partition-field-reader): Remove use of 'ENOENT-safe'. (partition-predicate): Wrap READER in 'ENOENT-safe'.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/build/file-systems.scm29
1 files changed, 14 insertions, 15 deletions
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 304805db62..6111cd747c 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -644,16 +644,13 @@ if DEVICE does not contain a NTFS file system."
(loop parts))))))))))
(define (ENOENT-safe proc)
- "Wrap the one-argument PROC such that ENOENT errors are caught and lead to a
-warning and #f as the result."
+ "Wrap the one-argument PROC such that ENOENT, EIO, and ENOMEDIUM errors are
+caught and lead to a warning and #f as the result."
(lambda (device)
(catch 'system-error
(lambda ()
(proc device))
(lambda args
- ;; When running on the hand-made /dev,
- ;; 'disk-partitions' could return partitions for which
- ;; we have no /dev node. Handle that gracefully.
(let ((errno (system-error-errno args)))
(cond ((= ENOENT errno)
(format (current-error-port)
@@ -671,11 +668,10 @@ warning and #f as the result."
(define (partition-field-reader read field)
"Return a procedure that takes a device and returns the value of a FIELD in
the partition superblock or #f."
- (let ((read (ENOENT-safe read)))
- (lambda (device)
- (let ((sblock (read device)))
- (and sblock
- (field sblock))))))
+ (lambda (device)
+ (let ((sblock (read device)))
+ (and sblock
+ (field sblock)))))
(define (read-partition-field device partition-field-readers)
"Returns the value of a FIELD in the partition superblock of DEVICE or #f. It
@@ -742,11 +738,14 @@ partition field reader that returned a value."
(define (partition-predicate reader =)
"Return a predicate that returns true if the FIELD of partition header that
was READ is = to the given value."
- (lambda (expected)
- (lambda (device)
- (let ((actual (reader device)))
- (and actual
- (= actual expected))))))
+ ;; When running on the hand-made /dev, 'disk-partitions' could return
+ ;; partitions for which we have no /dev node. Handle that gracefully.
+ (let ((reader (ENOENT-safe reader)))
+ (lambda (expected)
+ (lambda (device)
+ (let ((actual (reader device)))
+ (and actual
+ (= actual expected)))))))
(define partition-label-predicate
(partition-predicate read-partition-label string=?))