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
|
@ -167,22 +167,26 @@ if DEVICE does not contain an ext2 file system."
|
||||||
(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."
|
||||||
(catch 'system-error
|
(lambda (device)
|
||||||
(lambda ()
|
(catch 'system-error
|
||||||
(read-ext2-superblock device))
|
(lambda ()
|
||||||
(lambda args
|
(proc device))
|
||||||
;; When running on the hand-made /dev,
|
(lambda args
|
||||||
;; 'disk-partitions' could return partitions for which
|
;; When running on the hand-made /dev,
|
||||||
;; we have no /dev node. Handle that gracefully.
|
;; 'disk-partitions' could return partitions for which
|
||||||
(if (= ENOENT (system-error-errno args))
|
;; we have no /dev node. Handle that gracefully.
|
||||||
(begin
|
(if (= ENOENT (system-error-errno args))
|
||||||
(format (current-error-port)
|
(begin
|
||||||
"warning: device '~a' not found~%" device)
|
(format (current-error-port)
|
||||||
#f)
|
"warning: device '~a' not found~%" device)
|
||||||
(apply throw args)))))
|
#f)
|
||||||
|
(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 New Issue