Skip to content
Snippets Groups Projects
Unverified Commit bb7cf4f5 authored by Danny Milosavljevic's avatar Danny Milosavljevic
Browse files

file-systems: Provide string->iso9660-uuid.


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

Co-authored-by: default avatarLudovic Courtès <ludo@gnu.org>
parent 19c90e5f
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ (define-module (gnu build file-systems) ...@@ -43,6 +43,7 @@ (define-module (gnu build file-systems)
uuid->string uuid->string
string->uuid string->uuid
string->iso9660-uuid
bind-mount bind-mount
...@@ -235,6 +236,27 @@ (define (check-fat32-file-system device) ...@@ -235,6 +236,27 @@ (define (check-fat32-file-system device)
;; <http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf>. ;; <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) (define (iso9660-superblock? sblock)
"Return #t when SBLOCK is an iso9660 volume descriptor." "Return #t when SBLOCK is an iso9660 volume descriptor."
(bytevector=? (sub-bytevector sblock 1 6) (bytevector=? (sub-bytevector sblock 1 6)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment