文件系統(tǒng)設(shè)計(jì)_第1頁
文件系統(tǒng)設(shè)計(jì)_第2頁
文件系統(tǒng)設(shè)計(jì)_第3頁
文件系統(tǒng)設(shè)計(jì)_第4頁
文件系統(tǒng)設(shè)計(jì)_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、1設(shè)計(jì)題目 -12需求分析 -13系統(tǒng)概要設(shè)計(jì)(1)系統(tǒng)的主要功能- -1(2)系統(tǒng)模塊功能結(jié)構(gòu)-1(3)運(yùn)行環(huán)境要求-1(4)數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì)-14系統(tǒng)的詳細(xì)設(shè)確定程序設(shè)計(jì)的各個(gè)模塊的算法及內(nèi)部的數(shù)據(jù)組織,包括主要代碼并描述各種算法 -35系統(tǒng)的主要源代碼-56系統(tǒng)測(cè)試及調(diào)試-157心得體會(huì),概述總結(jié)自己-188主要參考文獻(xiàn)-18設(shè)計(jì)題目:文件系統(tǒng)設(shè)計(jì)需求分析:文件系統(tǒng)是linux操作系統(tǒng)的重要組成部分,linux文件具有強(qiáng)大的功能。文件系統(tǒng)中的文件是數(shù)據(jù)的集合,文件系統(tǒng)不僅包含著文件中的數(shù)據(jù)而且還有文件系統(tǒng)的結(jié)構(gòu),所有l(wèi)inux 用戶和程序看到的文件、目錄、軟連接及文件保護(hù)信息等都存儲(chǔ)在其中。

2、從這我們可以看出文件系統(tǒng)的重要性,要好好掌握,通過一個(gè)簡(jiǎn)單多用戶文件系統(tǒng)的設(shè)計(jì),加深理解文件系統(tǒng)的內(nèi)部功能及內(nèi)部實(shí)現(xiàn)。系統(tǒng)概要設(shè)計(jì)(1)系統(tǒng)的主要功能為linux系統(tǒng)設(shè)計(jì)一個(gè)簡(jiǎn)單的二級(jí)文件系統(tǒng),以實(shí)現(xiàn)下列功能:可以實(shí)現(xiàn)下列幾條命令(1) login 用戶登錄(2) dir 文件目錄列表(3) creat 創(chuàng)建文件(4) delete 刪除文件(5) open 打開文件(6) close 關(guān)閉文件 (7) read 讀文件(8) write 寫文件(2)系統(tǒng)模塊功能結(jié)構(gòu) 本系統(tǒng)是模擬實(shí)現(xiàn)多用戶多目錄的文件系統(tǒng)(8個(gè)用戶),在系統(tǒng)出現(xiàn)登錄后 ,輸入用戶與口令,在用戶登錄系統(tǒng)后,可建立文件卷,將用戶

3、輸入的文件保存在指定的文件中。系統(tǒng)的命令與其命令的具體實(shí)現(xiàn),此模擬系統(tǒng)共提供了login用戶登錄dir列文件目錄mkdir建立目錄create創(chuàng)建文件del刪除文件open打開文件read讀文件write寫文件上述命令,并根據(jù)命令的含義與要求,用c+編程來完成所有具體操作。該系統(tǒng)可以模擬完成用戶的登陸和驗(yàn)證,列出文件和目錄,新建目錄,改變目錄,創(chuàng)立和編寫文件,刪除文件和退出系統(tǒng)等功能。(3) 運(yùn)行環(huán)境要求開發(fā)環(huán)境:windows平臺(tái)+visual c+6.0運(yùn)行環(huán)境:windows全系列平臺(tái) visual c+6.0 linux環(huán)境下用g+編譯c+ 開發(fā)語言:c+(4) 數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì)(1)用戶

4、結(jié)構(gòu):賬號(hào)與密碼結(jié)構(gòu)typedef struct users char name8;char pwd10;users;本系統(tǒng)有8個(gè)默認(rèn)的用戶名,前面是用戶名,后面為密碼,用戶登陸時(shí)只要輸入正確便可進(jìn)入系統(tǒng),否則提示失敗要求重新輸入。users usrarray8 =usr1,usr1, usr2,usr2,usr3,usr3,usr4,usr4,usr5,usr5,usr6,usr6,usr7,usr7,usr8,usr8,;(2)數(shù)據(jù)結(jié)構(gòu)說明a)文件結(jié)構(gòu)鏈表struct fnode char filenamefilename_length;int isdir;int isopen;char

5、content255;fnode *parent;fnode *child;fnode *prev;fnode *next;b)函數(shù)介紹fnode *initfile(char filename,int isdir);/初始化文件或目錄void createroot();/建立系統(tǒng)根目錄int run();系統(tǒng)運(yùn)行int findpara(char *topara);對(duì)參數(shù)進(jìn)行處理bool chklogin(char *users, char *pwd);檢查賬號(hào)與口令void help();命令列表int mkdir();建立目錄int create();建立文件int read();讀取文

6、件int write();寫入文件int del();刪除文件int cd();切換目錄int dir();文件與目錄列表(3)各模塊流程圖系統(tǒng)的詳細(xì)設(shè)計(jì)確定程序設(shè)計(jì)的各個(gè)模塊的算法及內(nèi)部的數(shù)據(jù)組織,包括主要代碼并描述各種算法(1)用戶結(jié)構(gòu):賬號(hào)與密碼結(jié)構(gòu)typedef struct users char name8;char pwd10;users;本系統(tǒng)有8個(gè)默認(rèn)的用戶名,前面是用戶名,后面為密碼,用戶登陸時(shí)只要輸入正確便可進(jìn)入系統(tǒng),否則提示失敗要求重新輸入。users usrarray8 =usr1,usr1, usr2,usr2,usr3,usr3,usr4,usr4,usr5,usr

7、5,usr6,usr6,usr7,usr7,usr8,usr8,;(2)數(shù)據(jù)結(jié)構(gòu)說明a)文件結(jié)構(gòu)鏈表struct fnode char filenamefilename_length;int isdir;int isopen;char content255;fnode *parent;fnode *child;fnode *prev;fnode *next;b)函數(shù)介紹fnode *initfile(char filename,int isdir);/初始化文件或目錄void createroot();/建立系統(tǒng)根目錄int run();系統(tǒng)運(yùn)行int findpara(char *topar

8、a);對(duì)參數(shù)進(jìn)行處理bool chklogin(char *users, char *pwd);檢查賬號(hào)與口令void help();命令列表int mkdir();建立目錄int create();建立文件int read();讀取文件int write();寫入文件int del();刪除文件int cd();切換目錄int dir();文件與目錄列表系統(tǒng)的主要源代碼#include stdio.h#include iostream.h#include string.h#include iomanip.h#define filename_length 10 /文件名稱長(zhǎng)度#define c

9、ommand_length 10 /命令行長(zhǎng)度#define para_length 30 /參數(shù)長(zhǎng)度 /賬號(hào)結(jié)構(gòu) typedef struct users char name8; char pwd10;users; /文件結(jié)構(gòu)struct fnode char filenamefilename_length; int isdir; int isopen; char content255; fnode *parent; fnode *child; fnode *prev; fnode *next;/賬號(hào)users usrarray8 = usr1,usr1, usr2,usr2, usr3,u

10、sr3, usr4,usr4, usr5,usr5, usr6,usr6, usr7,usr7, usr8,usr8,; fnode *initfile(char filename,int isdir); void createroot(); int run(); int findpara(char *topara); bool chklogin(char *users, char *pwd); void help(); int mkdir(); int create(); int read(); int write(); int del(); int cd(); int dir();fnod

11、e *root,*recent,*temp,*ttemp;char parapara_length,commandcommand_length,tempparapara_length,recentparapara_length;/創(chuàng)建文件與目錄結(jié)點(diǎn) fnode* initfile(char filename,int isdir) fnode *node=new fnode; strcpy(node-filename,filename); node-isdir=isdir; node-isopen=0; node-parent=null; node-child=null; node-prev=n

12、ull; node-next=null; return node;/創(chuàng)建文件存儲(chǔ)結(jié)點(diǎn)void createroot () recent=root=initfile(/,1); root-parent=null; root-child=null; root-prev=root-next=null; strcpy(para,/); int mkdir() temp=initfile( ,1); cintemp-filename; if(recent-child=null) temp-parent=recent; temp-child=null; recent-child=temp; temp-pr

13、ev=temp-next=null; else ttemp=recent-child; while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=1) printf(對(duì)不起,目錄已存在!); return 1; ttemp-next=temp; temp-parent=null; temp-child=null; temp-prev=ttemp; temp-next=null; return 1;int create() temp=initfile( ,0); cintem

14、p-filename; cintemp-content; if(recent-child=null) temp-parent=recent; temp-child=null; recent-child=temp; temp-prev=temp-next=null; cout文件建立成功!child; while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=0) printf(對(duì)不起,文件已存在!); return 1; ttemp-next=temp; temp-pare

15、nt=null; temp-child=null; temp-prev=ttemp; temp-next=null; cout文件建立成功!endl; return 1;int dir()int i=0,j=0;temp=new fnode;temp=recent;if(temp!=root)cout .child=null) couttotal: directors i files j child;while(temp) if(temp-isdir) cout filenameendl;i+; else cout filenamenext; couttotal: directors i fi

16、les j filename; if(recent-child=null) cout文件不存在!child-filename,filename)=0) coutchild-contentchild; while(temp-next) if(strcmp(temp-next-filename,filename)=0) coutnext-contentendl; return 1; cout文件不存在!filename; if(recent-child=null) cout文件不存在!child-filename,filename)=0) recent-child-isopen=1;/設(shè)置文件標(biāo)記

17、為打開 cinrecent-child-content; recent-child-isopen=0;/設(shè)置文件標(biāo)記為關(guān)閉 cout文件寫入成功!child; while(temp-next) if(strcmp(temp-next-filename,filename)=0) recent-child-isopen=1;/設(shè)置文件標(biāo)記為打開 cintemp-next-content; recent-child-isopen=0;/設(shè)置文件標(biāo)記為關(guān)閉 cout文件寫入成功!endl; return 1; cout文件不存在!topara; if(strcmp(topara,.)=0) int i

18、; while(recent-prev) recent=recent-prev; if(recent-parent) recent=recent-parent; i=strlen(para); while(parai!=/ & i0) i-; if(i!=0) parai=0; else parai+1=0;else findpara(topara); return 1;int findpara(char *topara) int i=0; int sign=1; if(strcmp(topara,/)=0) recent=root; strcpy(para,/); return 1; tem

19、p=recent; strcpy(temppara,para); if(topara0=/) recent=root-child; i+; strcpy(para,/); else if(recent!=null & recent!=root) strcat(para,/); if(recent & recent-child) if(recent-isdir) recent=recent-child; else printf(路徑錯(cuò)誤!n); return 1; while(ichild) i+; if(recent-isdir) recent=recent-child; else print

20、f(路徑錯(cuò)誤n); return 0; strcat(para,/); while(toparai!=/ & ifilename,recentpara)!=0 | (recent-isdir!=1) & recent-next!=null) recent=recent-next; if(strcmp(recent-filename,recentpara)=0) if(recent-isdir=0) strcpy(para,temppara); recent=temp; printf(是文件不是目錄。n); return 0; strcat(para,recent-filename); if(s

21、trcmp(recent-filename,recentpara)!=0 | recent=null) strcpy(para,temppara); recent=temp; printf(輸入路徑錯(cuò)誤n); return 0; return 1;int del() char filenamefilename_length; cinfilename; temp=new fnode; if(recent-child) temp=recent-child; while(temp-next & (strcmp(temp-filename,filename)!=0 | temp-isdir!=0) t

22、emp=temp-next; if(strcmp(temp-filename,filename)!=0) cout不存在該文件!endl; return 0; else cout不存在該文件!parent=null) temp-prev-next=temp-next; if(temp-next) temp-next-prev=temp-prev; temp-prev=temp-next=null; else if(temp-next) temp-next-parent=temp-parent; temp-parent-child=temp-next; delete temp; cout文件已刪

23、除!endl; bool chklogin(char *users, char *pwd) int i; for(i=0; i8; i+) if( (strcmp(users,)=0) & (strcmp(pwd,usrarrayi.pwd)=0) return true; return false;void help(void) cout 命 令 一 覽 endl; coutendl; coutcreate: 建立文件。 endl; coutread: 讀取文件。 endl; coutwrite: 寫入文件,支持多線程 endl; coutdel : 刪除文件。

24、endl; coutmkdir: 建立目錄。 endl; coutcd: 切換目錄。 endl; coutlogout: 退出登錄。 endl;int run() coutlinux:para; cincommand; if(strcmp(command,mkdir)=0) mkdir(); else if(strcmp(command,dir)=0) dir(); else if(strcmp(command,cd)=0) cd(); else if(strcmp(command,create)=0) create(); else if(strcmp(command,read)=0) read(); else if(strcmp(command,write)=0) write();else if(strcmp(command,del)=0) del();else if(strcmp(command,help)=0) help(); else if(strcmp(command,logout)=0) return 0; else cout請(qǐng)參考help提供的命令列表!endl; int main()int i=0;bool in=false;char users8,pwd12; cout*endl;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論