mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 13:58:15 -05:00
file-systems: Separate ENOENT catching from ext2 superblock reads.
* gnu/build/file-systems.scm (ENOENT-safe): New procedure. (read-ext2-superblock*): Rewrite in terms of it.
This commit is contained in:
parent
e9dffec126
commit
2447335625
1 changed files with 20 additions and 16 deletions
|
@ -167,12 +167,13 @@ (define (partition? major minor)
|
||||||
(loop (cons name parts))
|
(loop (cons name parts))
|
||||||
(loop parts))))))))))
|
(loop parts))))))))))
|
||||||
|
|
||||||
(define (read-ext2-superblock* device)
|
(define (ENOENT-safe proc)
|
||||||
"Like 'read-ext2-superblock', but return #f when DEVICE does not exist
|
"Wrap the one-argument PROC such that ENOENT errors are caught and lead to a
|
||||||
instead of throwing an exception."
|
warning and #f as the result."
|
||||||
|
(lambda (device)
|
||||||
(catch 'system-error
|
(catch 'system-error
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(read-ext2-superblock device))
|
(proc device))
|
||||||
(lambda args
|
(lambda args
|
||||||
;; When running on the hand-made /dev,
|
;; When running on the hand-made /dev,
|
||||||
;; 'disk-partitions' could return partitions for which
|
;; 'disk-partitions' could return partitions for which
|
||||||
|
@ -182,7 +183,10 @@ (define (read-ext2-superblock* device)
|
||||||
(format (current-error-port)
|
(format (current-error-port)
|
||||||
"warning: device '~a' not found~%" device)
|
"warning: device '~a' not found~%" device)
|
||||||
#f)
|
#f)
|
||||||
(apply throw args)))))
|
(apply throw args))))))
|
||||||
|
|
||||||
|
(define read-ext2-superblock*
|
||||||
|
(ENOENT-safe read-ext2-superblock))
|
||||||
|
|
||||||
(define (partition-predicate field =)
|
(define (partition-predicate field =)
|
||||||
"Return a predicate that returns true if the FIELD of an ext2 superblock is
|
"Return a predicate that returns true if the FIELD of an ext2 superblock is
|
||||||
|
|
Loading…
Reference in a new issue