Linux文件系統(tǒng)實驗報告.doc

上傳人:小** 文檔編號:16661302 上傳時間:2020-10-20 格式:DOC 頁數(shù):19 大?。?41.50KB
收藏 版權(quán)申訴 舉報 下載
Linux文件系統(tǒng)實驗報告.doc_第1頁
第1頁 / 共19頁
Linux文件系統(tǒng)實驗報告.doc_第2頁
第2頁 / 共19頁
Linux文件系統(tǒng)實驗報告.doc_第3頁
第3頁 / 共19頁

下載文檔到電腦,查找使用更方便

5 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《Linux文件系統(tǒng)實驗報告.doc》由會員分享,可在線閱讀,更多相關(guān)《Linux文件系統(tǒng)實驗報告.doc(19頁珍藏版)》請在裝配圖網(wǎng)上搜索。

1、黃岡師范學院提高型實驗報告實驗課題文件系統(tǒng)的設(shè)計與實現(xiàn)(實驗類型:綜合性 R設(shè)計性 應(yīng)用性)實驗課程操作系統(tǒng)原理實驗時間20152016 第二學期學生姓名何正發(fā)專業(yè)班級軟件工程1401學 號2014263040107一、實驗?zāi)康暮鸵蟪煽儯?1、熟悉操作系統(tǒng)設(shè)計的過程,鞏固操作系統(tǒng)的基本知識,加深對操作原理、功能及各種不同的存儲管理方法理解與應(yīng)用;2、學會運用各種語言、軟件開發(fā)新軟件的基本方法;3、增強實際應(yīng)用能力和動手操作能力。二、實驗條件 Win7 /Windows 8.1/Linux等操作系統(tǒng),裝有java、C、C+、C#等語言工具的環(huán)境。三、實驗原理分析可以選擇最佳適應(yīng)算法,按照從小到

2、大的次序組成空閑區(qū)自由鏈,當用戶作業(yè)或進程申請一個空閑區(qū)時,存儲管理程序從表頭開始查找,當找到第一個満足要求的空閑區(qū)時,停止查找。如果該空閑區(qū)大于請求表中的請求長度,將減去請求長度后的剩余空閑區(qū)部分留在可用表中?;厥諘r,從作鏈中刪去要回收的作業(yè)塊,同時在空閑鏈中插入該作業(yè)大小的空閑區(qū),并按順序排列四、實驗方案或步驟1、應(yīng)用環(huán)境、需求分析本模擬系統(tǒng)主要針對文件的管理和操作名主要有:創(chuàng)建用戶、文件、文件夾,讀文件,寫文件,執(zhí)行文件,關(guān)閉文件,刪除用戶、文件夾、文件的功能。創(chuàng)建用戶、文件、文件夾:在對系統(tǒng)發(fā)出操作命令之前必須先登錄用戶,然而登錄之前必須創(chuàng)建該用戶。在創(chuàng)建完后,可通過登錄用戶來創(chuàng)建文件

3、和文件夾。在創(chuàng)建文件時可設(shè)置文件的屬性和輸入文件的內(nèi)容。讀文件:讀取任何已創(chuàng)建的只讀或讀寫文件的內(nèi)容;如果所要讀的文件不是可讀文件時,系統(tǒng)會顯示該文件不可讀;如果所讀文件不存在,系統(tǒng)會顯示文件不存在。寫文件用戶可寫或重寫讀寫文件中的內(nèi)容,并保存文件中的重寫內(nèi)容,以供下次讀取;當所要寫的文件不是可寫的文件時,系統(tǒng)會顯示該文件不可寫;當所要寫的文件并不存在時,系統(tǒng)會顯示該文件不存在。執(zhí)行文件:登錄用戶后,用戶可執(zhí)行系統(tǒng)中已創(chuàng)建的執(zhí)行文件;當該文件不是可執(zhí)行文件時,系統(tǒng)會顯示該文件不可執(zhí)行;當該文件不存在時,系統(tǒng)將會顯示該文件不存在。關(guān)閉文件:可通過選擇關(guān)閉文件的功能選項,來關(guān)閉系統(tǒng)中所有打開的文件

4、,如果沒有文件被打開,則系統(tǒng)會顯示沒有文件打開。刪除用戶、文件、文件夾:用戶可通過選擇刪除的功能選項來刪除不想再保存的文件和文件夾,刪除后,用戶會自動注銷;當選擇刪除用戶的功能選項時,系統(tǒng)會刪除該用戶,以及該用戶所創(chuàng)建的所有文件和文件夾。2、概要設(shè)計打開文件流程圖: 寫文件流程圖:關(guān)閉文件流程圖:3、詳細設(shè)計(1)用戶結(jié)構(gòu):賬號與密碼結(jié)構(gòu)typedef struct users char name8;char pwd10;users;本系統(tǒng)有8個默認的用戶名,前面是用戶名,后面為密碼,用戶登陸時只要輸入正確便可進入系統(tǒng),否則提示失敗要求重新輸入。users usrarray8 =usr1,us

5、r1, 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 content255;fnode *parent;fnode *child;fnode *prev;fnode *next;b)函數(shù)介紹fnode *initfile(char filename,int isdir);/初始化文件或目錄void createroot();/建立系

6、統(tǒng)根目錄int run();系統(tǒng)運行int findpara(char *topara);對參數(shù)進行處理bool chklogin(char *users, char *pwd);檢查賬號與口令void help();命令列表int mkdir();建立目錄int create();建立文件int read();讀取文件int write();寫入文件int del();刪除文件int cd();切換目錄int dir();文件與目錄列表4、 代碼清單 #include stdio.h#include iostream.h#include string.h#include iomanip.h#

7、define FILENAME_LENGTH 10 /文件名稱長度#define COMMAND_LENGTH 10 /命令行長度#define PARA_LENGTH 30 /參數(shù)長度 /賬號結(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;/賬號user

8、s usrarray8 = usr1,usr1, usr2,usr2, usr3,usr3, 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 wr

9、ite(); int del(); int cd(); int dir();fnode *root,*recent,*temp,*ttemp;char paraPARA_LENGTH,commandCOMMAND_LENGTH,tempparaPARA_LENGTH,recentparaPARA_LENGTH;/創(chuàng)建文件與目錄結(jié)點 fnode* initfile(char filename,int isdir) fnode *node=new fnode; strcpy(node-filename,filename); node-isdir=isdir; node-isopen=0; node

10、-parent=NULL; node-child=NULL; node-prev=NULL; node-next=NULL; return node;/創(chuàng)建文件存儲結(jié)點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; t

11、emp-child=NULL; recent-child=temp; temp-prev=temp-next=NULL; else ttemp=recent-child; while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=1) printf(對不起,目錄已存在!); return 1; ttemp-next=temp; temp-parent=NULL; temp-child=NULL; temp-prev=ttemp; temp-next=NULL; return

12、 1;int create() temp=initfile( ,0); cintemp-filename; gets(temp-content); /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-is

13、dir=0) printf(對不起,文件已存在!); return 1; ttemp-next=temp; temp-parent=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 fil

14、enameendl;i+; else cout filenamenext; coutTotal: directors i files 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

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

16、!endl; return 1; cout文件不存在!topara; if(strcmp(topara,.)=0) int i; 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

17、(strcmp(topara,/)=0) recent=root; strcpy(para,/); return 1; temp=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(路徑錯誤!n); return 1; whi

18、le(ichild) i+; if(recent-isdir) recent=recent-child; else printf(路徑錯誤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;

19、printf(是文件不是目錄。n); return 0; strcat(para,recent-filename); if(strcmp(recent-filename,recentpara)!=0 | recent=NULL) strcpy(para,temppara); recent=temp; printf(輸入路徑錯誤n); return 0; return 1;int del() char filenameFILENAME_LENGTH; cinfilename; temp=new fnode; if(recent-child) temp=recent-child; while(te

20、mp-next & (strcmp(temp-filename,filename)!=0 | temp-isdir!=0) temp=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=

21、temp-parent; temp-parent-child=temp-next; delete temp; cout文件已刪除!endl; bool chklogin(char *users, char *pwd) int i; for(i=0; i8; i+) if( (strcmp(users,usrarrayi.name)=0) & (strcmp(pwd,usrarrayi.pwd)=0) return true; return false;void help(void) cout 命 令 一 覽 endl; coutendl; coutcreate: 建立文件。 endl; cou

22、tread: 讀取文件。 endl; coutwrite: 寫入文件,支持多線程 endl; coutdel : 刪除文件。 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(c

23、ommand,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請參考help提供的命令列表!endl; int main()int i=0;bool in=false;char use

24、rs8,pwd12; cout*endl; cout* 簡單的二級Linux文件系統(tǒng) *endl; cout* 賬號:usr1-usr8 密碼:usr1-usr8 *endl; cout* 你只有三次機會來試驗賬號 *endl; cout* 鍵入help可以獲取幫助 *endl; cout*endl; coutendl;while(i3)coutusers;coutpwd;if(chklogin(users,pwd)in=true;break;i+;createroot();while(in)if(!run()break;五、實驗結(jié)果與分析 能夠很成功的對文件進行讀寫操作,意見保存和刪除六、討論總結(jié)通過這次提高型實驗,我明白了做一個系統(tǒng)的難度之大,首先要進行需求分析,然后通過ER圖來清晰自己的思路,整個過程雖然很繁瑣,很復(fù)雜,但完成任務(wù)后,內(nèi)心的成就感爆棚,給自己的未來增加了滿滿的信心!這次的實驗,我學會了如何用代碼實現(xiàn)操作系統(tǒng)的部分功能,如創(chuàng)建文件,讀文件,寫文件,創(chuàng)建文件夾,以及刪除文件等等,瞬間覺得特別高大上。希望今后能學習到更多到社會上有用的東西,加油!

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

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!