[PATCH] file-systems: Provide string->iso9660-uuid.

  • Done
  • quality assurance status badge
Details
2 participants
  • Danny Milosavljevic
  • Ludovic Courtès
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 8 years ago
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20170608192652.28420-1-dannym@scratchpost.org
* gnu/build/file-systems.scm (string->iso9660-uuid): New variable. Export it.
---
gnu/build/file-systems.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (40 lines)
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 7737de3d0..1c733f43b 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -43,6 +43,7 @@
uuid->string
string->uuid
+ string->iso9660-uuid
bind-mount
@@ -235,6 +236,27 @@ Trailing spaces are trimmed."
;; <http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf>.
+(define %iso9660-uuid-rx
+ ;; Y m d H M S ss
+ (make-regexp "^([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})$"))
+
+(define (string->iso9660-uuid str)
+ "Parse STR as a ISO9660 UUID (which is really a timestamp - see /dev/disk/by-uuid).
+Return its contents as a 16-byte bytevector. Return #f if STR is not a valid
+ISO9660 UUID representation."
+ (and=> (regexp-exec %iso9660-uuid-rx str)
+ (lambda (match)
+ (letrec-syntax ((match-numerals
+ (syntax-rules ()
+ ((_ index (name rest ...) body)
+ (let ((name (match:substring match index)))
+ (match-numerals (+ 1 index) (rest ...) body)))
+ ((_ index () body)
+ body))))
+ (match-numerals 1 (year month day hour minute second hundredths)
+ (string->utf8 (string-append year month day
+ hour minute second hundredths)))))))
+
(define (iso9660-superblock? sblock)
"Return #t when SBLOCK is an iso9660 volume descriptor."
(bytevector=? (sub-bytevector sblock 1 6)
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 27290@debbugs.gnu.org)
87bmpynplr.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (2 lines)
> * gnu/build/file-systems.scm (string->iso9660-uuid): New variable. Export it.

LGTM, thanks!

Ludo'.
Danny Milosavljevic wrote 8 years ago
(no subject)
(address . control@debbugs.gnu.org)
20170609132806.41f25a43@scratchpost.org
close 27290
?
Your comment

This issue is archived.

To comment on this conversation send an email to 27290@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 27290
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help