mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
file-systems: Fix F2FS volume name accessor.
Follow-up to 23b37c3d40
.
* gnu/build/file-systems.scm (bytevector-utf16-length): New procedure.
(null-terminated-utf16->string): New procedure.
(f2fs-superblock-volume-name): Use it.
This commit is contained in:
parent
f8a0065ae3
commit
f73f4b3a2d
1 changed files with 19 additions and 1 deletions
|
@ -98,6 +98,22 @@ (define (read-superblock device offset size magic?)
|
||||||
(define null-terminated-latin1->string
|
(define null-terminated-latin1->string
|
||||||
(cut latin1->string <> zero?))
|
(cut latin1->string <> zero?))
|
||||||
|
|
||||||
|
(define (bytevector-utf16-length bv)
|
||||||
|
"Given a bytevector BV containing a NUL-terminated UTF16-encoded string,
|
||||||
|
determine where the NUL terminator is and return its index. If there's no
|
||||||
|
NUL terminator, return the size of the bytevector."
|
||||||
|
(let ((length (bytevector-length bv)))
|
||||||
|
(let loop ((index 0))
|
||||||
|
(if (< index length)
|
||||||
|
(if (zero? (bytevector-u16-ref bv index 'little))
|
||||||
|
index
|
||||||
|
(loop (+ index 2)))
|
||||||
|
length))))
|
||||||
|
|
||||||
|
(define (null-terminated-utf16->string bv endianness)
|
||||||
|
(utf16->string (sub-bytevector bv 0 (bytevector-utf16-length bv))
|
||||||
|
endianness))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Ext2 file systems.
|
;;; Ext2 file systems.
|
||||||
|
@ -377,7 +393,9 @@ (define (f2fs-superblock-uuid sblock)
|
||||||
(define (f2fs-superblock-volume-name sblock)
|
(define (f2fs-superblock-volume-name sblock)
|
||||||
"Return the volume name of SBLOCK as a string of at most 512 characters, or
|
"Return the volume name of SBLOCK as a string of at most 512 characters, or
|
||||||
#f if SBLOCK has no volume name."
|
#f if SBLOCK has no volume name."
|
||||||
(utf16->string (sub-bytevector sblock (- (+ #x470 12) #x400) 512) %f2fs-endianness))
|
(null-terminated-utf16->string
|
||||||
|
(sub-bytevector sblock (- (+ #x470 12) #x400) 512)
|
||||||
|
%f2fs-endianness))
|
||||||
|
|
||||||
(define (check-f2fs-file-system device)
|
(define (check-f2fs-file-system device)
|
||||||
"Return the health of a F2FS file system on DEVICE."
|
"Return the health of a F2FS file system on DEVICE."
|
||||||
|
|
Loading…
Reference in a new issue