mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-12 06:06:53 -05:00
file-systems: Add support for F2FS.
* gnu/build/file-systems.scm (%f2fs-endianness): New syntax. (f2fs-superblock?, read-f2fs-superblock, f2fs-superblock-uuid) (f2fs-superblock-volume-name, check-f2fs-file-system): New procedures. (%partition-label-readers, %partition-uuid-readers, check-file-system): Register them. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
This commit is contained in:
parent
5a0b78e62b
commit
23b37c3d40
1 changed files with 59 additions and 2 deletions
|
@ -336,6 +336,58 @@ (define (check-jfs-file-system device)
|
|||
(2 'reboot-required)
|
||||
(_ 'fatal-error)))
|
||||
|
||||
|
||||
;;;
|
||||
;;; F2FS (Flash-Friendly File System)
|
||||
;;;
|
||||
|
||||
;;; https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/tree/include/linux/f2fs_fs.h
|
||||
;;; (but using xxd proved to be simpler)
|
||||
|
||||
(define-syntax %f2fs-endianness
|
||||
;; Endianness of F2FS file systems
|
||||
(identifier-syntax (endianness little)))
|
||||
|
||||
;; F2FS actually stores two adjacent copies of the superblock.
|
||||
;; should we read both?
|
||||
(define (f2fs-superblock? sblock)
|
||||
"Return #t when SBLOCK is an F2FS superblock."
|
||||
(let ((magic (bytevector-u32-ref sblock 0 %f2fs-endianness)))
|
||||
(= magic #xF2F52010)))
|
||||
|
||||
(define (read-f2fs-superblock device)
|
||||
"Return the raw contents of DEVICE's F2FS superblock as a bytevector, or #f
|
||||
if DEVICE does not contain an F2FS file system."
|
||||
(read-superblock device
|
||||
;; offset of magic in first copy
|
||||
#x400
|
||||
;; difference between magic of second
|
||||
;; and first copies
|
||||
(- #x1400 #x400)
|
||||
f2fs-superblock?))
|
||||
|
||||
(define (f2fs-superblock-uuid sblock)
|
||||
"Return the UUID of F2FS superblock SBLOCK as a 16-byte bytevector."
|
||||
(sub-bytevector sblock
|
||||
(- (+ #x460 12)
|
||||
;; subtract superblock offset
|
||||
#x400)
|
||||
16))
|
||||
|
||||
(define (f2fs-superblock-volume-name sblock)
|
||||
"Return the volume name of SBLOCK as a string of at most 512 characters, or
|
||||
#f if SBLOCK has no volume name."
|
||||
(utf16->string (sub-bytevector sblock (- (+ #x470 12) #x400) 512) %f2fs-endianness))
|
||||
|
||||
(define (check-f2fs-file-system device)
|
||||
"Return the health of a F2FS file system on DEVICE."
|
||||
(match (status:exit-val
|
||||
(system* "fsck.f2fs" "-p" device))
|
||||
;; 0 and -1 are the only two possibilities
|
||||
;; (according to the manpage)
|
||||
(0 'pass)
|
||||
(_ 'fatal-error)))
|
||||
|
||||
|
||||
;;;
|
||||
;;; LUKS encrypted devices.
|
||||
|
@ -472,7 +524,9 @@ (define %partition-label-readers
|
|||
(partition-field-reader read-fat16-superblock
|
||||
fat16-superblock-volume-name)
|
||||
(partition-field-reader read-jfs-superblock
|
||||
jfs-superblock-volume-name)))
|
||||
jfs-superblock-volume-name)
|
||||
(partition-field-reader read-f2fs-superblock
|
||||
f2fs-superblock-volume-name)))
|
||||
|
||||
(define %partition-uuid-readers
|
||||
(list (partition-field-reader read-iso9660-superblock
|
||||
|
@ -486,7 +540,9 @@ (define %partition-uuid-readers
|
|||
(partition-field-reader read-fat16-superblock
|
||||
fat16-superblock-uuid)
|
||||
(partition-field-reader read-jfs-superblock
|
||||
jfs-superblock-uuid)))
|
||||
jfs-superblock-uuid)
|
||||
(partition-field-reader read-f2fs-superblock
|
||||
f2fs-superblock-uuid)))
|
||||
|
||||
(define read-partition-label
|
||||
(cut read-partition-field <> %partition-label-readers))
|
||||
|
@ -582,6 +638,7 @@ (define check-procedure
|
|||
((string-prefix? "btrfs" type) check-btrfs-file-system)
|
||||
((string-suffix? "fat" type) check-fat-file-system)
|
||||
((string-prefix? "jfs" type) check-jfs-file-system)
|
||||
((string-prefix? "f2fs" type) check-f2fs-file-system)
|
||||
((string-prefix? "nfs" type) (const 'pass))
|
||||
(else #f)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue