From 227ffc6c34c7bef29a39b2745865ac25c28a7e74 Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Mon, 1 Aug 2016 08:46:48 -0700 Subject: [PATCH 5/9] Factor out procedure: device->title --- gnu/build/file-systems.scm | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index f1fccbd..4a8acd5 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -38,6 +38,7 @@ find-partition-by-uuid find-partition-by-luks-uuid canonicalize-device-spec + device->title uuid->string string->uuid @@ -364,19 +365,6 @@ the following: ;; this long. 20) - (define canonical-title - ;; The realm of canonicalization. - (if (eq? title 'any) - (if (string? spec) - ;; The "--root=SPEC" kernel command-line option always provides a - ;; string, but the string can represent a device, a UUID, or a - ;; label. So check for all three. - (cond ((string-prefix? "/" spec) 'device) - ((string->uuid spec) 'uuid) - (else 'label)) - 'uuid) - title)) - (define (resolve find-partition spec fmt) (let loop ((count 0)) (let ((device (find-partition spec))) @@ -391,6 +379,10 @@ the following: (sleep 1) (loop (+ 1 count)))))))) + (define canonical-title (if (eq? title 'any) + (device->title spec) + title)) + (case canonical-title ((device) ;; Nothing to do. @@ -407,6 +399,19 @@ the following: (else (error "unknown device title" title)))) +(define (device->title device) + "Guess the title for the given DEVICE, which must be a device parameter from +a object. As a special case, when the DEVICE is a UUID, it may +be specified as a string." + (if (string? device) + ;; The "--root=SPEC" kernel command-line option always provides a + ;; string, but the string can represent a device, a UUID, or a + ;; label. So check for all three. + (cond ((string-prefix? "/" device) 'device) + ((string->uuid device) 'uuid) + (else 'label)) + 'uuid)) + (define (check-file-system device type) "Run a file system check of TYPE on DEVICE." (define fsck -- 2.9.2