[PATCH SLOF 3/5] disk-label: introduce helper to check fat filesystem

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Mon Jun 22 17:59:45 AEST 2015


Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
---
 slof/fs/packages/disk-label.fs | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/slof/fs/packages/disk-label.fs b/slof/fs/packages/disk-label.fs
index 2cf1b85..e317e93 100644
--- a/slof/fs/packages/disk-label.fs
+++ b/slof/fs/packages/disk-label.fs
@@ -320,6 +320,18 @@ CONSTANT /gpt-part-entry
 
 \ Load from first active DOS boot partition.
 
+: has-fat-filesystem ( block -- true | false )
+   \ block 0 byte 0-2 is a jump instruction in all FAT
+   \ filesystems.
+   \ e9 and eb are jump instructions in x86 assembler.
+   dup c@ e9 <> IF
+      dup c@ eb <> swap
+      2+  c@ 90 <> or
+      IF false EXIT THEN
+   ELSE DROP THEN
+   TRUE
+;
+
 \ NOTE: block-size is always 512 bytes for DOS partition tables.
 
 : load-from-dos-boot-partition ( addr -- size )
@@ -547,15 +559,7 @@ AA268B49521E5A8B    CONSTANT GPT-PREP-PARTITION-4
 
 : try-dos-files ( -- found? )
    no-mbr? IF false EXIT THEN
-
-   \ block 0 byte 0-2 is a jump instruction in all FAT
-   \ filesystems.
-   \ e9 and eb are jump instructions in x86 assembler.
-   block c@ e9 <> IF
-      block c@ eb <>
-      block 2+ c@ 90 <> or
-      IF false EXIT THEN
-   THEN
+   block has-fat-filesystem 0= IF false EXIT THEN
    s" fat-files" (interpose-filesystem)
    true
 ;
-- 
1.8.3.1



More information about the Linuxppc-dev mailing list