[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
11/20: file-systems: read-partition-{uuid, label} don't swallow ENOENT &
From: |
guix-commits |
Subject: |
11/20: file-systems: read-partition-{uuid, label} don't swallow ENOENT & co. |
Date: |
Sun, 25 Apr 2021 08:37:54 -0400 (EDT) |
civodul pushed a commit to branch version-1.3.0
in repository guix.
commit e318e989b7be7f328f9ef801cd90c539893af962
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Apr 22 22:41:01 2021 +0200
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'.
---
gnu/build/file-systems.scm | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 304805d..6111cd7 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=?))
- 06/20: build: Use guix system image instead of disk-image, vm-image., (continued)
- 06/20: build: Use guix system image instead of disk-image, vm-image., guix-commits, 2021/04/25
- 03/20: build: Add doc-update-po as a prerequisite to the dist target., guix-commits, 2021/04/25
- 07/20: .gitignore: Ignore release artifacts., guix-commits, 2021/04/25
- 04/20: .gitignore: Ignore generated .pot files., guix-commits, 2021/04/25
- 08/20: build: Add a check for Guile-Lib., guix-commits, 2021/04/25
- 16/20: po: Remove file that no longer exists., guix-commits, 2021/04/25
- 05/20: gnu: guile-git: Update to 0.5.1., guix-commits, 2021/04/25
- 09/20: import: go: Do not set '%strict-tokenizer?' from the top level., guix-commits, 2021/04/25
- 20/20: http-client: Remove exception mishandling in 'http-multiple-get'., guix-commits, 2021/04/25
- 10/20: import: go: Autoload (htmlprag)., guix-commits, 2021/04/25
- 11/20: file-systems: read-partition-{uuid, label} don't swallow ENOENT & co.,
guix-commits <=
- 17/20: cve: Gracefully handle bogus CVE entries., guix-commits, 2021/04/25
- 19/20: http-client, substitute: Gracefully handle GnuTLS EAGAIN/EINTR., guix-commits, 2021/04/25
- 18/20: doc: Fix cross-reference URL to translated manual., guix-commits, 2021/04/25
- 12/20: gnu: icecat: Update to 78.10.0-guix0-preview1 [security fixes]., guix-commits, 2021/04/25
- 14/20: guix-install.sh: Allow overriding the Guix binary source., guix-commits, 2021/04/25
- 13/20: gnu: wireshark: Update to 3.4.5 [security fixes]., guix-commits, 2021/04/25
- 15/20: import: Remove Nix importer., guix-commits, 2021/04/25