Browse Source

change(fat32): use map to store cluster buffer

greatbridf 11 tháng trước cách đây
mục cha
commit
970c203132
4 tập tin đã thay đổi với 10 bổ sung12 xóa
  1. 2 2
      include/fs/fat.hpp
  2. 7 8
      include/kernel/process.hpp
  3. 1 1
      src/fs/fat.cpp
  4. 0 1
      src/kernel/process.cpp

+ 2 - 2
include/fs/fat.hpp

@@ -1,5 +1,6 @@
 #pragma once
 
+#include <map>
 #include <vector>
 
 #include <stdint.h>
@@ -7,7 +8,6 @@
 #include <sys/types.h>
 
 #include <types/size.h>
-#include <types/hash_map.hpp>
 
 #include <kernel/mem.h>
 #include <kernel/vfs.hpp>
@@ -134,7 +134,7 @@ private:
         int ref;
         // bool dirty;
     };
-    types::hash_map<cluster_t, buf_object> buf;
+    std::map<cluster_t, buf_object> buf;
 
     // buf MUST be larger than 512 bytes
     void _raw_read_sector(void* buf, uint32_t sector_no);

+ 7 - 8
include/kernel/process.hpp

@@ -16,6 +16,13 @@
 #include <kernel/task/thread.hpp>
 #include <kernel/task/current.hpp>
 
+#include <types/allocator.hpp>
+#include <types/cplusplus.hpp>
+#include <types/path.hpp>
+#include <types/status.h>
+#include <types/types.h>
+#include <types/lock.hpp>
+
 #include <kernel/async/waitlist.hpp>
 #include <kernel/interrupt.h>
 #include <kernel/mm.hpp>
@@ -25,14 +32,6 @@
 #include <kernel/task.h>
 #include <kernel/tty.hpp>
 #include <kernel/vfs.hpp>
-#include <types/allocator.hpp>
-#include <types/cplusplus.hpp>
-#include <types/hash_map.hpp>
-#include <types/path.hpp>
-#include <types/status.h>
-#include <types/string.hpp>
-#include <types/types.h>
-#include <types/lock.hpp>
 
 class process;
 

+ 1 - 1
src/fs/fat.cpp

@@ -65,7 +65,7 @@ char* fat32::read_cluster(cluster_t no)
 {
     auto iter = buf.find(no);
     if (iter) {
-        auto [ idx, buf ] = *iter;
+        auto& [ idx, buf ] = *iter;
         ++buf.ref;
         return buf.data;
     }

+ 0 - 1
src/kernel/process.cpp

@@ -27,7 +27,6 @@
 #include <types/bitmap.hpp>
 #include <types/cplusplus.hpp>
 #include <types/elf.hpp>
-#include <types/hash_map.hpp>
 #include <types/lock.hpp>
 #include <types/size.h>
 #include <types/status.h>