From 658f406a51b7b3136ae34da2cb33cd6926de89e7 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Wed, 21 Sep 2022 14:04:57 -0600
Subject: [PATCH] Make it possible to open RedoxFS without GPT on UEFI

---
 src/os/uefi/mod.rs | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/os/uefi/mod.rs b/src/os/uefi/mod.rs
index f9348e0..93ea04a 100644
--- a/src/os/uefi/mod.rs
+++ b/src/os/uefi/mod.rs
@@ -92,18 +92,30 @@ impl Os<
 
     fn filesystem(&self, password_opt: Option<&[u8]>) -> syscall::Result<redoxfs::FileSystem<DiskEfi>> {
         for block_io in DiskEfi::all().into_iter() {
-            if !block_io.0.Media.LogicalPartition {
-                continue;
-            }
-
-            match redoxfs::FileSystem::open(block_io, password_opt, Some(0), false) {
-                Ok(ok) => return Ok(ok),
-                Err(err) => match err.errno {
-                    // Ignore header not found error
-                    syscall::ENOENT => (),
-                    // Return any other errors
-                    _ => {
-                        return Err(err)
+            if block_io.0.Media.LogicalPartition {
+                match redoxfs::FileSystem::open(block_io, password_opt, Some(0), false) {
+                    Ok(ok) => return Ok(ok),
+                    Err(err) => match err.errno {
+                        // Ignore header not found error
+                        syscall::ENOENT => (),
+                        // Return any other errors
+                        _ => {
+                            return Err(err)
+                        }
+                    }
+                }
+            } else {
+                //TODO: get block from partition table
+                let block = crate::MIBI as u64 / redoxfs::BLOCK_SIZE;
+                match redoxfs::FileSystem::open(block_io, password_opt, Some(block), false) {
+                    Ok(ok) => return Ok(ok),
+                    Err(err) => match err.errno {
+                        // Ignore header not found error
+                        syscall::ENOENT => (),
+                        // Return any other errors
+                        _ => {
+                            return Err(err)
+                        }
                     }
                 }
             }
-- 
GitLab