資源簡介
仿照UNIX操作系統設計中文件系統的描述,將一個文件當作一個磁盤,并在該文件上構建一個完整文件系統,支持多級目錄,支持命令瀏覽文件ls, 切換目錄cd,創建文件create,刪除文件unlink,寫入文件write,讀文件read, 留有更多接口開發其他的命令,作為學習文件系統是一個不錯的例子。
代碼片段和文件信息
#include?“File_System.h“
#include?
static?FILE?*File_System_fp;
static?Surper_Block?Surper_Block_Info;
static?Mem_Inode_P?Mem_Inode_head?Mem_Inode_Tail;
static?int?Indirect_Block_Quantity?=?BLOCK_SIZE?/?sizeof(int);
static?int?Current_Dirent_Inode_Num;
//塊號轉文件偏移量
//入口參數:塊號
//返回值:文件偏移量
int?Block_Num_to_Offset(int?Block_Num)
{
????unsigned?int?Offset;
????Offset?=?Surper_Block_Info.Start_Block_Offset?+?Block_Num?*?BLOCK_SIZE;
????return?Offset;
}
//結點號轉文件偏移量
//入口參數:結點號
//返回值:文件偏移量
int?Inode_Num_to_Offset(int?Inode_Num)
{
????unsigned?int?Offset;
????int?Disk_Inode_Size?=?sizeof(Disk_Inode);
????Offset?=?Surper_Block_Info.Start_Inode_Offset?+?Inode_Num?*?Disk_Inode_Size;
????return?Offset;
}
//讀取文件塊里所有int數據
//入口參數:Block_Num:塊號;?Block_Buf:整型數組;
//返回
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????568??2018-10-23?20:29??File_System\apue.h
?????文件??????57585??2018-11-15?15:28??File_System\File_System.c
?????文件???????4894??2018-11-11?17:02??File_System\File_System.h
?????文件???????6070??2019-03-14?21:03??File_System\File_System_All.c
?????文件???????1215??2018-11-11?18:06??File_System\File_System_Test.c
?????文件????????119??2019-01-13?11:47??File_System\GccFile_System.sh
?????目錄??????????0??2019-03-14?21:06??File_System
-----------?---------??----------?-----??----
????????????????70451????????????????????7
評論
共有 條評論