資源簡(jiǎn)介
設(shè)計(jì)一
設(shè)計(jì)任務(wù):模擬Linux文件系統(tǒng)
在任一OS下,建立一個(gè)大文件,把它假象成一張盤,在其中實(shí)現(xiàn)一個(gè)簡(jiǎn)單的模擬Linux文件系統(tǒng)。
1. 在現(xiàn)有機(jī)器硬盤上開辟100M的硬盤空間,作為設(shè)定的硬盤空間。
2. 編寫一管理程序simdisk對(duì)此空間進(jìn)行管理,以模擬Linux文件系統(tǒng),要求:
(1) 盤塊大小1k
(2) 空閑盤塊的管理:Linux位圖法
(3) 結(jié)構(gòu):超級(jí)塊, i結(jié)點(diǎn)區(qū), 根目錄區(qū)
3. 該simdisk管理程序的功能要求如下:
(1) info: 顯示整個(gè)系統(tǒng)信息(參考Linux文件系統(tǒng)的系統(tǒng)信息),文件可以根據(jù)用戶進(jìn)行讀寫保護(hù)。目錄名和文件名支持全路徑名和相對(duì)路徑名,路徑名各分量間用“/”隔開。

代碼片段和文件信息
#include
#include
#include
#include?“structure.h“
#include?“format.h“
#include?“l(fā)og.h“
#include?“help.h“
#include?“dir.h“
#include?“file.h“
#include?“display_sys.h“
#include?“find_same_name.h“
#include?“b_alloc_and_free.h“
#include?“i_alloc_and_free.h“
#include?“divide_path.h“
#include?“check.h“
#include?“install.h“
#include?“exit.h“
#include?“display_current_dir.h“
struct?block_group?_block_group[BLOCKS_GROUP_NUM]; //數(shù)據(jù)塊組
struct?inode?inode_table[TOTAL_INODES_NUM]; //inode表
struct?user?_user[MAX_USER_NUM]; //用戶
struct?dir?_current_dir; //目錄
bool?block_bitmap[TOTAL_BLOCKS_NUM]; //數(shù)據(jù)塊位圖
bool?inode_bitmap[TOTAL_INODES_NUM]; //inode?位圖
FILE?*fd; //系統(tǒng)文件
unsigned?int?uid; //使用文件系統(tǒng)的用戶ID
char?pwd[20]; //密碼
command?cmd[13]; //命令
char?current_path[1000]; //保存當(dāng)前路徑
void?main()
{
install();
while(!login());
printf(“\n**************************歡迎使用模擬Linux文件系統(tǒng)!***************************\n“);
while(1)
{
char?control[100]; //用于輸入命令
char?path1[1000]path2[1000]; //用于路徑或名字輸入
int?i=0; //循環(huán)控制變量
fflush(stdin); //清除流
printf(“\n%s“current_path);
scanf(“%s“control);
for(i=0;i<13;i++)
if(strcmp(cmd[i].comcontrol)==0)
break;
switch(i)
{
case?0: //format
format();
break;
case?1: //info
display_sys_info();
break;
case?2: //cd
scanf(“%s“path1);
if(change_dir(path1sizeof(path1)))
display_current_dir(_current_dir);
break;
case?3: //dir
scanf(“%s“path1);
display_dir(path1sizeof(path1));
break;
case?4: //md
scanf(“%s“path1);
make_dir(path1sizeof(path1));
break;
case?5: //rd
scanf(“%s“path1);
remove_dir(path1sizeof(path1));
break;
case?6: //newfile
scanf(“%s“path1);
create_file(path1sizeof(path1));
break;
case?7: //cat
scanf(“%s“path1);
open_file(path1sizeof(path1));
break;
case?8: //copy
scanf(“%s“path1);
scanf(“%s“path2);
copy_file(path1sizeof(path1)path2sizeof(path2));
break;
case?9: //del
scanf(“%s“path1);
delete_file(path1sizeof(path1));
break;
case?10: //check
check();
break;
case?11: //exit
exit_sys();
break;
case?12: //help
help();
break;
default:
printf(“沒有此命令!如需幫助請(qǐng)輸入?hlep\n“);
}
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2009-02-28?16:46??操作系統(tǒng)課程設(shè)計(jì)\
?????文件??????229451??2009-02-25?22:38??操作系統(tǒng)課程設(shè)計(jì)\simdisk.exe
?????目錄???????????0??2009-02-25?23:57??操作系統(tǒng)課程設(shè)計(jì)\src\
?????文件????????4314??2009-02-25?21:13??操作系統(tǒng)課程設(shè)計(jì)\src\b_alloc_and_free.h
?????文件????????2679??2009-02-25?01:04??操作系統(tǒng)課程設(shè)計(jì)\src\check.h
?????文件???????13104??2009-02-25?21:07??操作系統(tǒng)課程設(shè)計(jì)\src\dir.h
?????文件?????????897??2009-02-25?18:03??操作系統(tǒng)課程設(shè)計(jì)\src\display_current_dir.h
?????文件?????????753??2009-02-22?12:43??操作系統(tǒng)課程設(shè)計(jì)\src\display_sys.h
?????文件????????5458??2009-02-25?18:32??操作系統(tǒng)課程設(shè)計(jì)\src\divide_path.h
?????文件?????????724??2009-02-25?18:02??操作系統(tǒng)課程設(shè)計(jì)\src\exit.h
?????文件???????13801??2009-02-25?18:10??操作系統(tǒng)課程設(shè)計(jì)\src\file.h
?????文件?????????331??2009-02-21?13:01??操作系統(tǒng)課程設(shè)計(jì)\src\find_same_name.h
?????文件????????4631??2009-02-25?17:37??操作系統(tǒng)課程設(shè)計(jì)\src\format.h
?????文件????????1053??2009-02-25?17:37??操作系統(tǒng)課程設(shè)計(jì)\src\help.h
?????文件????????1686??2009-02-25?17:37??操作系統(tǒng)課程設(shè)計(jì)\src\install.h
?????文件????????1391??2009-02-22?16:01??操作系統(tǒng)課程設(shè)計(jì)\src\i_alloc_and_free.h
?????文件????????1017??2009-02-25?14:32??操作系統(tǒng)課程設(shè)計(jì)\src\log.h
?????文件????????2560??2009-02-25?19:56??操作系統(tǒng)課程設(shè)計(jì)\src\main.cpp
?????文件????????5579??2009-02-25?22:38??操作系統(tǒng)課程設(shè)計(jì)\src\structure.h
?????文件??????339391??2009-02-28?16:44??操作系統(tǒng)課程設(shè)計(jì)\實(shí)驗(yàn)報(bào)告.docx
?????文件???????55808??2009-02-11?12:17??操作系統(tǒng)課程設(shè)計(jì)\操作系統(tǒng)課程設(shè)計(jì)2008-simple.doc
評(píng)論
共有 條評(píng)論