aboutsummaryrefslogtreecommitdiff
path: root/gnu/build
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2020-05-02 17:31:28 +0200
committerMarius Bakke <mbakke@fastmail.com>2020-05-02 17:31:28 +0200
commit50e6c1bf2ef2f006baa8cac80dfbb12ca2ba6d64 (patch)
tree64f16d207bad28a9dfda9cce95e6337483a40066 /gnu/build
parenta8cb1e72ef351330d1521833c1b270dcc0da593f (diff)
parentafc57916e5398737e13d94b3823983783221eb63 (diff)
downloadpatches-50e6c1bf2ef2f006baa8cac80dfbb12ca2ba6d64.tar
patches-50e6c1bf2ef2f006baa8cac80dfbb12ca2ba6d64.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/build')
-rw-r--r--gnu/build/file-systems.scm61
-rw-r--r--gnu/build/linux-boot.scm11
2 files changed, 66 insertions, 6 deletions
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 902563b219..bbea4c766e 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -338,6 +338,58 @@ if DEVICE does not contain a JFS file system."
;;;
+;;; 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 @@ partition field reader that returned a value."
(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 @@ partition field reader that returned a value."
(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 @@ were found."
((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)))
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index d1c9f47f33..c6f9df5f29 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -565,10 +565,13 @@ upon error."
;; 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.
- (let ((root (cond ((string-prefix? "/" root) root)
- ((uuid root) => identity)
- (else (file-system-label root)))))
- (mount-root-file-system (canonicalize-device-spec root)
+ (let ((device-spec (cond ((string-prefix? "/" root) root)
+ ((uuid root) => identity)
+ ((string-contains root ":/") #f) ; nfs
+ (else (file-system-label root)))))
+ (mount-root-file-system (if device-spec
+ (canonicalize-device-spec device-spec)
+ root)
root-fs-type
#:volatile-root? volatile-root?
#:flags root-fs-flags